From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751837AbdF1UvA (ORCPT ); Wed, 28 Jun 2017 16:51:00 -0400 Received: from terminus.zytor.com ([65.50.211.136]:54151 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751607AbdF1Uuv (ORCPT ); Wed, 28 Jun 2017 16:50:51 -0400 Date: Wed, 28 Jun 2017 13:45:16 -0700 From: tip-bot for Thomas Gleixner Message-ID: Cc: ak@linux.intel.com, bp@alien8.de, linux-kernel@vger.kernel.org, mingo@kernel.org, peterz@infradead.org, hpa@zytor.com, eranian@google.com, helgaas@kernel.org, tglx@linutronix.de Reply-To: ak@linux.intel.com, bp@alien8.de, hpa@zytor.com, peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, eranian@google.com, helgaas@kernel.org In-Reply-To: <20170316215057.205961140@linutronix.de> References: <20170316215057.205961140@linutronix.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/platform] PCI: Provide Kconfig option for lockless config space accessors Git-Commit-ID: 714fe383d6c9bd95d0d2cad8cbeff3688342d025 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 714fe383d6c9bd95d0d2cad8cbeff3688342d025 Gitweb: http://git.kernel.org/tip/714fe383d6c9bd95d0d2cad8cbeff3688342d025 Author: Thomas Gleixner AuthorDate: Thu, 16 Mar 2017 22:50:06 +0100 Committer: Thomas Gleixner CommitDate: Wed, 28 Jun 2017 22:32:56 +0200 PCI: Provide Kconfig option for lockless config space accessors The generic PCI configuration space accessors are globally serialized via pci_lock. On larger systems this causes massive lock contention when the configuration space has to be accessed frequently. One such access pattern is the Intel Uncore performance counter unit. Provide a kernel config option which can be selected by an architecture when the low level PCI configuration space accessors in the architecture use their own serialization or can operate completely lockless. Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas Cc: Andi Kleen Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Borislav Petkov Cc: linux-pci@vger.kernel.org Link: http://lkml.kernel.org/r/20170316215057.205961140@linutronix.de Signed-off-by: Thomas Gleixner --- drivers/pci/Kconfig | 3 +++ drivers/pci/access.c | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig index e0cacb7..c32a77f 100644 --- a/drivers/pci/Kconfig +++ b/drivers/pci/Kconfig @@ -86,6 +86,9 @@ config PCI_ATS config PCI_ECAM bool +config PCI_LOCKLESS_CONFIG + bool + config PCI_IOV bool "PCI IOV support" depends on PCI diff --git a/drivers/pci/access.c b/drivers/pci/access.c index c80e37a..913d672 100644 --- a/drivers/pci/access.c +++ b/drivers/pci/access.c @@ -25,6 +25,14 @@ DEFINE_RAW_SPINLOCK(pci_lock); #define PCI_word_BAD (pos & 1) #define PCI_dword_BAD (pos & 3) +#ifdef CONFIG_PCI_LOCKLESS_CONFIG +# define pci_lock_config(f) do { (void)(f); } while (0) +# define pci_unlock_config(f) do { (void)(f); } while (0) +#else +# define pci_lock_config(f) raw_spin_lock_irqsave(&pci_lock, f) +# define pci_unlock_config(f) raw_spin_unlock_irqrestore(&pci_lock, f) +#endif + #define PCI_OP_READ(size, type, len) \ int pci_bus_read_config_##size \ (struct pci_bus *bus, unsigned int devfn, int pos, type *value) \ @@ -33,10 +41,10 @@ int pci_bus_read_config_##size \ unsigned long flags; \ u32 data = 0; \ if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \ - raw_spin_lock_irqsave(&pci_lock, flags); \ + pci_lock_config(flags); \ res = bus->ops->read(bus, devfn, pos, len, &data); \ *value = (type)data; \ - raw_spin_unlock_irqrestore(&pci_lock, flags); \ + pci_unlock_config(flags); \ return res; \ } @@ -47,9 +55,9 @@ int pci_bus_write_config_##size \ int res; \ unsigned long flags; \ if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \ - raw_spin_lock_irqsave(&pci_lock, flags); \ + pci_lock_config(flags); \ res = bus->ops->write(bus, devfn, pos, len, value); \ - raw_spin_unlock_irqrestore(&pci_lock, flags); \ + pci_unlock_config(flags); \ return res; \ }