mmc: sdio: Export CISTPL_VERS_1 attributes to userspace
cover mmc: sdio: Export CISTPL_VERS_1 attributes to userspace
CISTPL_VERS_1 structure contains useful information for identification of SDIO cards. It contains revision number according to which standard is SDIO card compliant. And also it contain human readable info strings which should contain manufacturer name or product information, like for old PCMCIA cards. SDIO simplified specification 3.00 just contain reference to PCMCIA metaformat specification for definition of that CISTPL_VERS_1 structure itself.
Human readable SDIO card strings can be useful for userspace to do card identification. Until now kernel exported to userspace only vendor and device numbers but these numbers do not help to identify new or unknown cards.
I have tested these patches with Marwell 88W8997 SDIO card (WiFi+Bluetooth) and here is content of attributes available in userspace:
$ grep . /sys/class/mmc_host/mmc0/mmc0:0001/* /sys/class/mmc_host/mmc0/mmc0:0001/*/* /sys/class/mmc_host/mmc0/mmc0:0001/device:0x9140 /sys/class/mmc_host/mmc0/mmc0:0001/info1:Marvell /sys/class/mmc_host/mmc0/mmc0:0001/info2:Wireless Device ID: 50 /sys/class/mmc_host/mmc0/mmc0:0001/ocr:0x00200000 /sys/class/mmc_host/mmc0/mmc0:0001/rca:0x0001 /sys/class/mmc_host/mmc0/mmc0:0001/revision:1.0 /sys/class/mmc_host/mmc0/mmc0:0001/type:SDIO /sys/class/mmc_host/mmc0/mmc0:0001/uevent:MMC_TYPE=SDIO /sys/class/mmc_host/mmc0/mmc0:0001/uevent:SDIO_ID=02DF:9140 /sys/class/mmc_host/mmc0/mmc0:0001/uevent:SDIO_REVISION=1.0 /sys/class/mmc_host/mmc0/mmc0:0001/uevent:SDIO_INFO1=Marvell /sys/class/mmc_host/mmc0/mmc0:0001/uevent:SDIO_INFO2=Wireless Device ID: 50 /sys/class/mmc_host/mmc0/mmc0:0001/uevent:SDIO_INFO3= /sys/class/mmc_host/mmc0/mmc0:0001/vendor:0x02df /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/class:0x00 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/device:0x9141 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/info1:Marvell WiFi Device /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/modalias:sdio:c00v02DFd9141 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/revision:1.0 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/uevent:DRIVER=mwifiex_sdio /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/uevent:SDIO_CLASS=00 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/uevent:SDIO_ID=02DF:9141 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/uevent:SDIO_REVISION=1.0 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/uevent:SDIO_INFO1=Marvell WiFi Device /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/uevent:SDIO_INFO2= /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/uevent:MODALIAS=sdio:c00v02DFd9141 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/vendor:0x02df /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/class:0x00 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/device:0x9142 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/info1:Marvell Bluetooth Device /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/modalias:sdio:c00v02DFd9142 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/revision:1.0 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/uevent:DRIVER=btmrvl_sdio /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/uevent:SDIO_CLASS=00 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/uevent:SDIO_ID=02DF:9142 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/uevent:SDIO_REVISION=1.0 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/uevent:SDIO_INFO1=Marvell Bluetooth Device /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/uevent:SDIO_INFO2= /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/uevent:MODALIAS=sdio:c00v02DFd9142 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/vendor:0x02df /sys/class/mmc_host/mmc0/mmc0:0001/power/control:auto /sys/class/mmc_host/mmc0/mmc0:0001/power/runtime_active_time:0 /sys/class/mmc_host/mmc0/mmc0:0001/power/runtime_status:unsupported /sys/class/mmc_host/mmc0/mmc0:0001/power/runtime_suspended_time:0 /sys/class/mmc_host/mmc0/mmc0:0001/subsystem/drivers_autoprobe:1
As can be seen SDIO card does not provide all 4 info strings as required by SDIO/PCMCIA specificaion and the third and the second strings are empty.
Pali Rohár (4):
mmc: sdio: Check for CISTPL_VERS_1 buffer size
mmc: sdio: Parse CISTPL_VERS_1 major and minor revision numbers
mmc: sdio: Extend sdio_config_attr macro and use it also for modalias
mmc: sdio: Export SDIO revision and info strings to userspace
drivers/mmc/core/bus.c | 12 ++++++++ drivers/mmc/core/sd.c | 36 +++++++++++++++++++++-- drivers/mmc/core/sdio.c | 24 ++++++++++++++++ drivers/mmc/core/sdio_bus.c | 54 ++++++++++++++++++++++++++--------- drivers/mmc/core/sdio_cis.c | 11 +++++++ include/linux/mmc/card.h | 2 ++ include/linux/mmc/sdio_func.h | 2 ++ 7 files changed, 124 insertions(+), 17 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/4 mmc: sdio: Check for CISTPL_VERS_1 buffer size
Before parsing CISTPL_VERS_1 structure check that its size is at least two bytes to prevent buffer overflow.
--- drivers/mmc/core/sdio_cis.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mmc/core/sdio_cis.c +3 -0
@@ -24,10 +24,13 @@ static int cistpl_vers_1(struct mmc_card *card, struct sdio_func *func, const unsigned char *buf, unsigned size) { unsigned i, nr_strings;char **buffer, *string; +if (size <2 ) +return 0 ; +/* Find all null-terminated (including zero length) strings in the TPLLV1_INFO field. Trailing garbage is ignored. */ buf +=2 ; size -=2 ;
Signature · 1 line
2.20.1
PATCH 2/4 mmc: sdio: Parse CISTPL_VERS_1 major and minor revision numbers
In reply to Pali RohárThey should indicate compliance of standard.
--- drivers/mmc/core/sdio_cis.c | 8 ++++++++ include/linux/mmc/card.h | 2 ++ include/linux/mmc/sdio_func.h | 2 ++ 3 files changed, 12 insertions(+)
drivers/mmc/core/sdio_cis.c +8 -0
@@ -23,12 +23,16 @@static int cistpl_vers_1 (struct mmc_card *card,struct sdio_func *func,const unsigned char *buf,unsigned size) { +u8 major_rev, minor_rev;unsigned i, nr_strings;char **buffer, *string;if (size <2 )return 0 ; + major_rev = buf[0 ]; + minor_rev = buf[1 ]; +/* Find all null-terminated (including zero length) strings in the TPLLV1_INFO field. Trailing garbage is ignored. */ buf +=2 ;
@@ -60,9 +64,13 @@ static int cistpl_vers_1(struct mmc_card *card, struct sdio_func *func, }if (func) { + func->major_rev = major_rev; + func->minor_rev = minor_rev; func->num_info = nr_strings; func->info = (const char **)buffer; }else { + card->major_rev = major_rev; + card->minor_rev = minor_rev; card->num_info = nr_strings; card->info = (const char **)buffer; }
include/linux/mmc/card.h +2 -0
@@ -297,6 +297,8 @@ struct mmc_card {struct sdio_cis cis;/* common tuple info */ struct sdio_func *sdio_func[SDIO_MAX_FUNCS ];/* SDIO functions (devices) */ struct sdio_func *sdio_single_irq;/* SDIO function when only one IRQ active */ +u8 major_rev;/* major revision number */ +u8 minor_rev;/* minor revision number */ unsigned num_info;/* number of info strings */ const char **info;/* info strings */ struct sdio_func_tuple *tuples;/* unknown common tuples */
include/linux/mmc/sdio_func.h +2 -0
@@ -51,6 +51,8 @@ struct sdio_func {u8 *tmpbuf;/* DMA:able scratch buffer */ +u8 major_rev;/* major revision number */ +u8 minor_rev;/* minor revision number */ unsigned num_info;/* number of info strings */ const char **info;/* info strings */
Signature · 1 line
2.20.1
PATCH 3/4 mmc: sdio: Extend sdio_config_attr macro and use it also for modalias
In reply to Pali RohárThis simplify code for generating sdio config attributes and allows easily define new sdio attributes.
--- drivers/mmc/core/sdio_bus.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-)
drivers/mmc/core/sdio_bus.c +6 -14
@@ -28,29 +28,21 @@#define to_sdio_driver (d) container_of(d, struct sdio_driver, drv)/* show configuration fields */ -#define sdio_config_attr (field, format_string) \ +#define sdio_config_attr(field, format_string, args...) \ static ssize_t \ field##_show(struct device *dev, struct device_attribute *attr, char *buf) \ { \ struct sdio_func *func; \ \ func = dev_to_sdio_func (dev); \ - return sprintf (buf, format_string, func->field); \ + return sprintf(buf, format_string, args); \ } \ static DEVICE_ATTR_RO(field) -sdio_config_attr (class,"0x%02x\n" ); -sdio_config_attr (vendor,"0x%04x\n" ); -sdio_config_attr (device,"0x%04x\n" ); - -static ssize_t modalias_show (struct device *dev,struct device_attribute *attr,char *buf) -{ -struct sdio_func *func =dev_to_sdio_func (dev); - -return sprintf (buf,"sdio:c%02Xv%04Xd%04X\n" , - func->class, func->vendor, func->device); -} -static DEVICE_ATTR_RO (modalias); +sdio_config_attr (class,"0x%02x\n" , func->class); +sdio_config_attr (vendor,"0x%04x\n" , func->vendor); +sdio_config_attr (device,"0x%04x\n" , func->device); +sdio_config_attr (modalias,"sdio:c%02Xv%04Xd%04X\n" , func->class, func->vendor, func->device);static struct attribute *sdio_dev_attrs[] = { &dev_attr_class.attr,
Signature · 1 line
2.20.1
PATCH 4/4 mmc: sdio: Export SDIO revision and info strings to userspace
In reply to Pali RohárFor SDIO functions, SDIO cards and SD COMBO cards are exported revision number and info strings from CISTPL_VERS_1 structure. Revision number should indicate compliance of standard and info strings should contain product information in same format as product information for PCMCIA cards.
Product information for PCMCIA cards should contain following strings in this order: Manufacturer, Product Name, Lot number, Programming Conditions.
Note that not all SDIO cards export all those info strings in that order as described in PCMCIA Metaformat Specification.
--- drivers/mmc/core/bus.c | 12 ++++++++++++ drivers/mmc/core/sd.c | 36 +++++++++++++++++++++++++++++++++--- drivers/mmc/core/sdio.c | 24 ++++++++++++++++++++++++ drivers/mmc/core/sdio_bus.c | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 103 insertions(+), 3 deletions(-)
drivers/mmc/core/bus.c +12 -0
@@ -68,6 +68,7 @@ mmc_bus_uevent(struct device *dev, struct kobj_uevent_env *env) {struct mmc_card *card =mmc_dev_to_card (dev);const char *type; +unsigned int i;int retval =0 ;switch (card->type) {
@@ -98,6 +99,17 @@ mmc_bus_uevent(struct device *dev, struct kobj_uevent_env *env) card->cis.vendor, card->cis.device);if (retval)return retval; + + retval =add_uevent_var (env,"SDIO_REVISION=%u.%u" , + card->major_rev, card->minor_rev); +if (retval) +return retval; + +for (i =0 ; i < card->num_info; i++) { + retval =add_uevent_var (env,"SDIO_INFO%u=%s" , i+1 , card->info[i]); +if (retval) +return retval; + } }/*
drivers/mmc/core/sd.c +33 -3
@@ -709,10 +709,34 @@ static DEVICE_ATTR(dsr, S_IRUGO, mmc_dsr_show, NULL);MMC_DEV_ATTR (vendor,"0x%04x\n" , card->cis.vendor);MMC_DEV_ATTR (device,"0x%04x\n" , card->cis.device); +MMC_DEV_ATTR (revision,"%u.%u\n" , card->major_rev, card->minor_rev); + +#define sdio_info_attr (num) \ +static ssize_t info##num##_show(struct device *dev, struct device_attribute *attr, char *buf) \ +{ \ + struct mmc_card *card = mmc_dev_to_card(dev); \ + \ + if (num > card->num_info) \ + return -ENODATA; \ + if (!card->info[num-1][0]) \ + return 0; \ + return sprintf(buf, "%s\n", card->info[num-1]); \ +} \ +static DEVICE_ATTR_RO(info##num) + +sdio_info_attr (1 ); +sdio_info_attr (2 ); +sdio_info_attr (3 ); +sdio_info_attr (4 );static struct attribute *sd_std_attrs[] = { &dev_attr_vendor.attr, &dev_attr_device.attr, + &dev_attr_revision.attr, + &dev_attr_info1.attr, + &dev_attr_info2.attr, + &dev_attr_info3.attr, + &dev_attr_info4.attr, &dev_attr_cid.attr, &dev_attr_csd.attr, &dev_attr_scr.attr,
@@ -738,9 +762,15 @@ static umode_t sd_std_is_visible(struct kobject *kobj, struct attribute *attr, struct device *dev = container_of(kobj, struct device, kobj);struct mmc_card *card =mmc_dev_to_card (dev); -/* CIS vendor and device ids are available only for Combo cards */ -if ((attr == &dev_attr_vendor.attr || attr == &dev_attr_device.attr) && - card->type !=MMC_TYPE_SD_COMBO ) +/* CIS vendor and device ids, revision and info string are available only for Combo cards */ +if ((attr == &dev_attr_vendor.attr || + attr == &dev_attr_device.attr || + attr == &dev_attr_revision.attr || + attr == &dev_attr_info1.attr || + attr == &dev_attr_info2.attr || + attr == &dev_attr_info3.attr || + attr == &dev_attr_info4.attr + ) && card->type !=MMC_TYPE_SD_COMBO )return 0 ;return attr->mode;
drivers/mmc/core/sdio.c +24 -0
@@ -29,12 +29,36 @@MMC_DEV_ATTR (vendor,"0x%04x\n" , card->cis.vendor);MMC_DEV_ATTR (device,"0x%04x\n" , card->cis.device); +MMC_DEV_ATTR (revision,"%u.%u\n" , card->major_rev, card->minor_rev);MMC_DEV_ATTR (ocr,"0x%08x\n" , card->ocr);MMC_DEV_ATTR (rca,"0x%04x\n" , card->rca); +#define sdio_info_attr (num) \ +static ssize_t info##num##_show(struct device *dev, struct device_attribute *attr, char *buf) \ +{ \ + struct mmc_card *card = mmc_dev_to_card(dev); \ + \ + if (num > card->num_info) \ + return -ENODATA; \ + if (!card->info[num-1][0]) \ + return 0; \ + return sprintf(buf, "%s\n", card->info[num-1]); \ +} \ +static DEVICE_ATTR_RO(info##num) + +sdio_info_attr (1 ); +sdio_info_attr (2 ); +sdio_info_attr (3 ); +sdio_info_attr (4 ); +static struct attribute *sdio_std_attrs[] = { &dev_attr_vendor.attr, &dev_attr_device.attr, + &dev_attr_revision.attr, + &dev_attr_info1.attr, + &dev_attr_info2.attr, + &dev_attr_info3.attr, + &dev_attr_info4.attr, &dev_attr_ocr.attr, &dev_attr_rca.attr,NULL ,
drivers/mmc/core/sdio_bus.c +34 -0
@@ -42,12 +42,36 @@ static DEVICE_ATTR_RO(field)sdio_config_attr (class,"0x%02x\n" , func->class);sdio_config_attr (vendor,"0x%04x\n" , func->vendor);sdio_config_attr (device,"0x%04x\n" , func->device); +sdio_config_attr (revision,"%u.%u\n" , func->major_rev, func->minor_rev);sdio_config_attr (modalias,"sdio:c%02Xv%04Xd%04X\n" , func->class, func->vendor, func->device); +#define sdio_info_attr (num) \ +static ssize_t info##num##_show(struct device *dev, struct device_attribute *attr, char *buf) \ +{ \ + struct sdio_func *func = dev_to_sdio_func(dev); \ + \ + if (num > func->num_info) \ + return -ENODATA; \ + if (!func->info[num-1][0]) \ + return 0; \ + return sprintf(buf, "%s\n", func->info[num-1]); \ +} \ +static DEVICE_ATTR_RO(info##num) + +sdio_info_attr (1 ); +sdio_info_attr (2 ); +sdio_info_attr (3 ); +sdio_info_attr (4 ); +static struct attribute *sdio_dev_attrs[] = { &dev_attr_class.attr, &dev_attr_vendor.attr, &dev_attr_device.attr, + &dev_attr_revision.attr, + &dev_attr_info1.attr, + &dev_attr_info2.attr, + &dev_attr_info3.attr, + &dev_attr_info4.attr, &dev_attr_modalias.attr,NULL , };
@@ -98,6 +122,7 @@ static int sdio_bus_uevent(struct device *dev, struct kobj_uevent_env *env) { struct sdio_func *func = dev_to_sdio_func(dev); +unsigned int i;if (add_uevent_var (env,"SDIO_CLASS=%02X" , func->class))
@@ -107,6 +132,15 @@ sdio_bus_uevent(struct device *dev, struct kobj_uevent_env *env) "SDIO_ID=%04X:%04X", func->vendor, func->device))return -ENOMEM ; +if (add_uevent_var (env, +"SDIO_REVISION=%u.%u" , func->major_rev, func->minor_rev)) +return -ENOMEM ; + +for (i =0 ; i < func->num_info; i++) { +if (add_uevent_var (env,"SDIO_INFO%u=%s" , i+1 , func->info[i])) +return -ENOMEM ; + } +if (add_uevent_var (env,"MODALIAS=sdio:c%02Xv%04Xd%04X" , func->class, func->vendor, func->device))
Signature · 1 line
2.20.1
Hello Ulf! I would like to remind you this SDIO patch series. Could you please look and review it?
Quoted 86 lines · On Monday 27 July 2020 15:38:33 Pali Rohár wrote:
CISTPL_VERS_1structure contains useful information for identification of SDIO cards. It contains revision number according to which standard is SDIO card compliant. And also it contain human readable info strings which should contain manufacturer name or product information, like for old PCMCIA cards. SDIO simplified specification 3.00 just contain reference to PCMCIA metaformat specification for definition of thatCISTPL_VERS_1structure itself.Human readable SDIO card strings can be useful for userspace to do card identification. Until now kernel exported to userspace only vendor and device numbers but these numbers do not help to identify new or unknown cards.
I have tested these patches with Marwell 88W8997 SDIO card (WiFi+Bluetooth) and here is content of attributes available in userspace:
$ grep . /sys/class/mmc_host/mmc0/mmc0:0001/* /sys/class/mmc_host/mmc0/mmc0:0001/*/* /sys/class/mmc_host/mmc0/mmc0:0001/device:0x9140 /sys/class/mmc_host/mmc0/mmc0:0001/info1:Marvell /sys/class/mmc_host/mmc0/mmc0:0001/info2:Wireless Device ID: 50 /sys/class/mmc_host/mmc0/mmc0:0001/ocr:0x00200000 /sys/class/mmc_host/mmc0/mmc0:0001/rca:0x0001 /sys/class/mmc_host/mmc0/mmc0:0001/revision:1.0 /sys/class/mmc_host/mmc0/mmc0:0001/type:SDIO /sys/class/mmc_host/mmc0/mmc0:0001/uevent:MMC_TYPE=SDIO /sys/class/mmc_host/mmc0/mmc0:0001/uevent:SDIO_ID=02DF:9140 /sys/class/mmc_host/mmc0/mmc0:0001/uevent:SDIO_REVISION=1.0 /sys/class/mmc_host/mmc0/mmc0:0001/uevent:SDIO_INFO1=Marvell /sys/class/mmc_host/mmc0/mmc0:0001/uevent:SDIO_INFO2=Wireless Device ID: 50 /sys/class/mmc_host/mmc0/mmc0:0001/uevent:SDIO_INFO3= /sys/class/mmc_host/mmc0/mmc0:0001/vendor:0x02df /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/class:0x00 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/device:0x9141 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/info1:Marvell WiFi Device /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/modalias:sdio:c00v02DFd9141 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/revision:1.0 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/uevent:DRIVER=mwifiex_sdio /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/uevent:SDIO_CLASS=00 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/uevent:SDIO_ID=02DF:9141 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/uevent:SDIO_REVISION=1.0 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/uevent:SDIO_INFO1=Marvell WiFi Device /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/uevent:SDIO_INFO2= /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/uevent:MODALIAS=sdio:c00v02DFd9141 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/vendor:0x02df /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/class:0x00 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/device:0x9142 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/info1:Marvell Bluetooth Device /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/modalias:sdio:c00v02DFd9142 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/revision:1.0 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/uevent:DRIVER=btmrvl_sdio /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/uevent:SDIO_CLASS=00 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/uevent:SDIO_ID=02DF:9142 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/uevent:SDIO_REVISION=1.0 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/uevent:SDIO_INFO1=Marvell Bluetooth Device /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/uevent:SDIO_INFO2= /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/uevent:MODALIAS=sdio:c00v02DFd9142 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/vendor:0x02df /sys/class/mmc_host/mmc0/mmc0:0001/power/control:auto /sys/class/mmc_host/mmc0/mmc0:0001/power/runtime_active_time:0 /sys/class/mmc_host/mmc0/mmc0:0001/power/runtime_status:unsupported /sys/class/mmc_host/mmc0/mmc0:0001/power/runtime_suspended_time:0 /sys/class/mmc_host/mmc0/mmc0:0001/subsystem/drivers_autoprobe:1As can be seen SDIO card does not provide all 4 info strings as required by SDIO/PCMCIA specificaion and the third and the second strings are empty.
Pali Rohár (4):
mmc: sdio: Check forCISTPL_VERS_1buffer size
mmc: sdio: ParseCISTPL_VERS_1major and minor revision numbers
mmc: sdio: Extendsdio_config_attrmacro and use it also for modalias
mmc: sdio: Export SDIO revision and info strings to userspacedrivers/mmc/core/bus.c | 12 ++++++++ drivers/mmc/core/sd.c | 36 +++++++++++++++++++++-- drivers/mmc/core/sdio.c | 24 ++++++++++++++++ drivers/mmc/core/sdio_bus.c | 54 ++++++++++++++++++++++++++--------- drivers/mmc/core/sdio_cis.c | 11 +++++++ include/linux/mmc/card.h | 2 ++ include/linux/mmc/sdio_func.h | 2 ++ 7 files changed, 124 insertions(+), 17 deletions(-)Signature · 1 line
2.20.1
Quoted 3 lines · Pali Rohár
Hello Ulf! I would like to remind you this SDIO patch series. Could you please look and review it?
Yes, thanks for pinging, I will have a look.
Kind regards
Uffe
Quoted 88 lines · On Monday 27 July 2020 15:38:33 Pali Rohár wrote:
Quoted 86 lines
CISTPL_VERS_1structure contains useful information for identification of SDIO cards. It contains revision number according to which standard is SDIO card compliant. And also it contain human readable info strings which should contain manufacturer name or product information, like for old PCMCIA cards. SDIO simplified specification 3.00 just contain reference to PCMCIA metaformat specification for definition of thatCISTPL_VERS_1structure itself.Human readable SDIO card strings can be useful for userspace to do card identification. Until now kernel exported to userspace only vendor and device numbers but these numbers do not help to identify new or unknown cards.
I have tested these patches with Marwell 88W8997 SDIO card (WiFi+Bluetooth) and here is content of attributes available in userspace:
$ grep . /sys/class/mmc_host/mmc0/mmc0:0001/* /sys/class/mmc_host/mmc0/mmc0:0001/*/* /sys/class/mmc_host/mmc0/mmc0:0001/device:0x9140 /sys/class/mmc_host/mmc0/mmc0:0001/info1:Marvell /sys/class/mmc_host/mmc0/mmc0:0001/info2:Wireless Device ID: 50 /sys/class/mmc_host/mmc0/mmc0:0001/ocr:0x00200000 /sys/class/mmc_host/mmc0/mmc0:0001/rca:0x0001 /sys/class/mmc_host/mmc0/mmc0:0001/revision:1.0 /sys/class/mmc_host/mmc0/mmc0:0001/type:SDIO /sys/class/mmc_host/mmc0/mmc0:0001/uevent:MMC_TYPE=SDIO /sys/class/mmc_host/mmc0/mmc0:0001/uevent:SDIO_ID=02DF:9140 /sys/class/mmc_host/mmc0/mmc0:0001/uevent:SDIO_REVISION=1.0 /sys/class/mmc_host/mmc0/mmc0:0001/uevent:SDIO_INFO1=Marvell /sys/class/mmc_host/mmc0/mmc0:0001/uevent:SDIO_INFO2=Wireless Device ID: 50 /sys/class/mmc_host/mmc0/mmc0:0001/uevent:SDIO_INFO3= /sys/class/mmc_host/mmc0/mmc0:0001/vendor:0x02df /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/class:0x00 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/device:0x9141 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/info1:Marvell WiFi Device /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/modalias:sdio:c00v02DFd9141 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/revision:1.0 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/uevent:DRIVER=mwifiex_sdio /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/uevent:SDIO_CLASS=00 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/uevent:SDIO_ID=02DF:9141 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/uevent:SDIO_REVISION=1.0 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/uevent:SDIO_INFO1=Marvell WiFi Device /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/uevent:SDIO_INFO2= /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/uevent:MODALIAS=sdio:c00v02DFd9141 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/vendor:0x02df /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/class:0x00 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/device:0x9142 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/info1:Marvell Bluetooth Device /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/modalias:sdio:c00v02DFd9142 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/revision:1.0 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/uevent:DRIVER=btmrvl_sdio /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/uevent:SDIO_CLASS=00 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/uevent:SDIO_ID=02DF:9142 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/uevent:SDIO_REVISION=1.0 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/uevent:SDIO_INFO1=Marvell Bluetooth Device /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/uevent:SDIO_INFO2= /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/uevent:MODALIAS=sdio:c00v02DFd9142 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/vendor:0x02df /sys/class/mmc_host/mmc0/mmc0:0001/power/control:auto /sys/class/mmc_host/mmc0/mmc0:0001/power/runtime_active_time:0 /sys/class/mmc_host/mmc0/mmc0:0001/power/runtime_status:unsupported /sys/class/mmc_host/mmc0/mmc0:0001/power/runtime_suspended_time:0 /sys/class/mmc_host/mmc0/mmc0:0001/subsystem/drivers_autoprobe:1As can be seen SDIO card does not provide all 4 info strings as required by SDIO/PCMCIA specificaion and the third and the second strings are empty.
Pali Rohár (4):
mmc: sdio: Check forCISTPL_VERS_1buffer size
mmc: sdio: ParseCISTPL_VERS_1major and minor revision numbers
mmc: sdio: Extendsdio_config_attrmacro and use it also for modalias
mmc: sdio: Export SDIO revision and info strings to userspacedrivers/mmc/core/bus.c | 12 ++++++++ drivers/mmc/core/sd.c | 36 +++++++++++++++++++++-- drivers/mmc/core/sdio.c | 24 ++++++++++++++++ drivers/mmc/core/sdio_bus.c | 54 ++++++++++++++++++++++++++--------- drivers/mmc/core/sdio_cis.c | 11 +++++++ include/linux/mmc/card.h | 2 ++ include/linux/mmc/sdio_func.h | 2 ++ 7 files changed, 124 insertions(+), 17 deletions(-)--
2.20.1
Quoted 84 lines · Pali Rohár
CISTPL_VERS_1structure contains useful information for identification of SDIO cards. It contains revision number according to which standard is SDIO card compliant. And also it contain human readable info strings which should contain manufacturer name or product information, like for old PCMCIA cards. SDIO simplified specification 3.00 just contain reference to PCMCIA metaformat specification for definition of thatCISTPL_VERS_1structure itself.Human readable SDIO card strings can be useful for userspace to do card identification. Until now kernel exported to userspace only vendor and device numbers but these numbers do not help to identify new or unknown cards.
I have tested these patches with Marwell 88W8997 SDIO card (WiFi+Bluetooth) and here is content of attributes available in userspace:
$ grep . /sys/class/mmc_host/mmc0/mmc0:0001/* /sys/class/mmc_host/mmc0/mmc0:0001/*/* /sys/class/mmc_host/mmc0/mmc0:0001/device:0x9140 /sys/class/mmc_host/mmc0/mmc0:0001/info1:Marvell /sys/class/mmc_host/mmc0/mmc0:0001/info2:Wireless Device ID: 50 /sys/class/mmc_host/mmc0/mmc0:0001/ocr:0x00200000 /sys/class/mmc_host/mmc0/mmc0:0001/rca:0x0001 /sys/class/mmc_host/mmc0/mmc0:0001/revision:1.0 /sys/class/mmc_host/mmc0/mmc0:0001/type:SDIO /sys/class/mmc_host/mmc0/mmc0:0001/uevent:MMC_TYPE=SDIO /sys/class/mmc_host/mmc0/mmc0:0001/uevent:SDIO_ID=02DF:9140 /sys/class/mmc_host/mmc0/mmc0:0001/uevent:SDIO_REVISION=1.0 /sys/class/mmc_host/mmc0/mmc0:0001/uevent:SDIO_INFO1=Marvell /sys/class/mmc_host/mmc0/mmc0:0001/uevent:SDIO_INFO2=Wireless Device ID: 50 /sys/class/mmc_host/mmc0/mmc0:0001/uevent:SDIO_INFO3= /sys/class/mmc_host/mmc0/mmc0:0001/vendor:0x02df /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/class:0x00 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/device:0x9141 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/info1:Marvell WiFi Device /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/modalias:sdio:c00v02DFd9141 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/revision:1.0 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/uevent:DRIVER=mwifiex_sdio /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/uevent:SDIO_CLASS=00 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/uevent:SDIO_ID=02DF:9141 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/uevent:SDIO_REVISION=1.0 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/uevent:SDIO_INFO1=Marvell WiFi Device /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/uevent:SDIO_INFO2= /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/uevent:MODALIAS=sdio:c00v02DFd9141 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:1/vendor:0x02df /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/class:0x00 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/device:0x9142 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/info1:Marvell Bluetooth Device /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/modalias:sdio:c00v02DFd9142 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/revision:1.0 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/uevent:DRIVER=btmrvl_sdio /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/uevent:SDIO_CLASS=00 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/uevent:SDIO_ID=02DF:9142 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/uevent:SDIO_REVISION=1.0 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/uevent:SDIO_INFO1=Marvell Bluetooth Device /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/uevent:SDIO_INFO2= /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/uevent:MODALIAS=sdio:c00v02DFd9142 /sys/class/mmc_host/mmc0/mmc0:0001/mmc0:0001:2/vendor:0x02df /sys/class/mmc_host/mmc0/mmc0:0001/power/control:auto /sys/class/mmc_host/mmc0/mmc0:0001/power/runtime_active_time:0 /sys/class/mmc_host/mmc0/mmc0:0001/power/runtime_status:unsupported /sys/class/mmc_host/mmc0/mmc0:0001/power/runtime_suspended_time:0 /sys/class/mmc_host/mmc0/mmc0:0001/subsystem/drivers_autoprobe:1As can be seen SDIO card does not provide all 4 info strings as required by SDIO/PCMCIA specificaion and the third and the second strings are empty.
Pali Rohár (4):
mmc: sdio: Check forCISTPL_VERS_1buffer size
mmc: sdio: ParseCISTPL_VERS_1major and minor revision numbers
mmc: sdio: Extendsdio_config_attrmacro and use it also for modalias
mmc: sdio: Export SDIO revision and info strings to userspacedrivers/mmc/core/bus.c | 12 ++++++++ drivers/mmc/core/sd.c | 36 +++++++++++++++++++++-- drivers/mmc/core/sdio.c | 24 ++++++++++++++++ drivers/mmc/core/sdio_bus.c | 54 ++++++++++++++++++++++++++--------- drivers/mmc/core/sdio_cis.c | 11 +++++++ include/linux/mmc/card.h | 2 ++ include/linux/mmc/sdio_func.h | 2 ++ 7 files changed, 124 insertions(+), 17 deletions(-)
Quoted 3 lines
--
2.20.1
Applied for next, thanks!
Kind regards
Uffe