On Sun, Jan 10, 2016 at 07:21:37PM +0100, Mark Kettenis wrote:
> Apparently the CIS on the Broadcom BCM43341 in the ASUS X205TA has
> CISTPL_NULL codes, which causes somedmesg spam:
>
> sdmmc1: CIS parse error at 4286, tuple code 0, length 0
>
> Handling these is simple. They're just bytes that have to be skipped.
> Diff below rearranges the parsing loop a bit to accomplish this. As a
> bonus, it also prevents us from reading beyond the CISTPL_END code.
>
> ok?
This closer matches the pcmcia cis code, the simplified sdio spec
"Basic Tuple Format and Tuple Chain Structure" section, and
looks fine to me. ok jsg@
>
>
> Index: sdmmc_cis.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/sdmmc/sdmmc_cis.c,v
> retrieving revision 1.5
> diff -u -p -r1.5 sdmmc_cis.c
> --- sdmmc_cis.c 24 Aug 2010 14:52:23 -0000 1.5
> +++ sdmmc_cis.c 10 Jan 2016 18:16:05 -0000
> @@ -77,13 +77,16 @@ sdmmc_read_cis(struct sdmmc_function *sf
>
> for (;;) {
> tplcode = sdmmc_io_read_1(sf, reg++);
> - tpllen = sdmmc_io_read_1(sf, reg++);
> + if (tplcode == SD_IO_CISTPL_END)
> + break;
> + if (tplcode == SD_IO_CISTPL_NULL)
> + continue;
>
> - if (tplcode == 0xff || tpllen == 0) {
> - if (tplcode != 0xff)
> - printf("%s: CIS parse error at %d, "
> - "tuple code %#x, length %d\n",
> - DEVNAME(sf->sc), reg, tplcode, tpllen);
> + tpllen = sdmmc_io_read_1(sf, reg++);
> + if (tpllen == 0) {
> + printf("%s: CIS parse error at %d, "
> + "tuple code %#x, length %d\n",
> + DEVNAME(sf->sc), reg, tplcode, tpllen);
> break;
> }
>
> Index: sdmmc_ioreg.h
> ===================================================================
> RCS file: /cvs/src/sys/dev/sdmmc/sdmmc_ioreg.h,v
> retrieving revision 1.4
> diff -u -p -r1.4 sdmmc_ioreg.h
> --- sdmmc_ioreg.h 2 Jun 2007 01:48:37 -0000 1.4
> +++ sdmmc_ioreg.h 10 Jan 2016 18:16:05 -0000
> @@ -82,10 +82,12 @@
> #define SD_IO_CIS_SIZE 0x17000
>
> /* CIS tuple codes (based on PC Card 16) */
> +#define SD_IO_CISTPL_NULL 0x00
> #define SD_IO_CISTPL_VERS_1 0x15
> #define SD_IO_CISTPL_MANFID 0x20
> #define SD_IO_CISTPL_FUNCID 0x21
> #define SD_IO_CISTPL_FUNCE 0x22
> +#define SD_IO_CISTPL_END 0xff
>
> /* CISTPL_FUNCID codes */
> #define SDMMC_FUNCTION_WLAN 0x0c
>