bus: mhi: core: Introduce sysfs ul chan id for mhi chan device
Subsystems (2)
PATCH 1/1 bus: mhi: core: Introduce sysfs ul chan id for mhi chan device
From: "carl.yin" <[email protected]>
User space software like ModemManager can identify the function of the mhi chan device by ul_chan_id.
--- Documentation/ABI/stable/sysfs-bus-mhi | 10 ++++++++++ drivers/bus/mhi/core/init.c | 15 +++++++++++++++ 2 files changed, 25 insertions(+)
Documentation/ABI/stable/sysfs-bus-mhi +10 -0
@@ -19,3 +19,13 @@ Description: The file holds the OEM PK Hash value of the endpoint device read without having the device power on at least once, the file will read all 0's. Users: Any userspace application or clients interested in device info. + +What: /sys/bus/mhi/devices/.../ul_chan_id +Date: November 2020 +KernelVersion: 5.10 +Contact: Carl Yin <[email protected]> +Description: The file holds the uplink chan id of the mhi chan device. + User space software like ModemManager can identify the function of + the mhi chan device. If the mhi device is not a chan device, + eg mhi controller device, the file read -1. +Users: Any userspace application or clients interested in device info.
drivers/bus/mhi/core/init.c +15 -0
@@ -105,9 +105,24 @@ static ssize_t oem_pk_hash_show(struct device *dev, }static DEVICE_ATTR_RO (oem_pk_hash); +static ssize_t ul_chan_id_show (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct mhi_device *mhi_dev =to_mhi_device (dev); +int ul_chan_id =-1 ; + +if (mhi_dev->ul_chan) + ul_chan_id = mhi_dev->ul_chan_id; + +return snprintf (buf,PAGE_SIZE ,"%d\n" , ul_chan_id); +} +static DEVICE_ATTR_RO (ul_chan_id); +static struct attribute *mhi_dev_attrs[] = { &dev_attr_serial_number.attr, &dev_attr_oem_pk_hash.attr, + &dev_attr_ul_chan_id.attr,NULL , };ATTRIBUTE_GROUPS (mhi_dev);
Signature · 1 line
2.25.1
Jeffrey Hugo
NAKQuoted 49 lines · On 10/27/2020 3:43 AM, [email protected] wrote:
From: "carl.yin" <[email protected]>
User space software like ModemManager can identify the function of the mhi chan device by
ul_chan_id.Signed-off-by carl.yin <[email protected]>--- Documentation/ABI/stable/sysfs-bus-mhi | 10 ++++++++++ drivers/bus/mhi/core/init.c | 15 +++++++++++++++ 2 files changed, 25 insertions(+)Documentation/ABI/stable/sysfs-bus-mhi +10
-0@@ -19,3 +19,13 @@ Description: The file holds the OEM PK Hash value of the endpoint device read without having the device power on at least once, the file will read all 0's. Users: Any userspace application or clients interested in device info. + +What: /sys/bus/mhi/devices/.../ul_chan_id +Date: November 2020 +KernelVersion: 5.10 +Contact: Carl Yin <[email protected]> +Description: The file holds the uplink chan id of the mhi chan device. + User space software like ModemManager can identify the function of + the mhi chan device. If the mhi device is not a chan device, + eg mhi controller device, the file read -1. +Users: Any userspace application or clients interested in device info.drivers/bus/mhi/core/init.c +11
-0@@ -105,9 +105,24 @@ static ssize_t oem_pk_hash_show(struct device *dev, }static DEVICE_ATTR_RO (oem_pk_hash); +static ssize_t ul_chan_id_show (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct mhi_device *mhi_dev =to_mhi_device (dev); +int ul_chan_id =-1 ; + +if (mhi_dev->ul_chan) + ul_chan_id = mhi_dev->ul_chan_id; + +return snprintf (buf,PAGE_SIZE ,"%d\n" , ul_chan_id);
drivers/bus/mhi/core/init.c static ssize_t oem_pk_hash_show(struct device *dev, · line 128
Quoted 10 lines
drivers/bus/mhi/core/init.c +4
-0+} +static DEVICE_ATTR_RO (ul_chan_id); +static struct attribute *mhi_dev_attrs[] = { &dev_attr_serial_number.attr, &dev_attr_oem_pk_hash.attr, + &dev_attr_ul_chan_id.attr,NULL , };ATTRIBUTE_GROUPS (mhi_dev);
NACK
Channel ID is a device specific detail. Userspace should be basing decisions on the channel name.
Signature · 3 lines
Jeffrey Hugo Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Hi Carl,
Quoted 66 lines · Jeffrey Hugo
Quoted 52 lines · On 10/27/2020 3:43 AM, [email protected] wrote:
From: "carl.yin" <[email protected]>
User space software like ModemManager can identify the function of the mhi chan device by
ul_chan_id.Signed-off-by carl.yin <[email protected]>---
Documentation/ABI/stable/sysfs-bus-mhi| 10 ++++++++++ drivers/bus/mhi/core/init.c | 15 +++++++++++++++2 files changed, 25 insertions(+)Documentation/ABI/stable/sysfs-bus-mhi +0
-0@@ -19,3 +19,13 @@ Description: The file holds the OEM PK Hashvalue of the endpoint device
read without having the device power on at least once, the file will read all 0's.
Users: Any userspace application or clients interested in device info.Documentation/ABI/stable/sysfs-bus-mhi +6
-0+ +What: /sys/bus/mhi/devices/.../ul_chan_id +Date: November 2020 +KernelVersion: 5.10 +Contact: Carl Yin <[email protected]> +Description: The file holds the uplink chan id of the mhi chandevice.
+ User space software like ModemManager can identify the function of
+ the mhi chan device. If the mhi device is not a chan device, + eg mhi controller device, the file read -1. +Users: Any userspace application or clients interested in device info.drivers/bus/mhi/core/init.c +12
-0@@ -105,9 +105,24 @@ static ssize_t oem_pk_hash_show(struct device *dev, } static DEVICE_ATTR_RO(oem_pk_hash); +static ssize_t ul_chan_id_show (struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct mhi_device *mhi_dev = to_mhi_device(dev); + int ul_chan_id = -1; + + if (mhi_dev->ul_chan) + ul_chan_id = mhi_dev->ul_chan_id; + + return snprintf(buf, PAGE_SIZE, "%d\n", ul_chan_id); +}drivers/bus/mhi/core/init.c static ssize_t oem_pk_hash_show(struct device *dev, · line 128
Quoted 10 lines
drivers/bus/mhi/core/init.c +3
-0+static DEVICE_ATTR_RO (ul_chan_id); + static struct attribute *mhi_dev_attrs[] = { &dev_attr_serial_number.attr, &dev_attr_oem_pk_hash.attr, + &dev_attr_ul_chan_id.attr, NULL, }; ATTRIBUTE_GROUPS(mhi_dev);NACK
Quoted 2 lines
Channel ID is a device specific detail. Userspace should be basing decisions on the channel name.
I agree with Jeff, why do you need to know the channel id, if you need to poll for any device node to get created you can try to open the device node from user space and wait until the device gets opened. Are you trying to wait for EDL channels to get started using UCI ?
Thanks,
Hemant
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Hi Jeffery and Hemant:
Quoted 73 lines · hemantk
On 10/27/20 8:06 AM, Jeffrey Hugo wrote:
Hi Carl,Quoted 69 lines · Jeffrey Hugo
Quoted 55 lines · On 10/27/2020 3:43 AM, [email protected] wrote:
From: "carl.yin" <[email protected]>
User space software like ModemManager can identify the function of the mhi chan device by
ul_chan_id.Signed-off-by carl.yin <[email protected]>---
Documentation/ABI/stable/sysfs-bus-mhi| 10 ++++++++++ drivers/bus/mhi/core/init.c | 15 +++++++++++++++2 files changed, 25 insertions(+)Documentation/ABI/stable/sysfs-bus-mhi +0
-0@@ -19,3 +19,13 @@ Description: The file holds the OEM PK Hashvalue of the endpoint device
read without having the device power on at least once, the file
will read all 0's.
Users: Any userspace application or clients interested in device info.Documentation/ABI/stable/sysfs-bus-mhi +6
-0+ +What: /sys/bus/mhi/devices/.../ul_chan_id +Date: November 2020 +KernelVersion: 5.10 +Contact: Carl Yin <[email protected]> +Description: The file holds the uplink chan id of the mhi chandevice.
+ User space software like ModemManager can identify the function of
+ the mhi chan device. If the mhi device is not a chan device, + eg mhi controller device, the file read -1. +Users: Any userspace application or clients interested in device info.(quoted diff) +0
-0
b/drivers/bus/mhi/core/init.cindex c6b43e9..ac4aa5c 100644drivers/bus/mhi/core/init.c +10
-0@@ -105,9 +105,24 @@ static ssize_t oem_pk_hash_show(struct device *dev, } static DEVICE_ATTR_RO(oem_pk_hash); +static ssize_t ul_chan_id_show (struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct mhi_device *mhi_dev = to_mhi_device(dev); + int ul_chan_id = -1; + + if (mhi_dev->ul_chan) + ul_chan_id = mhi_dev->ul_chan_id; +drivers/bus/mhi/core/init.c static ssize_t oem_pk_hash_show(struct device · line 127
Quoted 10 lines
drivers/bus/mhi/core/init.c +4
-0+ return snprintf(buf, PAGE_SIZE, "%d\n", ul_chan_id); } static +DEVICE_ATTR_RO (ul_chan_id); + static struct attribute *mhi_dev_attrs[] = { &dev_attr_serial_number.attr, &dev_attr_oem_pk_hash.attr, + &dev_attr_ul_chan_id.attr, NULL, }; ATTRIBUTE_GROUPS(mhi_dev);NACK
Quoted 7 lines
Quoted 3 lines
Channel ID is a device specific detail. Userspace should be basing decisions on the channel name.
I agree with Jeff, why do you need to know the channel id, if you need to poll for any device node to get created you can try to open the device node from user space and wait until the device gets opened.
Are you trying to wait for EDL channels to get started using UCI ?
[carl.yin] In my opinion, mhi chan id is something like 'bInterfaceNumber' of USB device. A USB device and several USB interfaces, and a mhi devices have 128 mhi chans. Chan id is a physical attribute of one mhi chan.
Next is the udev info of one mhi chan:
# udevadm info -a /dev/mhi_0000\:03\:00.0_EDL
looking at parent device '/devices/pci0000:00/0000:00:1d.0/0000:03:00.0/0000:03:00.0_EDL':
KERNELS=="0000:03:00.0_EDL"
SUBSYSTEMS=="mhi"
DRIVERS=="mhi_uci"
ATTRS{serial_number}=="Serial Number: 2644481182"
ATTRS{ul_chan_id}=="34"If no ul_chan_id, the udev ruler will be ' KERNEL=="*_EDL" ' With ul_chan_id, the udev ruler will be ' ATTRS{ul_chan_id}=="34"' I think the latter is more better.
Quoted 6 lines
Thanks,
Hemant
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 96 lines · Carl Yin(殷张成)
Hi Jeffery and Hemant:
Quoted 73 lines · hemantk
On 10/27/20 8:06 AM, Jeffrey Hugo wrote:
Hi Carl,Quoted 69 lines · Jeffrey Hugo
Quoted 55 lines · On 10/27/2020 3:43 AM, [email protected] wrote:
From: "carl.yin" <[email protected]>
User space software like ModemManager can identify the function of the mhi chan device by
ul_chan_id.Signed-off-by carl.yin <[email protected]>--- Documentation/ABI/stable/sysfs-bus-mhi | 10 ++++++++++ drivers/bus/mhi/core/init.c | 15 +++++++++++++++ 2 files changed, 25 insertions(+)Documentation/ABI/stable/sysfs-bus-mhi +0
-0@@ -19,3 +19,13 @@ Description: The file holds the OEM PK Hashvalue of the endpoint device
read without having the device power on at least once, the
file
will read all 0's.
Users: Any userspace application or clients interested in
device info.Documentation/ABI/stable/sysfs-bus-mhi +6
-0+ +What: /sys/bus/mhi/devices/.../ul_chan_id +Date: November 2020 +KernelVersion: 5.10 +Contact: Carl Yin <[email protected]> +Description: The file holds the uplink chan id of the mhi chandevice.
+ User space software like ModemManager can identify the function of
+ the mhi chan device. If the mhi device is not a chan device, + eg mhi controller device, the file read -1. +Users: Any userspace application or clients interested in device info.(quoted diff) +0
-0
b/drivers/bus/mhi/core/init.cindex c6b43e9..ac4aa5c 100644drivers/bus/mhi/core/init.c +10
-0@@ -105,9 +105,24 @@ static ssize_t oem_pk_hash_show(struct device *dev, } static DEVICE_ATTR_RO(oem_pk_hash); +static ssize_t ul_chan_id_show (struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct mhi_device *mhi_dev = to_mhi_device(dev); + int ul_chan_id = -1; + + if (mhi_dev->ul_chan) + ul_chan_id = mhi_dev->ul_chan_id; +drivers/bus/mhi/core/init.c static ssize_t oem_pk_hash_show(struct device · line 127
Quoted 10 lines
drivers/bus/mhi/core/init.c +4
-0+ return snprintf(buf, PAGE_SIZE, "%d\n", ul_chan_id); } static +DEVICE_ATTR_RO (ul_chan_id); + static struct attribute *mhi_dev_attrs[] = { &dev_attr_serial_number.attr, &dev_attr_oem_pk_hash.attr, + &dev_attr_ul_chan_id.attr, NULL, }; ATTRIBUTE_GROUPS(mhi_dev);NACK
Quoted 7 lines
Quoted 3 lines
Channel ID is a device specific detail. Userspace should be basing decisions on the channel name.
I agree with Jeff, why do you need to know the channel id, if you need to poll for any device node to get created you can try to open the device node from user space and wait until the device gets opened.
Are you trying to wait for EDL channels to get started using UCI ?[carl.yin] In my opinion, mhi chan id is something like 'bInterfaceNumber' of USB device. A USB device and several USB interfaces, and a mhi devices have 128 mhi chans. Chan id is a physical attribute of one mhi chan.
Next is the udev info of one mhi chan:
# udevadm info -a /dev/mhi_0000\:03\:00.0_EDL looking at parent device '/devices/pci0000:00/0000:00:1d.0/0000:03:00.0/0000:03:00.0_EDL': KERNELS=="0000:03:00.0_EDL" SUBSYSTEMS=="mhi" DRIVERS=="mhi_uci" ATTRS{serial_number}=="Serial Number: 2644481182" ATTRS{ul_chan_id}=="34"
Quoted 1 line
If no
ul_chan_id, the udev ruler will be ' KERNEL=="*_EDL" '
I have several usecases where this works just fine today.
Quoted 1 line
With
ul_chan_id, the udev ruler will be ' ATTRS{ul_chan_id}=="34"'
This breaks when there is some new device that has the EDL channel on some different chan_id, like 7. The above does not. Additionally if there is a different device that is using chan_id 34 for a different purpose, say Diag, then your udev rule also breaks.
The name of the channel is the interface to the channel. Not the chan_id. This holds true within the kernel, and should be the same for userspace. I still oppose this change.
Signature · 3 lines
Jeffrey Hugo Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Hi Jeffrey:
Quoted 107 lines · jhugo
Quoted 77 lines · Carl Yin(殷张成)
Hi Jeffery and Hemant:
Quoted 74 lines · hemantk
On 10/27/20 8:06 AM, Jeffrey Hugo wrote:
Hi Carl,Quoted 70 lines · Jeffrey Hugo
Quoted 56 lines · On 10/27/2020 3:43 AM, [email protected] wrote:
From: "carl.yin" <[email protected]>
User space software like ModemManager can identify the function of the mhi chan device by
ul_chan_id.Signed-off-by carl.yin <[email protected]>--- Documentation/ABI/stable/sysfs-bus-mhi | 10 ++++++++++ drivers/bus/mhi/core/init.c | 15 +++++++++++++++ 2 files changed, 25 insertions(+)Documentation/ABI/stable/sysfs-bus-mhi +0
-0@@ -19,3 +19,13 @@ Description: The file holds the OEM PK Hashvalue of the endpoint device
read without having the device power on at least once,
the file
will read all 0's.
Users: Any userspace application or clients interested in
device info.Documentation/ABI/stable/sysfs-bus-mhi +6
-0+ +What: /sys/bus/mhi/devices/.../ul_chan_id +Date: November 2020 +KernelVersion: 5.10 +Contact: Carl Yin <[email protected]> +Description: The file holds the uplink chan id of the mhi chandevice.
+ User space software like ModemManager can identify the function of
+ the mhi chan device. If the mhi device is not a chanDocumentation/ABI/stable/sysfs-bus-mhi +3
-0+device, + eg mhi controller device, the file read -1. +Users: Any userspace application or clients interested indevice info.
(quoted diff) +0
-0
b/drivers/bus/mhi/core/init.cindex c6b43e9..ac4aa5c 100644drivers/bus/mhi/core/init.c +10
-0@@ -105,9 +105,24 @@ static ssize_t oem_pk_hash_show(struct device *dev, } static DEVICE_ATTR_RO(oem_pk_hash); +static ssize_t ul_chan_id_show (struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct mhi_device *mhi_dev = to_mhi_device(dev); + int ul_chan_id = -1; + + if (mhi_dev->ul_chan) + ul_chan_id = mhi_dev->ul_chan_id; +drivers/bus/mhi/core/init.c static ssize_t oem_pk_hash_show(struct device · line 127
Quoted 10 lines
drivers/bus/mhi/core/init.c +4
-0+ return snprintf(buf, PAGE_SIZE, "%d\n", ul_chan_id); } static +DEVICE_ATTR_RO (ul_chan_id); + static struct attribute *mhi_dev_attrs[] = { &dev_attr_serial_number.attr, &dev_attr_oem_pk_hash.attr, + &dev_attr_ul_chan_id.attr, NULL, }; ATTRIBUTE_GROUPS(mhi_dev);NACK
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
Channel ID is a device specific detail. Userspace should be basing decisions on the channel name.
I agree with Jeff, why do you need to know the channel id, if you need to poll for any device node to get created you can try to open the device node from user space and wait until the device gets opened. Are you trying to wait for EDL channels to get started using UCI ?
[carl.yin] In my opinion, mhi chan id is something like 'bInterfaceNumber' of
USB device.
Quoted 1 line
A USB device and several USB interfaces, and a mhi devices have 128 mhi
chans.
Quoted 5 lines
Chan id is a physical attribute of one mhi chan.
Next is the udev info of one mhi chan:
# udevadm info -a /dev/mhi_0000\:03\:00.0_EDL looking at parent device'/devices/pci0000:00/0000:00:1d.0/0000:03:00.0/0000:03:00.0_EDL':
Quoted 7 lines
KERNELS=="0000:03:00.0_EDL" SUBSYSTEMS=="mhi" DRIVERS=="mhi_uci" ATTRS{serial_number}=="Serial Number: 2644481182" ATTRS{ul_chan_id}=="34"If no
ul_chan_id, the udev ruler will be ' KERNEL=="*_EDL" 'I have several usecases where this works just fine today.
Quoted 1 line
With
ul_chan_id, the udev ruler will be ' ATTRS{ul_chan_id}=="34"'
Quoted 8 lines
This breaks when there is some new device that has the EDL channel on some different
chan_id, like 7. The above does not. Additionally if there is a different device that is usingchan_id34 for a different purpose, say Diag, then your udev rule also breaks.The name of the channel is the interface to the channel. Not the
chan_id. This holds true within the kernel, and should be the same for userspace. I still oppose this change.
[carl.yin] ok, I agree that chan id is not a good and necessary choice.
ModemManager also work well with ' KERNEL=="mhi_*_<chan name>"'.
Quoted 5 lines
--
Jeffrey Hugo
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.