Accepting request 244363 from home:trenn:branches:Base:System

- Add mainline commit: 51b8cdb0b60df3baa
  With this patch, the info can be showed correctly if there are two or more
  PCI root ports in the same Bus ID/Device ID (bnc#890562)
  Add: fix_several_PCI_root_ports_in_one_bus.patch

OBS-URL: https://build.opensuse.org/request/show/244363
OBS-URL: https://build.opensuse.org/package/show/Base:System/biosdevname?expand=0&rev=35
This commit is contained in:
Thomas Renninger 2014-08-12 16:07:18 +00:00 committed by Git OBS Bridge
parent 80108a409f
commit 6ff43063e2
3 changed files with 154 additions and 0 deletions

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Tue Aug 12 16:03:10 UTC 2014 - trenn@suse.de
- Add mainline commit: 51b8cdb0b60df3baa
With this patch, the info can be showed correctly if there are two or more
PCI root ports in the same Bus ID/Device ID (bnc#890562)
Add: fix_several_PCI_root_ports_in_one_bus.patch
-------------------------------------------------------------------
Fri Jun 13 17:01:24 UTC 2014 - trenn@suse.de

View File

@ -16,6 +16,7 @@
#
Name: biosdevname
Version: 0.5.0
Release: 0
@ -34,6 +35,7 @@ Patch2: ignore-broken-BIOSes
Patch3: whitelist-dell
Patch4: udev-rule-path.patch
Patch5: biosdevname_udevrule_rename_all_network_devices.patch
Patch6: fix_several_PCI_root_ports_in_one_bus.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: automake
BuildRequires: pciutils-devel
@ -65,6 +67,7 @@ You can enable/disable usage of biosdevname with boot option
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%build
# this is a udev rule, so it needs to live in / rather than /usr

View File

@ -0,0 +1,143 @@
From: Jordan Hargrave <Jordan_Hargrave@dell.com>
Subject: From Adrian Huang
References: bnc#890562
Patch-Mainline: yes
Git-commit: 51b8cdb0b60df3baa1be4ea3d8c303b0198465d3
Git-repo: linux.dell.com/biosdevname.git
Signed-off-by: Thomas Renninger <trenn@suse.de>
The command "biosdevname -d" shows the field "SMBIOS Lable" with "MEZZ2" for
all network interfaces when there are two or more PCI root ports in the same
Bus ID/Device ID.
With this patch, the info can be showed correctly if there are two or more PCI
root ports in the same Bus ID/Device ID. For example, the field of the
"p4p1" and "p4p2" would be showed as "MEZZ1".
This patch is based on v0.5.1.
Signed-off-by: Adrian Huang <ahuang12@lenovo.com>
diff --git a/src/dmidecode/dmidecode.c b/src/dmidecode/dmidecode.c
index f766b8c..4acac01 100644
--- a/src/dmidecode/dmidecode.c
+++ b/src/dmidecode/dmidecode.c
@@ -48,6 +48,27 @@ extern int smver_mjr, smver_mnr, is_valid_smbios;
#define dprintf(a...)
#endif
+struct dmi_type9
+{
+ u8 hdrtype;
+ u8 hdrlength;
+ u16 hdrhandle;
+
+ u8 ref;
+ u8 type;
+ u8 buswidth;
+ u8 usage;
+ u8 length;
+ u16 id;
+ u8 flags1;
+ /* 2.1+ */
+ u8 flags2;
+ /* 2.6+ */
+ u16 segment;
+ u8 bus;
+ u8 devfn;
+} __attribute__((packed));
+
static const char *bad_index = "<BAD INDEX>";
/*
@@ -116,8 +137,7 @@ int smbios_setslot(const struct libbiosdevname_state *state,
int domain, int bus, int device, int func,
int type, int slot, int index, const char *label)
{
- struct pci_device *pdev, *n;
- int i;
+ struct pci_device *pdev;
dprintf("setslot: %.4x:%.2x:%.2x.%x = type:%x slot(%2d %2d) %s\n",
domain, bus, device, func, type, slot, index, label);
@@ -128,7 +148,7 @@ int smbios_setslot(const struct libbiosdevname_state *state,
(bus == 0xFF && device == 0x1F && func == 0x7))
{
dprintf(" disabled\n");
- return;
+ return -1;
}
list_for_each_entry(pdev, &state->pci_devices, node) {
@@ -164,7 +184,8 @@ int smbios_setslot(const struct libbiosdevname_state *state,
static void dmi_decode(struct dmi_header *h, u16 ver, const struct libbiosdevname_state *state)
{
u8 *data=h->data;
- int domain, bus, device, function, i;
+
+ int domain, bus, device, function;
switch(h->type)
{
case 9: /* 3.3.10 System Slots */
@@ -173,7 +194,11 @@ static void dmi_decode(struct dmi_header *h, u16 ver, const struct libbiosdevnam
bus = data[0x0F];
device = (data[0x10]>>3)&0x1F;
function = data[0x10] & 7;
- smbios_setslot(state, domain, bus, device, -1,
+
+ /* Root ports can be on multiport device.. scan single */
+ if (!is_root_port(state, domain, bus, device, function))
+ function = -1;
+ smbios_setslot(state, domain, bus, device, function,
0x00, WORD(data+0x09), 0x00,
dmi_string(h, data[0x04]));
}
diff --git a/src/pci.c b/src/pci.c
index 7a7cb36..168cd59 100644
--- a/src/pci.c
+++ b/src/pci.c
@@ -876,3 +876,31 @@ struct pci_device * find_dev_by_pci_name(const struct libbiosdevname_state *stat
return find_pci_dev_by_pci_addr(state, domain, bus, device, func);
}
+
+int is_root_port(const struct libbiosdevname_state *state,
+ int domain, int bus, int device, int func)
+{
+ struct pci_device *pdev;
+ int pos;
+ u16 flag;
+
+ pdev = find_pci_dev_by_pci_addr(state, domain, bus, device, func);
+
+ if (!pdev || !pdev->pci_dev)
+ return 0;
+
+ pos = pci_find_capability(pdev->pci_dev, PCI_CAP_ID_EXP);
+ if (pos != 0) {
+ u8 type;
+
+ flag = pci_read_word(pdev->pci_dev, pos + PCI_EXP_FLAGS);
+
+ type = (flag & PCI_EXP_FLAGS_TYPE) >> 4;
+
+ if (type == PCI_EXP_TYPE_ROOT_PORT)
+ return 1;
+ }
+
+ return 0;
+}
+
diff --git a/src/pci.h b/src/pci.h
index eacb539..ab2eb64 100644
--- a/src/pci.h
+++ b/src/pci.h
@@ -102,5 +102,7 @@ static inline int pci_domain_nr(const struct pci_dev *dev)
}
#endif
+int is_root_port(const struct libbiosdevname_state *state,
+ int domain, int bus, int device, int func);
#endif /* PCI_H_INCLUDED */