* [PATCH v4 0/2] pci/lspci: Identify Enhanced Allocation (EA) Resources
@ 2016-02-12 0:52 Sean O. Stalley
2016-02-12 0:52 ` [PATCH v4 1/2] pci: Identify Enhanced Allocation (EA) BAR Equivalent resources Sean O. Stalley
2016-02-12 0:52 ` [PATCH v4 2/2] Add support for enhanced allocation regions Sean O. Stalley
0 siblings, 2 replies; 7+ messages in thread
From: Sean O. Stalley @ 2016-02-12 0:52 UTC (permalink / raw)
To: linux-pci, mj, bhelgaas, alex.williamson; +Cc: sean.stalley, david.daney
Identify BAR-equivalent resources that are described by EA entries
with the IORESOURCE_PCI_EA_BEI flag.
lspci cannot distinguish between resources from VF BARs and resources from EA.
This results in EA Resources being incorrectly identified as [virtual].
Adding this flag allows EA resources to be marked more accurately as [enhanced].
Although this patchset only add support for this flag to lspci,
there are other use cases (such as vfio) where knowing a resource
comes from EA would be useful.
[PATCH 1/2] is for the kernel, [PATCH 2/2] is for lspci.
Changes from V1:
-Rewrote commit message for linux changes
Changes from V2:
- Rewrote commit message for linux, fixing spelling :)
- Added warning about resource flags being exposed in sysfs
Changes from V3 (only lspci changes):
- Incremented libpci API version number
- append new flag variables to the end of struct pci_dev (so we don't break binary compatiblity)
- expanded comment for the resource flags
- removed brackets around 1 line conditionals
Alex Williamson (1):
pci: Identify Enhanced Allocation (EA) BAR Equivalent resources
Sean O. Stalley (1):
Add support for enhanced allocation regions
linux changes:
drivers/pci/pci.c | 2 +-
include/linux/ioport.h | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
lspci changes:
lib/access.c | 18 ++++++++++--------
lib/caps.c | 2 +-
lib/filter.c | 2 +-
lib/header.h | 4 ++++
lib/libpci.ver | 5 +++++
lib/pci.h | 3 +++
lib/sysfs.c | 7 +++++--
lspci.c | 12 +++++++++---
8 files changed, 38 insertions(+), 15 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v4 1/2] pci: Identify Enhanced Allocation (EA) BAR Equivalent resources
2016-02-12 0:52 [PATCH v4 0/2] pci/lspci: Identify Enhanced Allocation (EA) Resources Sean O. Stalley
@ 2016-02-12 0:52 ` Sean O. Stalley
2016-05-16 20:31 ` Bjorn Helgaas
2016-02-12 0:52 ` [PATCH v4 2/2] Add support for enhanced allocation regions Sean O. Stalley
1 sibling, 1 reply; 7+ messages in thread
From: Sean O. Stalley @ 2016-02-12 0:52 UTC (permalink / raw)
To: linux-pci, mj, bhelgaas, alex.williamson; +Cc: sean.stalley, david.daney
From: Alex Williamson <alex.williamson@redhat.com>
Resource flags are exposed to userspace via the sysfs "resource" file.
lspci reads the sysfs file to determine resource properties.
Adding this flag allows lspci to distinguish between [virtual]
and [enhanced] resources.
If the resource is not aligned, userspace could deduce where
the resource is EA based on the size & address fields.
However, a flag indicating whether a PCI resource is a traditional BAR
or BAR equivalent seems like a much simpler solution and works if the
EA resource is aligned.
Although this patchset only improves lspci, other uses for this
flag have been identified. For example, vfio makes assumptions
about alignment and sizing, and runs into problems when attempting
to emulate a BAR Equivalent EA resource.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Sean O. Stalley <sean.stalley@intel.com>
---
drivers/pci/pci.c | 2 +-
include/linux/ioport.h | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index d1a7105..8ff678c 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -2229,7 +2229,7 @@ void pci_pm_init(struct pci_dev *dev)
static unsigned long pci_ea_flags(struct pci_dev *dev, u8 prop)
{
- unsigned long flags = IORESOURCE_PCI_FIXED;
+ unsigned long flags = IORESOURCE_PCI_FIXED | IORESOURCE_PCI_EA_BEI;
switch (prop) {
case PCI_EA_P_MEM:
diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index 24bea08..88816f9 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -25,7 +25,11 @@ struct resource {
/*
* IO resources have these defined flags.
+ *
+ * PCI devices expose these flags to userspace in the "resource" sysfs file,
+ * Moving them around could break stuff, so don't do it.
*/
+
#define IORESOURCE_BITS 0x000000ff /* Bus-specific bits */
#define IORESOURCE_TYPE_BITS 0x00001f00 /* Resource type */
@@ -97,6 +101,7 @@ struct resource {
#define IORESOURCE_IO_SPARSE (1<<2)
/* PCI ROM control bits (IORESOURCE_BITS) */
+
#define IORESOURCE_ROM_ENABLE (1<<0) /* ROM is enabled, same as PCI_ROM_ADDRESS_ENABLE */
#define IORESOURCE_ROM_SHADOW (1<<1) /* ROM is copy at C000:0 */
#define IORESOURCE_ROM_COPY (1<<2) /* ROM is alloc'd copy, resource field overlaid */
@@ -105,6 +110,8 @@ struct resource {
/* PCI control bits. Shares IORESOURCE_BITS with above PCI ROM. */
#define IORESOURCE_PCI_FIXED (1<<4) /* Do not move resource */
+/* PCI Enhanced Allocation defined BAR equivalent resource */
+#define IORESOURCE_PCI_EA_BEI (1<<5)
/* helpers to define resources */
#define DEFINE_RES_NAMED(_start, _size, _name, _flags) \
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v4 2/2] Add support for enhanced allocation regions
2016-02-12 0:52 [PATCH v4 0/2] pci/lspci: Identify Enhanced Allocation (EA) Resources Sean O. Stalley
2016-02-12 0:52 ` [PATCH v4 1/2] pci: Identify Enhanced Allocation (EA) BAR Equivalent resources Sean O. Stalley
@ 2016-02-12 0:52 ` Sean O. Stalley
2016-04-10 22:22 ` Bjorn Helgaas
1 sibling, 1 reply; 7+ messages in thread
From: Sean O. Stalley @ 2016-02-12 0:52 UTC (permalink / raw)
To: linux-pci, mj, bhelgaas, alex.williamson; +Cc: sean.stalley, david.daney
Append [enhanced] to Regions that contain the BEI flag in sysfs.
To do this, we need to add the resource flags to the pci_dev struct.
This struct is passed through the libpci API, so we increment the API version number.
Don't tuncate least significant bits of the region size.
ex: a 2000 byte region should display [size=2000] instead of [size=1K]
Signed-off-by: Sean O. Stalley <sean.stalley@intel.com>
---
lib/access.c | 18 ++++++++++--------
lib/caps.c | 2 +-
lib/filter.c | 2 +-
| 4 ++++
lib/libpci.ver | 5 +++++
lib/pci.h | 3 +++
lib/sysfs.c | 7 +++++--
lspci.c | 12 +++++++++---
8 files changed, 38 insertions(+), 15 deletions(-)
diff --git a/lib/access.c b/lib/access.c
index 5994008..17b8bed 100644
--- a/lib/access.c
+++ b/lib/access.c
@@ -155,7 +155,7 @@ pci_write_block(struct pci_dev *d, int pos, byte *buf, int len)
}
int
-pci_fill_info_v34(struct pci_dev *d, int flags)
+pci_fill_info_v35(struct pci_dev *d, int flags)
{
if (flags & PCI_FILL_RESCAN)
{
@@ -169,17 +169,19 @@ pci_fill_info_v34(struct pci_dev *d, int flags)
}
/* In version 3.1, pci_fill_info got new flags => versioned alias */
-/* In versions 3.2, 3.3 and 3.4, the same has happened */
-STATIC_ALIAS(int pci_fill_info(struct pci_dev *d, int flags), pci_fill_info_v34(d, flags));
-DEFINE_ALIAS(int pci_fill_info_v30(struct pci_dev *d, int flags), pci_fill_info_v34);
-DEFINE_ALIAS(int pci_fill_info_v31(struct pci_dev *d, int flags), pci_fill_info_v34);
-DEFINE_ALIAS(int pci_fill_info_v32(struct pci_dev *d, int flags), pci_fill_info_v34);
-DEFINE_ALIAS(int pci_fill_info_v33(struct pci_dev *d, int flags), pci_fill_info_v34);
+/* In versions 3.2, 3.3, 3.4 and 3.5, the same has happened */
+STATIC_ALIAS(int pci_fill_info(struct pci_dev *d, int flags), pci_fill_info_v35(d, flags));
+DEFINE_ALIAS(int pci_fill_info_v30(struct pci_dev *d, int flags), pci_fill_info_v35);
+DEFINE_ALIAS(int pci_fill_info_v31(struct pci_dev *d, int flags), pci_fill_info_v35);
+DEFINE_ALIAS(int pci_fill_info_v32(struct pci_dev *d, int flags), pci_fill_info_v35);
+DEFINE_ALIAS(int pci_fill_info_v33(struct pci_dev *d, int flags), pci_fill_info_v35);
+DEFINE_ALIAS(int pci_fill_info_v34(struct pci_dev *d, int flags), pci_fill_info_v35);
SYMBOL_VERSION(pci_fill_info_v30, pci_fill_info@LIBPCI_3.0);
SYMBOL_VERSION(pci_fill_info_v31, pci_fill_info@LIBPCI_3.1);
SYMBOL_VERSION(pci_fill_info_v32, pci_fill_info@LIBPCI_3.2);
SYMBOL_VERSION(pci_fill_info_v33, pci_fill_info@LIBPCI_3.3);
-SYMBOL_VERSION(pci_fill_info_v34, pci_fill_info@@LIBPCI_3.4);
+SYMBOL_VERSION(pci_fill_info_v34, pci_fill_info@LIBPCI_3.4);
+SYMBOL_VERSION(pci_fill_info_v35, pci_fill_info@@LIBPCI_3.5);
void
pci_setup_cache(struct pci_dev *d, byte *cache, int len)
diff --git a/lib/caps.c b/lib/caps.c
index a812fb9..9a2e0a5 100644
--- a/lib/caps.c
+++ b/lib/caps.c
@@ -106,7 +106,7 @@ pci_find_cap(struct pci_dev *d, unsigned int id, unsigned int type)
{
struct pci_cap *c;
- pci_fill_info_v34(d, ((type == PCI_CAP_NORMAL) ? PCI_FILL_CAPS : PCI_FILL_EXT_CAPS));
+ pci_fill_info_v35(d, ((type == PCI_CAP_NORMAL) ? PCI_FILL_CAPS : PCI_FILL_EXT_CAPS));
for (c=d->first_cap; c; c=c->next)
if (c->type == type && c->id == id)
return c;
diff --git a/lib/filter.c b/lib/filter.c
index d4254a0..ab1476f 100644
--- a/lib/filter.c
+++ b/lib/filter.c
@@ -129,7 +129,7 @@ pci_filter_match_v33(struct pci_filter *f, struct pci_dev *d)
return 0;
if (f->device >= 0 || f->vendor >= 0)
{
- pci_fill_info_v34(d, PCI_FILL_IDENT);
+ pci_fill_info_v35(d, PCI_FILL_IDENT);
if ((f->device >= 0 && f->device != d->device_id) ||
(f->vendor >= 0 && f->vendor != d->vendor_id))
return 0;
--git a/lib/header.h b/lib/header.h
index b8f7dc1..7b9a803 100644
--- a/lib/header.h
+++ b/lib/header.h
@@ -1235,3 +1235,7 @@
#define PCI_VENDOR_ID_INTEL 0x8086
#define PCI_VENDOR_ID_COMPAQ 0x0e11
+
+/* taken from <include/linux/ioport.h> */
+
+#define IORESOURCE_PCI_EA_BEI (1<<5)
diff --git a/lib/libpci.ver b/lib/libpci.ver
index 7ac8d34..83f3c50 100644
--- a/lib/libpci.ver
+++ b/lib/libpci.ver
@@ -66,3 +66,8 @@ LIBPCI_3.4 {
global:
pci_fill_info;
};
+
+LIBPCI_3.5 {
+ global:
+ pci_fill_info;
+};
diff --git a/lib/pci.h b/lib/pci.h
index 9c1e281..a86bfd7 100644
--- a/lib/pci.h
+++ b/lib/pci.h
@@ -136,6 +136,8 @@ struct pci_dev {
char *module_alias; /* Linux kernel module alias */
char *label; /* Device name as exported by BIOS */
int numa_node; /* NUMA node */
+ pciaddr_t flags[6]; /* Region IORESOURCE flags */
+ pciaddr_t rom_flags; /* Expansion ROM IORESOURCE flags */
/* Fields used internally: */
struct pci_access *access;
@@ -174,6 +176,7 @@ int pci_fill_info(struct pci_dev *, int flags) PCI_ABI; /* Fill in device inform
#define PCI_FILL_MODULE_ALIAS 0x0200
#define PCI_FILL_LABEL 0x0400
#define PCI_FILL_NUMA_NODE 0x0800
+#define PCI_FILL_IO_FLAGS 0x1000
#define PCI_FILL_RESCAN 0x00010000
void pci_setup_cache(struct pci_dev *, u8 *cache, int len) PCI_ABI;
diff --git a/lib/sysfs.c b/lib/sysfs.c
index 986ecc9..65f58bf 100644
--- a/lib/sysfs.c
+++ b/lib/sysfs.c
@@ -153,14 +153,17 @@ sysfs_get_resources(struct pci_dev *d)
size = end - start + 1;
else
size = 0;
- flags &= PCI_ADDR_FLAG_MASK;
if (i < 6)
{
+ d->flags[i] = flags;
+ flags &= PCI_ADDR_FLAG_MASK;
d->base_addr[i] = start | flags;
d->size[i] = size;
}
else
{
+ d->rom_flags = flags;
+ flags &= PCI_ADDR_FLAG_MASK;
d->rom_base_addr = start | flags;
d->rom_size = size;
}
@@ -208,7 +211,7 @@ static void sysfs_scan(struct pci_access *a)
d->vendor_id = sysfs_get_value(d, "vendor", 1);
d->device_id = sysfs_get_value(d, "device", 1);
d->device_class = sysfs_get_value(d, "class", 1) >> 8;
- d->known_fields = PCI_FILL_IDENT | PCI_FILL_CLASS | PCI_FILL_IRQ | PCI_FILL_BASES | PCI_FILL_ROM_BASE | PCI_FILL_SIZES;
+ d->known_fields = PCI_FILL_IDENT | PCI_FILL_CLASS | PCI_FILL_IRQ | PCI_FILL_BASES | PCI_FILL_ROM_BASE | PCI_FILL_SIZES | PCI_FILL_IO_FLAGS;
}
pci_link_dev(a, d);
}
diff --git a/lspci.c b/lspci.c
index fe7b7fe..52d14f3 100644
--- a/lspci.c
+++ b/lspci.c
@@ -336,7 +336,7 @@ show_size(pciaddr_t x)
if (!x)
return;
for (i = 0; i < (sizeof(suffix) / sizeof(*suffix) - 1); i++) {
- if (x < 1024)
+ if (x % 1024)
break;
x /= 1024;
}
@@ -355,6 +355,7 @@ show_bases(struct device *d, int cnt)
{
pciaddr_t pos = p->base_addr[i];
pciaddr_t len = (p->known_fields & PCI_FILL_SIZES) ? p->size[i] : 0;
+ pciaddr_t ioflg = (p->known_fields & PCI_FILL_IO_FLAGS) ? p->flags[i] : 0;
u32 flg = get_conf_long(d, PCI_BASE_ADDRESS_0 + 4*i);
if (flg == 0xffffffff)
flg = 0;
@@ -364,7 +365,9 @@ show_bases(struct device *d, int cnt)
printf("\tRegion %d: ", i);
else
putchar('\t');
- if (pos && !flg) /* Reported by the OS, but not by the device */
+ if (ioflg & IORESOURCE_PCI_EA_BEI)
+ printf("[enhanced] ");
+ else if (pos && !flg) /* Reported by the OS, but not by the device */
{
printf("[virtual] ");
flg = pos;
@@ -430,6 +433,7 @@ show_rom(struct device *d, int reg)
struct pci_dev *p = d->dev;
pciaddr_t rom = p->rom_base_addr;
pciaddr_t len = (p->known_fields & PCI_FILL_SIZES) ? p->rom_size : 0;
+ pciaddr_t ioflg = (p->known_fields & PCI_FILL_IO_FLAGS) ? p->rom_flags : 0;
u32 flg = get_conf_long(d, reg);
word cmd = get_conf_word(d, PCI_COMMAND);
int virtual = 0;
@@ -437,7 +441,9 @@ show_rom(struct device *d, int reg)
if (!rom && !flg && !len)
return;
putchar('\t');
- if ((rom & PCI_ROM_ADDRESS_MASK) && !(flg & PCI_ROM_ADDRESS_MASK))
+ if (ioflg & IORESOURCE_PCI_EA_BEI)
+ printf("[enhanced] ");
+ else if ((rom & PCI_ROM_ADDRESS_MASK) && !(flg & PCI_ROM_ADDRESS_MASK))
{
printf("[virtual] ");
flg = rom;
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v4 2/2] Add support for enhanced allocation regions
2016-02-12 0:52 ` [PATCH v4 2/2] Add support for enhanced allocation regions Sean O. Stalley
@ 2016-04-10 22:22 ` Bjorn Helgaas
2016-05-14 9:28 ` Martin Mares
0 siblings, 1 reply; 7+ messages in thread
From: Bjorn Helgaas @ 2016-04-10 22:22 UTC (permalink / raw)
To: Sean O. Stalley; +Cc: linux-pci, mj, bhelgaas, alex.williamson, david.daney
Hi Martin,
On Thu, Feb 11, 2016 at 04:52:25PM -0800, Sean O. Stalley wrote:
> Append [enhanced] to Regions that contain the BEI flag in sysfs.
> To do this, we need to add the resource flags to the pci_dev struct.
> This struct is passed through the libpci API, so we increment the API version number.
>
> Don't tuncate least significant bits of the region size.
s/tuncate/truncate/
> ex: a 2000 byte region should display [size=2000] instead of [size=1K]
What do you think of this? I don't object to the kernel PCI part of
it, but I don't want to apply it unless you plan to make lspci make
use of it.
Bjorn
> Signed-off-by: Sean O. Stalley <sean.stalley@intel.com>
> ---
> lib/access.c | 18 ++++++++++--------
> lib/caps.c | 2 +-
> lib/filter.c | 2 +-
> lib/header.h | 4 ++++
> lib/libpci.ver | 5 +++++
> lib/pci.h | 3 +++
> lib/sysfs.c | 7 +++++--
> lspci.c | 12 +++++++++---
> 8 files changed, 38 insertions(+), 15 deletions(-)
>
> diff --git a/lib/access.c b/lib/access.c
> index 5994008..17b8bed 100644
> --- a/lib/access.c
> +++ b/lib/access.c
> @@ -155,7 +155,7 @@ pci_write_block(struct pci_dev *d, int pos, byte *buf, int len)
> }
>
> int
> -pci_fill_info_v34(struct pci_dev *d, int flags)
> +pci_fill_info_v35(struct pci_dev *d, int flags)
> {
> if (flags & PCI_FILL_RESCAN)
> {
> @@ -169,17 +169,19 @@ pci_fill_info_v34(struct pci_dev *d, int flags)
> }
>
> /* In version 3.1, pci_fill_info got new flags => versioned alias */
> -/* In versions 3.2, 3.3 and 3.4, the same has happened */
> -STATIC_ALIAS(int pci_fill_info(struct pci_dev *d, int flags), pci_fill_info_v34(d, flags));
> -DEFINE_ALIAS(int pci_fill_info_v30(struct pci_dev *d, int flags), pci_fill_info_v34);
> -DEFINE_ALIAS(int pci_fill_info_v31(struct pci_dev *d, int flags), pci_fill_info_v34);
> -DEFINE_ALIAS(int pci_fill_info_v32(struct pci_dev *d, int flags), pci_fill_info_v34);
> -DEFINE_ALIAS(int pci_fill_info_v33(struct pci_dev *d, int flags), pci_fill_info_v34);
> +/* In versions 3.2, 3.3, 3.4 and 3.5, the same has happened */
> +STATIC_ALIAS(int pci_fill_info(struct pci_dev *d, int flags), pci_fill_info_v35(d, flags));
> +DEFINE_ALIAS(int pci_fill_info_v30(struct pci_dev *d, int flags), pci_fill_info_v35);
> +DEFINE_ALIAS(int pci_fill_info_v31(struct pci_dev *d, int flags), pci_fill_info_v35);
> +DEFINE_ALIAS(int pci_fill_info_v32(struct pci_dev *d, int flags), pci_fill_info_v35);
> +DEFINE_ALIAS(int pci_fill_info_v33(struct pci_dev *d, int flags), pci_fill_info_v35);
> +DEFINE_ALIAS(int pci_fill_info_v34(struct pci_dev *d, int flags), pci_fill_info_v35);
> SYMBOL_VERSION(pci_fill_info_v30, pci_fill_info@LIBPCI_3.0);
> SYMBOL_VERSION(pci_fill_info_v31, pci_fill_info@LIBPCI_3.1);
> SYMBOL_VERSION(pci_fill_info_v32, pci_fill_info@LIBPCI_3.2);
> SYMBOL_VERSION(pci_fill_info_v33, pci_fill_info@LIBPCI_3.3);
> -SYMBOL_VERSION(pci_fill_info_v34, pci_fill_info@@LIBPCI_3.4);
> +SYMBOL_VERSION(pci_fill_info_v34, pci_fill_info@LIBPCI_3.4);
> +SYMBOL_VERSION(pci_fill_info_v35, pci_fill_info@@LIBPCI_3.5);
>
> void
> pci_setup_cache(struct pci_dev *d, byte *cache, int len)
> diff --git a/lib/caps.c b/lib/caps.c
> index a812fb9..9a2e0a5 100644
> --- a/lib/caps.c
> +++ b/lib/caps.c
> @@ -106,7 +106,7 @@ pci_find_cap(struct pci_dev *d, unsigned int id, unsigned int type)
> {
> struct pci_cap *c;
>
> - pci_fill_info_v34(d, ((type == PCI_CAP_NORMAL) ? PCI_FILL_CAPS : PCI_FILL_EXT_CAPS));
> + pci_fill_info_v35(d, ((type == PCI_CAP_NORMAL) ? PCI_FILL_CAPS : PCI_FILL_EXT_CAPS));
> for (c=d->first_cap; c; c=c->next)
> if (c->type == type && c->id == id)
> return c;
> diff --git a/lib/filter.c b/lib/filter.c
> index d4254a0..ab1476f 100644
> --- a/lib/filter.c
> +++ b/lib/filter.c
> @@ -129,7 +129,7 @@ pci_filter_match_v33(struct pci_filter *f, struct pci_dev *d)
> return 0;
> if (f->device >= 0 || f->vendor >= 0)
> {
> - pci_fill_info_v34(d, PCI_FILL_IDENT);
> + pci_fill_info_v35(d, PCI_FILL_IDENT);
> if ((f->device >= 0 && f->device != d->device_id) ||
> (f->vendor >= 0 && f->vendor != d->vendor_id))
> return 0;
> diff --git a/lib/header.h b/lib/header.h
> index b8f7dc1..7b9a803 100644
> --- a/lib/header.h
> +++ b/lib/header.h
> @@ -1235,3 +1235,7 @@
>
> #define PCI_VENDOR_ID_INTEL 0x8086
> #define PCI_VENDOR_ID_COMPAQ 0x0e11
> +
> +/* taken from <include/linux/ioport.h> */
> +
> +#define IORESOURCE_PCI_EA_BEI (1<<5)
> diff --git a/lib/libpci.ver b/lib/libpci.ver
> index 7ac8d34..83f3c50 100644
> --- a/lib/libpci.ver
> +++ b/lib/libpci.ver
> @@ -66,3 +66,8 @@ LIBPCI_3.4 {
> global:
> pci_fill_info;
> };
> +
> +LIBPCI_3.5 {
> + global:
> + pci_fill_info;
> +};
> diff --git a/lib/pci.h b/lib/pci.h
> index 9c1e281..a86bfd7 100644
> --- a/lib/pci.h
> +++ b/lib/pci.h
> @@ -136,6 +136,8 @@ struct pci_dev {
> char *module_alias; /* Linux kernel module alias */
> char *label; /* Device name as exported by BIOS */
> int numa_node; /* NUMA node */
> + pciaddr_t flags[6]; /* Region IORESOURCE flags */
> + pciaddr_t rom_flags; /* Expansion ROM IORESOURCE flags */
>
> /* Fields used internally: */
> struct pci_access *access;
> @@ -174,6 +176,7 @@ int pci_fill_info(struct pci_dev *, int flags) PCI_ABI; /* Fill in device inform
> #define PCI_FILL_MODULE_ALIAS 0x0200
> #define PCI_FILL_LABEL 0x0400
> #define PCI_FILL_NUMA_NODE 0x0800
> +#define PCI_FILL_IO_FLAGS 0x1000
> #define PCI_FILL_RESCAN 0x00010000
>
> void pci_setup_cache(struct pci_dev *, u8 *cache, int len) PCI_ABI;
> diff --git a/lib/sysfs.c b/lib/sysfs.c
> index 986ecc9..65f58bf 100644
> --- a/lib/sysfs.c
> +++ b/lib/sysfs.c
> @@ -153,14 +153,17 @@ sysfs_get_resources(struct pci_dev *d)
> size = end - start + 1;
> else
> size = 0;
> - flags &= PCI_ADDR_FLAG_MASK;
> if (i < 6)
> {
> + d->flags[i] = flags;
> + flags &= PCI_ADDR_FLAG_MASK;
> d->base_addr[i] = start | flags;
> d->size[i] = size;
> }
> else
> {
> + d->rom_flags = flags;
> + flags &= PCI_ADDR_FLAG_MASK;
> d->rom_base_addr = start | flags;
> d->rom_size = size;
> }
> @@ -208,7 +211,7 @@ static void sysfs_scan(struct pci_access *a)
> d->vendor_id = sysfs_get_value(d, "vendor", 1);
> d->device_id = sysfs_get_value(d, "device", 1);
> d->device_class = sysfs_get_value(d, "class", 1) >> 8;
> - d->known_fields = PCI_FILL_IDENT | PCI_FILL_CLASS | PCI_FILL_IRQ | PCI_FILL_BASES | PCI_FILL_ROM_BASE | PCI_FILL_SIZES;
> + d->known_fields = PCI_FILL_IDENT | PCI_FILL_CLASS | PCI_FILL_IRQ | PCI_FILL_BASES | PCI_FILL_ROM_BASE | PCI_FILL_SIZES | PCI_FILL_IO_FLAGS;
> }
> pci_link_dev(a, d);
> }
> diff --git a/lspci.c b/lspci.c
> index fe7b7fe..52d14f3 100644
> --- a/lspci.c
> +++ b/lspci.c
> @@ -336,7 +336,7 @@ show_size(pciaddr_t x)
> if (!x)
> return;
> for (i = 0; i < (sizeof(suffix) / sizeof(*suffix) - 1); i++) {
> - if (x < 1024)
> + if (x % 1024)
> break;
> x /= 1024;
> }
> @@ -355,6 +355,7 @@ show_bases(struct device *d, int cnt)
> {
> pciaddr_t pos = p->base_addr[i];
> pciaddr_t len = (p->known_fields & PCI_FILL_SIZES) ? p->size[i] : 0;
> + pciaddr_t ioflg = (p->known_fields & PCI_FILL_IO_FLAGS) ? p->flags[i] : 0;
> u32 flg = get_conf_long(d, PCI_BASE_ADDRESS_0 + 4*i);
> if (flg == 0xffffffff)
> flg = 0;
> @@ -364,7 +365,9 @@ show_bases(struct device *d, int cnt)
> printf("\tRegion %d: ", i);
> else
> putchar('\t');
> - if (pos && !flg) /* Reported by the OS, but not by the device */
> + if (ioflg & IORESOURCE_PCI_EA_BEI)
> + printf("[enhanced] ");
> + else if (pos && !flg) /* Reported by the OS, but not by the device */
> {
> printf("[virtual] ");
> flg = pos;
> @@ -430,6 +433,7 @@ show_rom(struct device *d, int reg)
> struct pci_dev *p = d->dev;
> pciaddr_t rom = p->rom_base_addr;
> pciaddr_t len = (p->known_fields & PCI_FILL_SIZES) ? p->rom_size : 0;
> + pciaddr_t ioflg = (p->known_fields & PCI_FILL_IO_FLAGS) ? p->rom_flags : 0;
> u32 flg = get_conf_long(d, reg);
> word cmd = get_conf_word(d, PCI_COMMAND);
> int virtual = 0;
> @@ -437,7 +441,9 @@ show_rom(struct device *d, int reg)
> if (!rom && !flg && !len)
> return;
> putchar('\t');
> - if ((rom & PCI_ROM_ADDRESS_MASK) && !(flg & PCI_ROM_ADDRESS_MASK))
> + if (ioflg & IORESOURCE_PCI_EA_BEI)
> + printf("[enhanced] ");
> + else if ((rom & PCI_ROM_ADDRESS_MASK) && !(flg & PCI_ROM_ADDRESS_MASK))
> {
> printf("[virtual] ");
> flg = rom;
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4 2/2] Add support for enhanced allocation regions
2016-04-10 22:22 ` Bjorn Helgaas
@ 2016-05-14 9:28 ` Martin Mares
0 siblings, 0 replies; 7+ messages in thread
From: Martin Mares @ 2016-05-14 9:28 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Sean O. Stalley, linux-pci, bhelgaas, alex.williamson,
david.daney
Hi Bjorn,
sorry for the delay, I was too busy with rebuilding my house :)
> > ex: a 2000 byte region should display [size=2000] instead of [size=1K]
>
> What do you think of this? I don't object to the kernel PCI part of
> it, but I don't want to apply it unless you plan to make lspci make
> use of it.
I like it. Applied to pciutils.git.
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
Nothing is smiple enough to be not screwed up.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4 1/2] pci: Identify Enhanced Allocation (EA) BAR Equivalent resources
2016-02-12 0:52 ` [PATCH v4 1/2] pci: Identify Enhanced Allocation (EA) BAR Equivalent resources Sean O. Stalley
@ 2016-05-16 20:31 ` Bjorn Helgaas
2016-05-16 22:07 ` Stalley, Sean
0 siblings, 1 reply; 7+ messages in thread
From: Bjorn Helgaas @ 2016-05-16 20:31 UTC (permalink / raw)
To: Sean O. Stalley; +Cc: linux-pci, mj, bhelgaas, alex.williamson, david.daney
On Thu, Feb 11, 2016 at 04:52:24PM -0800, Sean O. Stalley wrote:
> From: Alex Williamson <alex.williamson@redhat.com>
>
> Resource flags are exposed to userspace via the sysfs "resource" file.
> lspci reads the sysfs file to determine resource properties.
> Adding this flag allows lspci to distinguish between [virtual]
> and [enhanced] resources.
>
> If the resource is not aligned, userspace could deduce where
> the resource is EA based on the size & address fields.
> However, a flag indicating whether a PCI resource is a traditional BAR
> or BAR equivalent seems like a much simpler solution and works if the
> EA resource is aligned.
>
> Although this patchset only improves lspci, other uses for this
> flag have been identified. For example, vfio makes assumptions
> about alignment and sizing, and runs into problems when attempting
> to emulate a BAR Equivalent EA resource.
>
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> Signed-off-by: Sean O. Stalley <sean.stalley@intel.com>
I applied this to pci/resource and intend to merge it for v4.7.
> ---
> drivers/pci/pci.c | 2 +-
> include/linux/ioport.h | 7 +++++++
> 2 files changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index d1a7105..8ff678c 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -2229,7 +2229,7 @@ void pci_pm_init(struct pci_dev *dev)
>
> static unsigned long pci_ea_flags(struct pci_dev *dev, u8 prop)
> {
> - unsigned long flags = IORESOURCE_PCI_FIXED;
> + unsigned long flags = IORESOURCE_PCI_FIXED | IORESOURCE_PCI_EA_BEI;
>
> switch (prop) {
> case PCI_EA_P_MEM:
> diff --git a/include/linux/ioport.h b/include/linux/ioport.h
> index 24bea08..88816f9 100644
> --- a/include/linux/ioport.h
> +++ b/include/linux/ioport.h
> @@ -25,7 +25,11 @@ struct resource {
>
> /*
> * IO resources have these defined flags.
> + *
> + * PCI devices expose these flags to userspace in the "resource" sysfs file,
> + * Moving them around could break stuff, so don't do it.
> */
> +
> #define IORESOURCE_BITS 0x000000ff /* Bus-specific bits */
>
> #define IORESOURCE_TYPE_BITS 0x00001f00 /* Resource type */
> @@ -97,6 +101,7 @@ struct resource {
> #define IORESOURCE_IO_SPARSE (1<<2)
>
> /* PCI ROM control bits (IORESOURCE_BITS) */
> +
> #define IORESOURCE_ROM_ENABLE (1<<0) /* ROM is enabled, same as PCI_ROM_ADDRESS_ENABLE */
> #define IORESOURCE_ROM_SHADOW (1<<1) /* ROM is copy at C000:0 */
> #define IORESOURCE_ROM_COPY (1<<2) /* ROM is alloc'd copy, resource field overlaid */
> @@ -105,6 +110,8 @@ struct resource {
> /* PCI control bits. Shares IORESOURCE_BITS with above PCI ROM. */
> #define IORESOURCE_PCI_FIXED (1<<4) /* Do not move resource */
>
> +/* PCI Enhanced Allocation defined BAR equivalent resource */
> +#define IORESOURCE_PCI_EA_BEI (1<<5)
>
> /* helpers to define resources */
> #define DEFINE_RES_NAMED(_start, _size, _name, _flags) \
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH v4 1/2] pci: Identify Enhanced Allocation (EA) BAR Equivalent resources
2016-05-16 20:31 ` Bjorn Helgaas
@ 2016-05-16 22:07 ` Stalley, Sean
0 siblings, 0 replies; 7+ messages in thread
From: Stalley, Sean @ 2016-05-16 22:07 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: linux-pci@vger.kernel.org, mj@ucw.cz, bhelgaas@google.com,
alex.williamson@redhat.com, david.daney@cavium.com
Thanks Bjorn & Martin!
-Sean
> -----Original Message-----
> From: Bjorn Helgaas [mailto:helgaas@kernel.org]
> Sent: Monday, May 16, 2016 1:32 PM
> To: Stalley, Sean <sean.stalley@intel.com>
> Cc: linux-pci@vger.kernel.org; mj@ucw.cz; bhelgaas@google.com;
> alex.williamson@redhat.com; david.daney@cavium.com
> Subject: Re: [PATCH v4 1/2] pci: Identify Enhanced Allocation (EA) BAR
> Equivalent resources
>=20
> On Thu, Feb 11, 2016 at 04:52:24PM -0800, Sean O. Stalley wrote:
> > From: Alex Williamson <alex.williamson@redhat.com>
> >
> > Resource flags are exposed to userspace via the sysfs "resource" file.
> > lspci reads the sysfs file to determine resource properties.
> > Adding this flag allows lspci to distinguish between [virtual] and
> > [enhanced] resources.
> >
> > If the resource is not aligned, userspace could deduce where the
> > resource is EA based on the size & address fields.
> > However, a flag indicating whether a PCI resource is a traditional BAR
> > or BAR equivalent seems like a much simpler solution and works if the
> > EA resource is aligned.
> >
> > Although this patchset only improves lspci, other uses for this flag
> > have been identified. For example, vfio makes assumptions about
> > alignment and sizing, and runs into problems when attempting to
> > emulate a BAR Equivalent EA resource.
> >
> > Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> > Signed-off-by: Sean O. Stalley <sean.stalley@intel.com>
>=20
> I applied this to pci/resource and intend to merge it for v4.7.
>=20
> > ---
> > drivers/pci/pci.c | 2 +-
> > include/linux/ioport.h | 7 +++++++
> > 2 files changed, 8 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index
> > d1a7105..8ff678c 100644
> > --- a/drivers/pci/pci.c
> > +++ b/drivers/pci/pci.c
> > @@ -2229,7 +2229,7 @@ void pci_pm_init(struct pci_dev *dev)
> >
> > static unsigned long pci_ea_flags(struct pci_dev *dev, u8 prop) {
> > - unsigned long flags =3D IORESOURCE_PCI_FIXED;
> > + unsigned long flags =3D IORESOURCE_PCI_FIXED |
> IORESOURCE_PCI_EA_BEI;
> >
> > switch (prop) {
> > case PCI_EA_P_MEM:
> > diff --git a/include/linux/ioport.h b/include/linux/ioport.h index
> > 24bea08..88816f9 100644
> > --- a/include/linux/ioport.h
> > +++ b/include/linux/ioport.h
> > @@ -25,7 +25,11 @@ struct resource {
> >
> > /*
> > * IO resources have these defined flags.
> > + *
> > + * PCI devices expose these flags to userspace in the "resource"
> > + sysfs file,
> > + * Moving them around could break stuff, so don't do it.
> > */
> > +
> > #define IORESOURCE_BITS 0x000000ff /* Bus-specific bits */
> >
> > #define IORESOURCE_TYPE_BITS 0x00001f00 /* Resource type */
> > @@ -97,6 +101,7 @@ struct resource {
> > #define IORESOURCE_IO_SPARSE (1<<2)
> >
> > /* PCI ROM control bits (IORESOURCE_BITS) */
> > +
> > #define IORESOURCE_ROM_ENABLE (1<<0) /* ROM is enabled,
> same as PCI_ROM_ADDRESS_ENABLE */
> > #define IORESOURCE_ROM_SHADOW (1<<1) /* ROM is copy at
> C000:0 */
> > #define IORESOURCE_ROM_COPY (1<<2) /* ROM is alloc'd copy,
> resource field overlaid */
> > @@ -105,6 +110,8 @@ struct resource {
> > /* PCI control bits. Shares IORESOURCE_BITS with above PCI ROM. */
> > #define IORESOURCE_PCI_FIXED (1<<4) /* Do not move
> resource */
> >
> > +/* PCI Enhanced Allocation defined BAR equivalent resource */
> > +#define IORESOURCE_PCI_EA_BEI (1<<5)
> >
> > /* helpers to define resources */
> > #define DEFINE_RES_NAMED(_start, _size, _name, _flags)
> \
> > --
> > 1.9.1
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-pci"
> > in the body of a message to majordomo@vger.kernel.org More majordomo
> > info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-05-16 22:07 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-12 0:52 [PATCH v4 0/2] pci/lspci: Identify Enhanced Allocation (EA) Resources Sean O. Stalley
2016-02-12 0:52 ` [PATCH v4 1/2] pci: Identify Enhanced Allocation (EA) BAR Equivalent resources Sean O. Stalley
2016-05-16 20:31 ` Bjorn Helgaas
2016-05-16 22:07 ` Stalley, Sean
2016-02-12 0:52 ` [PATCH v4 2/2] Add support for enhanced allocation regions Sean O. Stalley
2016-04-10 22:22 ` Bjorn Helgaas
2016-05-14 9:28 ` Martin Mares
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).