* [PATCH] lspci: Show device name as exported by BIOS (sysfs label attribute)
@ 2014-01-27 21:00 Thomas Renninger
2014-01-28 7:51 ` [PATCH] lspci: Show device name as exported by BIOS (sysfs label attribute) (V2) Thomas Renninger
0 siblings, 1 reply; 7+ messages in thread
From: Thomas Renninger @ 2014-01-27 21:00 UTC (permalink / raw)
To: mj; +Cc: trenn, linux-pci
The Device name of a PCI or PCI Express device under OS may be exported via
ACPI _DSM function with function index 7.
The kernel already exports this string through sysfs under a PCI device through
the "label" sysfs attribute.
This patch reads the device name if available and shows it to the user.
Real world examples:
Device Name: "USB HS EHCI Controller #2 #3"
Device Name: "USB HS EHCI Controller #1"
Device Name: "SATA Controller #1"
Device Name: "Onboard LAN #1"
Device Name: "Onboard LAN #2"
Device Name: "Onboard Video (PILOT-3)"
Compare with PCI Firmware Spec v3.1 chapter 4.6.7 and
ACPI spec v5.0 chapter 9.14.1
The DeviceName is not shown by default, but starting from first verbose
parameter (-v).
Signed-off-by: Thomas Renninger <trenn@suse.de>
CC: linux-pci@vger.kernel.org
---
lib/pci.h | 1 +
lib/sysfs.c | 4 ++++
lspci.c | 2 ++
3 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/lib/pci.h b/lib/pci.h
index 38e2e99..f31419d 100644
--- a/lib/pci.h
+++ b/lib/pci.h
@@ -131,6 +131,7 @@ struct pci_dev {
struct pci_cap *first_cap; /* List of capabilities */
char *phy_slot; /* Physical slot */
char *module_alias; /* Linux kernel module alias */
+ char *label; /* Device name as exported by BIOS */
/* Fields used internally: */
struct pci_access *access;
diff --git a/lib/sysfs.c b/lib/sysfs.c
index 5a48c0d..3a8a34f 100644
--- a/lib/sysfs.c
+++ b/lib/sysfs.c
@@ -199,6 +199,10 @@ static void sysfs_scan(struct pci_access *a)
d->vendor_id = sysfs_get_value(d, "vendor");
d->device_id = sysfs_get_value(d, "device");
d->device_class = sysfs_get_value(d, "class") >> 8;
+ char buf[1024];
+ if (sysfs_get_string(d, "label", buf, 0))
+ d->label = pci_strdup(d->access, buf);
+
d->known_fields = PCI_FILL_IDENT | PCI_FILL_CLASS | PCI_FILL_IRQ | PCI_FILL_BASES | PCI_FILL_ROM_BASE | PCI_FILL_SIZES;
}
pci_link_dev(a, d);
diff --git a/lspci.c b/lspci.c
index dbba678..eb17af5 100644
--- a/lspci.c
+++ b/lspci.c
@@ -315,6 +315,8 @@ show_terse(struct device *d)
word subsys_v, subsys_d;
char ssnamebuf[256];
+ if (p->label)
+ printf("\tDeviceName: %s", p->label);
get_subid(d, &subsys_v, &subsys_d);
if (subsys_v && subsys_v != 0xffff)
printf("\tSubsystem: %s\n",
--
1.7.6.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] lspci: Show device name as exported by BIOS (sysfs label attribute) (V2)
2014-01-27 21:00 [PATCH] lspci: Show device name as exported by BIOS (sysfs label attribute) Thomas Renninger
@ 2014-01-28 7:51 ` Thomas Renninger
2014-11-01 15:22 ` Martin Mares
0 siblings, 1 reply; 7+ messages in thread
From: Thomas Renninger @ 2014-01-28 7:51 UTC (permalink / raw)
To: mj; +Cc: trenn, linux-pci
The Device name of a PCI or PCI Express device under OS may be exported via
ACPI _DSM function with function index 7.
This allows to connect a described PCI device in the platform documentation
or as labeled on the chassis with PCI devices shown via lspci.
The kernel already exports this string through sysfs under a PCI device through
the "label" sysfs attribute.
This patch reads the device name if available and shows it to the user.
Real world examples:
Device Name: "USB HS EHCI Controller #2 #3"
Device Name: "USB HS EHCI Controller #1"
Device Name: "SATA Controller #1"
Device Name: "Onboard LAN #1"
Device Name: "Onboard LAN #2"
Device Name: "Onboard Video (PILOT-3)"
Compare with PCI Firmware Spec v3.1 chapter 4.6.7 and
ACPI spec v5.0 chapter 9.14.1
The DeviceName is not shown by default, but starting from first verbose
parameter (-v).
V2: - Free label string if allocated
- Enhance changelog
Signed-off-by: Thomas Renninger <trenn@suse.de>
CC: linux-pci@vger.kernel.org
---
lib/access.c | 1 +
lib/pci.h | 1 +
lib/sysfs.c | 4 ++++
lspci.c | 2 ++
4 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/lib/access.c b/lib/access.c
index 5112504..c23a2fd 100644
--- a/lib/access.c
+++ b/lib/access.c
@@ -60,6 +60,7 @@ void pci_free_dev(struct pci_dev *d)
d->methods->cleanup_dev(d);
pci_free_caps(d);
pci_mfree(d->module_alias);
+ pci_mfree(d->label);
pci_mfree(d->phy_slot);
pci_mfree(d);
}
diff --git a/lib/pci.h b/lib/pci.h
index 38e2e99..f31419d 100644
--- a/lib/pci.h
+++ b/lib/pci.h
@@ -131,6 +131,7 @@ struct pci_dev {
struct pci_cap *first_cap; /* List of capabilities */
char *phy_slot; /* Physical slot */
char *module_alias; /* Linux kernel module alias */
+ char *label; /* Device name as exported by BIOS */
/* Fields used internally: */
struct pci_access *access;
diff --git a/lib/sysfs.c b/lib/sysfs.c
index 5a48c0d..3a8a34f 100644
--- a/lib/sysfs.c
+++ b/lib/sysfs.c
@@ -199,6 +199,10 @@ static void sysfs_scan(struct pci_access *a)
d->vendor_id = sysfs_get_value(d, "vendor");
d->device_id = sysfs_get_value(d, "device");
d->device_class = sysfs_get_value(d, "class") >> 8;
+ char buf[1024];
+ if (sysfs_get_string(d, "label", buf, 0))
+ d->label = pci_strdup(d->access, buf);
+
d->known_fields = PCI_FILL_IDENT | PCI_FILL_CLASS | PCI_FILL_IRQ | PCI_FILL_BASES | PCI_FILL_ROM_BASE | PCI_FILL_SIZES;
}
pci_link_dev(a, d);
diff --git a/lspci.c b/lspci.c
index dbba678..eb17af5 100644
--- a/lspci.c
+++ b/lspci.c
@@ -315,6 +315,8 @@ show_terse(struct device *d)
word subsys_v, subsys_d;
char ssnamebuf[256];
+ if (p->label)
+ printf("\tDeviceName: %s", p->label);
get_subid(d, &subsys_v, &subsys_d);
if (subsys_v && subsys_v != 0xffff)
printf("\tSubsystem: %s\n",
--
1.7.6.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] lspci: Show device name as exported by BIOS (sysfs label attribute) (V2)
2014-01-28 7:51 ` [PATCH] lspci: Show device name as exported by BIOS (sysfs label attribute) (V2) Thomas Renninger
@ 2014-11-01 15:22 ` Martin Mares
2014-11-01 16:16 ` Martin Mares
0 siblings, 1 reply; 7+ messages in thread
From: Martin Mares @ 2014-11-01 15:22 UTC (permalink / raw)
To: Thomas Renninger; +Cc: linux-pci
Hi!
> The Device name of a PCI or PCI Express device under OS may be exported via
> ACPI _DSM function with function index 7.
> This allows to connect a described PCI device in the platform documentation
> or as labeled on the chassis with PCI devices shown via lspci.
> The kernel already exports this string through sysfs under a PCI device through
> the "label" sysfs attribute.
Thanks, applied. (With minor changes, like using OBJBUFSIZE instead of
a hard-coded constant 1024.)
Have a nice fortnight
--
Martin `MJ' Mares <mj@ucw.cz> http://mj.ucw.cz/
Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth
Got mole problems? Call Avogadro, 602-1023!
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] lspci: Show device name as exported by BIOS (sysfs label attribute) (V2)
2014-11-01 15:22 ` Martin Mares
@ 2014-11-01 16:16 ` Martin Mares
2014-11-13 15:23 ` Thomas Renninger
0 siblings, 1 reply; 7+ messages in thread
From: Martin Mares @ 2014-11-01 16:16 UTC (permalink / raw)
To: Thomas Renninger; +Cc: linux-pci
> Thanks, applied. (With minor changes, like using OBJBUFSIZE instead of
> a hard-coded constant 1024.)
... I realized that your way of reading the label attribute was
completely different from reading of most other device attributes.
I changed it, now it read only on request by pci_fill_info() with the
PCI_FILL_LABEL flag.
Could you please check that the version in pciutils.git still works
for you?
Have a nice fortnight
--
Martin `MJ' Mares <mj@ucw.cz> http://mj.ucw.cz/
Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth
A jury consists of 12 persons chosen to decide who has the better lawyer.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] lspci: Show device name as exported by BIOS (sysfs label attribute) (V2)
2014-11-01 16:16 ` Martin Mares
@ 2014-11-13 15:23 ` Thomas Renninger
2014-11-14 21:34 ` Martin Mares
0 siblings, 1 reply; 7+ messages in thread
From: Thomas Renninger @ 2014-11-13 15:23 UTC (permalink / raw)
To: Martin Mares; +Cc: linux-pci
Hi,
and sorry for the late reply.
On Saturday, November 01, 2014 05:16:08 PM Martin Mares wrote:
> > Thanks, applied. (With minor changes, like using OBJBUFSIZE instead of
> > a hard-coded constant 1024.)
>
> ... I realized that your way of reading the label attribute was
> completely different from reading of most other device attributes.
>
> I changed it, now it read only on request by pci_fill_info() with the
> PCI_FILL_LABEL flag.
>
> Could you please check that the version in pciutils.git still works
> for you?
I tried with latest 3.3.0 version and things work as expected:
lspci -v |grep DeviceName:
DeviceName: USB HS EHCI Controller #2 #3
DeviceName: USB HS EHCI Controller #1
DeviceName: SATA Controller #1
DeviceName: Onboard LAN #1
DeviceName: Onboard LAN #2
DeviceName: Onboard Video (PILOT-3)
Thanks a lot!
Hm, while using the latest 3.3.0 tarball with our pciutils dist
package I realized that this diff does not perfectly patch
anymore.
Unfortunately without author, looks like a gcc guy added it.
I paste it in the end
You may want to incorporate (a shortened version?) it if appropriate.
Be careful, needs patch -p0
Thomas
Dear kernel developers. we plead to you, please use documented,optimized userspace interfaces, thanks !
--- lib/sysdep.h.orig
+++ lib/sysdep.h
@@ -18,71 +18,10 @@
typedef u8 byte;
typedef u16 word;
-#ifdef PCI_OS_WINDOWS
-#define strcasecmp strcmpi
-#endif
-
-#ifdef PCI_HAVE_LINUX_BYTEORDER_H
-
-#include <asm/byteorder.h>
-#define cpu_to_le16 __cpu_to_le16
-#define cpu_to_le32 __cpu_to_le32
-#define le16_to_cpu __le16_to_cpu
-#define le32_to_cpu __le32_to_cpu
-
-#else
-
-#ifdef PCI_OS_LINUX
#include <endian.h>
-#define BYTE_ORDER __BYTE_ORDER
-#define BIG_ENDIAN __BIG_ENDIAN
-#endif
-
-#ifdef PCI_OS_SUNOS
-#include <sys/byteorder.h>
-#define BIG_ENDIAN 4321
-#ifdef _LITTLE_ENDIAN
-#define BYTE_ORDER 1234
-#else
-#define BYTE_ORDER 4321
-#endif
-#endif
-
-#ifdef PCI_OS_WINDOWS
-#ifdef __MINGW32__
- #include <sys/param.h>
-#else
- #include <io.h>
- #define BIG_ENDIAN 4321
- #define LITTLE_ENDIAN 1234
- #define BYTE_ORDER LITTLE_ENDIAN
- #define snprintf _snprintf
-#endif
-#endif
-
-#if BYTE_ORDER == BIG_ENDIAN
-#define cpu_to_le16 swab16
-#define cpu_to_le32 swab32
-#define le16_to_cpu swab16
-#define le32_to_cpu swab32
-
-static inline word swab16(word w)
-{
- return (w << 8) | ((w >> 8) & 0xff);
-}
-static inline u32 swab32(u32 w)
-{
- return ((w & 0xff000000) >> 24) |
- ((w & 0x00ff0000) >> 8) |
- ((w & 0x0000ff00) << 8) |
- ((w & 0x000000ff) << 24);
-}
-#else
-#define cpu_to_le16(x) (x)
-#define cpu_to_le32(x) (x)
-#define le16_to_cpu(x) (x)
-#define le32_to_cpu(x) (x)
-#endif
+#define cpu_to_le16 htole16
+#define cpu_to_le32 htole32
+#define le16_to_cpu le16toh
+#define le32_to_cpu le32toh
-#endif
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] lspci: Show device name as exported by BIOS (sysfs label attribute) (V2)
2014-11-13 15:23 ` Thomas Renninger
@ 2014-11-14 21:34 ` Martin Mares
2014-11-16 10:05 ` Thomas Renninger
0 siblings, 1 reply; 7+ messages in thread
From: Martin Mares @ 2014-11-14 21:34 UTC (permalink / raw)
To: Thomas Renninger; +Cc: linux-pci
Hi!
> Hm, while using the latest 3.3.0 tarball with our pciutils dist
> package I realized that this diff does not perfectly patch
> anymore.
>
> Unfortunately without author, looks like a gcc guy added it.
> I paste it in the end
> You may want to incorporate (a shortened version?) it if appropriate.
No, I don't want :-) While it simplifies the code on Linux, it breaks
many other platforms.
Have a nice fortnight
--
Martin `MJ' Mares <mj@ucw.cz> http://mj.ucw.cz/
Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth
Why is it called "common sense" when nobody seems to have any?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] lspci: Show device name as exported by BIOS (sysfs label attribute) (V2)
2014-11-14 21:34 ` Martin Mares
@ 2014-11-16 10:05 ` Thomas Renninger
0 siblings, 0 replies; 7+ messages in thread
From: Thomas Renninger @ 2014-11-16 10:05 UTC (permalink / raw)
To: Martin Mares; +Cc: linux-pci
On Friday, November 14, 2014 10:34:39 PM Martin Mares wrote:
> Hi!
>
> > Hm, while using the latest 3.3.0 tarball with our pciutils dist
> > package I realized that this diff does not perfectly patch
> > anymore.
> >
> > Unfortunately without author, looks like a gcc guy added it.
> > I paste it in the end
> > You may want to incorporate (a shortened version?) it if appropriate.
>
> No, I don't want :-) While it simplifies the code on Linux, it breaks
> many other platforms.
Of course not the whole patch.
The OS specific stuff must stay.
It is about (be careful, copy and pasted) these
which seem to be a nice code reduction:
-#if BYTE_ORDER == BIG_ENDIAN
-#define cpu_to_le16 swab16
-#define cpu_to_le32 swab32
-#define le16_to_cpu swab16
-#define le32_to_cpu swab32
-
-static inline word swab16(word w)
-{
- return (w << 8) | ((w >> 8) & 0xff);
-}
-static inline u32 swab32(u32 w)
-{
- return ((w & 0xff000000) >> 24) |
- ((w & 0x00ff0000) >> 8) |
- ((w & 0x0000ff00) << 8) |
- ((w & 0x000000ff) << 24);
-}
-#else
-#define cpu_to_le16(x) (x)
-#define cpu_to_le32(x) (x)
-#define le16_to_cpu(x) (x)
-#define le32_to_cpu(x) (x)
-#endif
+#define cpu_to_le16 htole16
+#define cpu_to_le32 htole32
+#define le16_to_cpu le16toh
+#define le32_to_cpu le32toh
Thomas
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-11-16 10:05 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-27 21:00 [PATCH] lspci: Show device name as exported by BIOS (sysfs label attribute) Thomas Renninger
2014-01-28 7:51 ` [PATCH] lspci: Show device name as exported by BIOS (sysfs label attribute) (V2) Thomas Renninger
2014-11-01 15:22 ` Martin Mares
2014-11-01 16:16 ` Martin Mares
2014-11-13 15:23 ` Thomas Renninger
2014-11-14 21:34 ` Martin Mares
2014-11-16 10:05 ` Thomas Renninger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).