Port IO instructions (PIO) are less efficient than MMIO (memory mapped I/O). They require twice as many PCI accesses and PIO instructions are serializing. As a result, MMIO should be preferred when possible over PIO.
Bare metal test result 1 million reads using raw_pci_read() took: PIO: 0.433153 Sec. MMIO: 0.268792 Sec.
Virtual Machine test result 1 hundred thousand reads using raw_pci_read() took: PIO: 12.809 Sec. MMIO: took 8.517 Sec.
Signed-off-by: Ajay Kaher akaher@vmware.com --- arch/x86/pci/common.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index 3507f456f..0b3383d9c 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c @@ -40,20 +40,20 @@ const struct pci_raw_ops *__read_mostly raw_pci_ext_ops; int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn, int reg, int len, u32 *val) { + if (raw_pci_ext_ops) + return raw_pci_ext_ops->read(domain, bus, devfn, reg, len, val); if (domain == 0 && reg < 256 && raw_pci_ops) return raw_pci_ops->read(domain, bus, devfn, reg, len, val); - if (raw_pci_ext_ops) - return raw_pci_ext_ops->read(domain, bus, devfn, reg, len, val); return -EINVAL; }
int raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devfn, int reg, int len, u32 val) { + if (raw_pci_ext_ops) + return raw_pci_ext_ops->write(domain, bus, devfn, reg, len, val); if (domain == 0 && reg < 256 && raw_pci_ops) return raw_pci_ops->write(domain, bus, devfn, reg, len, val); - if (raw_pci_ext_ops) - return raw_pci_ext_ops->write(domain, bus, devfn, reg, len, val); return -EINVAL; }
[+cc Matthew]
On Tue, Jun 28, 2022 at 09:59:21PM +0530, Ajay Kaher wrote:
Port IO instructions (PIO) are less efficient than MMIO (memory mapped I/O). They require twice as many PCI accesses and PIO instructions are serializing. As a result, MMIO should be preferred when possible over PIO.
Bare metal test result 1 million reads using raw_pci_read() took: PIO: 0.433153 Sec. MMIO: 0.268792 Sec.
Virtual Machine test result 1 hundred thousand reads using raw_pci_read() took: PIO: 12.809 Sec. MMIO: took 8.517 Sec.
Signed-off-by: Ajay Kaher akaher@vmware.com
arch/x86/pci/common.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index 3507f456f..0b3383d9c 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c @@ -40,20 +40,20 @@ const struct pci_raw_ops *__read_mostly raw_pci_ext_ops; int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn, int reg, int len, u32 *val) {
- if (raw_pci_ext_ops)
if (domain == 0 && reg < 256 && raw_pci_ops) return raw_pci_ops->read(domain, bus, devfn, reg, len, val);return raw_pci_ext_ops->read(domain, bus, devfn, reg, len, val);
- if (raw_pci_ext_ops)
return -EINVAL;return raw_pci_ext_ops->read(domain, bus, devfn, reg, len, val);
This organization of raw_pci_read() dates to b6ce068a1285 ("Change pci_raw_ops to pci_raw_read/write"), by Matthew. Cc'd him for comment, since I think he considered the ordering at the time.
} int raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devfn, int reg, int len, u32 val) {
- if (raw_pci_ext_ops)
if (domain == 0 && reg < 256 && raw_pci_ops) return raw_pci_ops->write(domain, bus, devfn, reg, len, val);return raw_pci_ext_ops->write(domain, bus, devfn, reg, len, val);
- if (raw_pci_ext_ops)
return -EINVAL;return raw_pci_ext_ops->write(domain, bus, devfn, reg, len, val);
} -- 2.30.0
On Tue, Jun 28, 2022 at 09:59:21PM +0530, Ajay Kaher wrote:
Port IO instructions (PIO) are less efficient than MMIO (memory mapped I/O). They require twice as many PCI accesses and PIO instructions are serializing. As a result, MMIO should be preferred when possible over PIO.
Bare metal test result 1 million reads using raw_pci_read() took: PIO: 0.433153 Sec. MMIO: 0.268792 Sec.
Virtual Machine test result 1 hundred thousand reads using raw_pci_read() took: PIO: 12.809 Sec. MMIO: took 8.517 Sec.
Signed-off-by: Ajay Kaher akaher@vmware.com
arch/x86/pci/common.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index 3507f456f..0b3383d9c 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c @@ -40,20 +40,20 @@ const struct pci_raw_ops *__read_mostly raw_pci_ext_ops; int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn, int reg, int len, u32 *val) {
- if (raw_pci_ext_ops)
if (domain == 0 && reg < 256 && raw_pci_ops) return raw_pci_ops->read(domain, bus, devfn, reg, len, val);return raw_pci_ext_ops->read(domain, bus, devfn, reg, len, val);
- if (raw_pci_ext_ops)
return -EINVAL;return raw_pci_ext_ops->read(domain, bus, devfn, reg, len, val);
} int raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devfn, int reg, int len, u32 val) {
- if (raw_pci_ext_ops)
if (domain == 0 && reg < 256 && raw_pci_ops) return raw_pci_ops->write(domain, bus, devfn, reg, len, val);return raw_pci_ext_ops->write(domain, bus, devfn, reg, len, val);
- if (raw_pci_ext_ops)
return -EINVAL;return raw_pci_ext_ops->write(domain, bus, devfn, reg, len, val);
} -- 2.30.0
<formletter>
This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html for how to do this properly.
</formletter>
On June 28, 2022 11:12:41 PM PDT, Greg KH gregkh@linuxfoundation.org wrote:
On Tue, Jun 28, 2022 at 09:59:21PM +0530, Ajay Kaher wrote:
Port IO instructions (PIO) are less efficient than MMIO (memory mapped I/O). They require twice as many PCI accesses and PIO instructions are serializing. As a result, MMIO should be preferred when possible over PIO.
Bare metal test result 1 million reads using raw_pci_read() took: PIO: 0.433153 Sec. MMIO: 0.268792 Sec.
Virtual Machine test result 1 hundred thousand reads using raw_pci_read() took: PIO: 12.809 Sec. MMIO: took 8.517 Sec.
Signed-off-by: Ajay Kaher akaher@vmware.com
arch/x86/pci/common.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index 3507f456f..0b3383d9c 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c @@ -40,20 +40,20 @@ const struct pci_raw_ops *__read_mostly raw_pci_ext_ops; int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn, int reg, int len, u32 *val) {
- if (raw_pci_ext_ops)
if (domain == 0 && reg < 256 && raw_pci_ops) return raw_pci_ops->read(domain, bus, devfn, reg, len, val);return raw_pci_ext_ops->read(domain, bus, devfn, reg, len, val);
- if (raw_pci_ext_ops)
return -EINVAL;return raw_pci_ext_ops->read(domain, bus, devfn, reg, len, val);
} int raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devfn, int reg, int len, u32 val) {
- if (raw_pci_ext_ops)
if (domain == 0 && reg < 256 && raw_pci_ops) return raw_pci_ops->write(domain, bus, devfn, reg, len, val);return raw_pci_ext_ops->write(domain, bus, devfn, reg, len, val);
- if (raw_pci_ext_ops)
return -EINVAL;return raw_pci_ext_ops->write(domain, bus, devfn, reg, len, val);
} -- 2.30.0
<formletter>
This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html for how to do this properly.
</formletter>
The statement in the header is also incorrect.
linux-stable-mirror@lists.linaro.org