From: Bjorn Helgaas <helgaas@kernel.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
x86@kernel.org, Peter Anvin <hpa@zytor.com>,
Borislav Petkov <bp@alien8.de>,
Peter Zijlstra <peterz@infradead.org>,
Stephane Eranian <eranian@google.com>,
Andi Kleen <ak@linux.intel.com>,
linux-pci@vger.kernel.org
Subject: Re: [patch 3/7] x86/pci/ce4100: Properly lock accessor functions
Date: Tue, 27 Jun 2017 16:00:33 -0500 [thread overview]
Message-ID: <20170627210033.GD764@bhelgaas-glaptop.roam.corp.google.com> (raw)
In-Reply-To: <20170316215057.126873574@linutronix.de>
[+cc linux-pci]
On Thu, Mar 16, 2017 at 10:50:05PM +0100, Thomas Gleixner wrote:
> x86 wants to get rid of the global pci_lock protecting the config space
> accessors so ECAM mode can operate completely lockless, but the CE4100 pci
> code relies on that to protect the simulation registers.
s/pci/PCI/
> Restructure the code so it uses the x86 specific pci_config_lock to
> serialize the inner workings of the CE4100 PCI magic. That allows to remove
> the global locking via pci_lock later.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> ---
> arch/x86/pci/ce4100.c | 87 +++++++++++++++++++++++++++-----------------------
> 1 file changed, 48 insertions(+), 39 deletions(-)
>
> --- a/arch/x86/pci/ce4100.c
> +++ b/arch/x86/pci/ce4100.c
> @@ -65,6 +65,9 @@ struct sim_reg_op {
> { PCI_DEVFN(device, func), offset, init_op, read_op, write_op,\
> {0, SIZE_TO_MASK(size)} },
>
> +/*
> + * All read/write functions are called with pci_config_lock held.
> + */
> static void reg_init(struct sim_dev_reg *reg)
> {
> pci_direct_conf1.read(0, 1, reg->dev_func, reg->reg, 4,
> @@ -73,21 +76,13 @@ static void reg_init(struct sim_dev_reg
>
> static void reg_read(struct sim_dev_reg *reg, u32 *value)
> {
> - unsigned long flags;
> -
> - raw_spin_lock_irqsave(&pci_config_lock, flags);
> *value = reg->sim_reg.value;
> - raw_spin_unlock_irqrestore(&pci_config_lock, flags);
> }
>
> static void reg_write(struct sim_dev_reg *reg, u32 value)
> {
> - unsigned long flags;
> -
> - raw_spin_lock_irqsave(&pci_config_lock, flags);
> reg->sim_reg.value = (value & reg->sim_reg.mask) |
> (reg->sim_reg.value & ~reg->sim_reg.mask);
> - raw_spin_unlock_irqrestore(&pci_config_lock, flags);
> }
>
> static void sata_reg_init(struct sim_dev_reg *reg)
> @@ -117,12 +112,8 @@ static void sata_revid_read(struct sim_d
>
> static void reg_noirq_read(struct sim_dev_reg *reg, u32 *value)
> {
> - unsigned long flags;
> -
> - raw_spin_lock_irqsave(&pci_config_lock, flags);
> /* force interrupt pin value to 0 */
> *value = reg->sim_reg.value & 0xfff00ff;
> - raw_spin_unlock_irqrestore(&pci_config_lock, flags);
> }
>
> static struct sim_dev_reg bus1_fixups[] = {
> @@ -265,24 +256,33 @@ int bridge_read(unsigned int devfn, int
> return retval;
> }
>
> -static int ce4100_conf_read(unsigned int seg, unsigned int bus,
> - unsigned int devfn, int reg, int len, u32 *value)
> +static int ce4100_bus1_read(unsigned int devfn, int reg, int len, u32 *value)
> {
> + unsigned long flags;
> int i;
>
> - WARN_ON(seg);
> - if (bus == 1) {
> - for (i = 0; i < ARRAY_SIZE(bus1_fixups); i++) {
> - if (bus1_fixups[i].dev_func == devfn &&
> - bus1_fixups[i].reg == (reg & ~3) &&
> - bus1_fixups[i].read) {
> - bus1_fixups[i].read(&(bus1_fixups[i]),
> - value);
> - extract_bytes(value, reg, len);
> - return 0;
> - }
> + for (i = 0; i < ARRAY_SIZE(bus1_fixups); i++) {
> + if (bus1_fixups[i].dev_func == devfn &&
> + bus1_fixups[i].reg == (reg & ~3) &&
> + bus1_fixups[i].read) {
> +
> + raw_spin_lock_irqsave(&pci_config_lock, flags);
> + bus1_fixups[i].read(&(bus1_fixups[i]), value);
> + raw_spin_unlock_irqrestore(&pci_config_lock, flags);
> + extract_bytes(value, reg, len);
> + return 0;
> }
> }
> + return -1;
> +}
> +
> +static int ce4100_conf_read(unsigned int seg, unsigned int bus,
> + unsigned int devfn, int reg, int len, u32 *value)
> +{
> + WARN_ON(seg);
> +
> + if (bus == 1 && !ce4100_bus1_read(devfn, reg, len, value))
> + return 0;
>
> if (bus == 0 && (PCI_DEVFN(1, 0) == devfn) &&
> !bridge_read(devfn, reg, len, value))
> @@ -291,23 +291,32 @@ static int ce4100_conf_read(unsigned int
> return pci_direct_conf1.read(seg, bus, devfn, reg, len, value);
> }
>
> -static int ce4100_conf_write(unsigned int seg, unsigned int bus,
> - unsigned int devfn, int reg, int len, u32 value)
> +static int ce4100_bus1_write(unsigned int devfn, int reg, int len, u32 value)
> {
> + unsigned long flags;
> int i;
>
> - WARN_ON(seg);
> - if (bus == 1) {
> - for (i = 0; i < ARRAY_SIZE(bus1_fixups); i++) {
> - if (bus1_fixups[i].dev_func == devfn &&
> - bus1_fixups[i].reg == (reg & ~3) &&
> - bus1_fixups[i].write) {
> - bus1_fixups[i].write(&(bus1_fixups[i]),
> - value);
> - return 0;
> - }
> + for (i = 0; i < ARRAY_SIZE(bus1_fixups); i++) {
> + if (bus1_fixups[i].dev_func == devfn &&
> + bus1_fixups[i].reg == (reg & ~3) &&
> + bus1_fixups[i].write) {
> +
> + raw_spin_lock_irqsave(&pci_config_lock, flags);
> + bus1_fixups[i].write(&(bus1_fixups[i]), value);
> + raw_spin_unlock_irqrestore(&pci_config_lock, flags);
> + return 0;
> }
> }
> + return -1;
> +}
> +
> +static int ce4100_conf_write(unsigned int seg, unsigned int bus,
> + unsigned int devfn, int reg, int len, u32 value)
> +{
> + WARN_ON(seg);
> +
> + if (bus == 1 && !ce4100_bus1_write(devfn, reg, len, value))
> + return 0;
>
> /* Discard writes to A/V bridge BAR. */
> if (bus == 0 && PCI_DEVFN(1, 0) == devfn &&
> @@ -318,8 +327,8 @@ static int ce4100_conf_write(unsigned in
> }
>
> static const struct pci_raw_ops ce4100_pci_conf = {
> - .read = ce4100_conf_read,
> - .write = ce4100_conf_write,
> + .read = ce4100_conf_read,
> + .write = ce4100_conf_write,
> };
>
> int __init ce4100_pci_init(void)
>
>
next prev parent reply other threads:[~2017-06-27 21:00 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-16 21:50 [patch 0/7] x86/pci: Switch to lockless ECAM configuration mode Thomas Gleixner
2017-03-16 21:50 ` [patch 1/7] x86/pci: Remove duplicate defines Thomas Gleixner
2017-06-27 20:57 ` Bjorn Helgaas
2017-06-28 20:43 ` [tip:x86/platform] x86/PCI: " tip-bot for Thomas Gleixner
2017-03-16 21:50 ` [patch 2/7] x86/pci: Abort if legacy init fails Thomas Gleixner
2017-06-27 20:59 ` Bjorn Helgaas
2017-06-28 20:44 ` [tip:x86/platform] x86/PCI: " tip-bot for Thomas Gleixner
2017-03-16 21:50 ` [patch 3/7] x86/pci/ce4100: Properly lock accessor functions Thomas Gleixner
2017-03-17 0:28 ` Andi Kleen
2017-06-27 21:00 ` Bjorn Helgaas [this message]
2017-06-28 20:44 ` [tip:x86/platform] x86/PCI/ce4100: " tip-bot for Thomas Gleixner
2017-03-16 21:50 ` [patch 4/7] PCI: Provide Kconfig option for lockless config space accessors Thomas Gleixner
2017-06-27 21:11 ` Bjorn Helgaas
2017-06-28 20:31 ` Thomas Gleixner
2017-06-28 20:45 ` [tip:x86/platform] " tip-bot for Thomas Gleixner
2017-03-16 21:50 ` [patch 5/7] x86/pci: Select CONFIG_PCI_LOCKLESS_CONFIG Thomas Gleixner
2017-06-28 20:45 ` [tip:x86/platform] x86/PCI: " tip-bot for Thomas Gleixner
2017-03-16 21:50 ` [patch 6/7] x86/pci/mmcfg: Include 32/64 bit code into shared code Thomas Gleixner
2017-03-17 0:25 ` Andi Kleen
2017-03-17 8:41 ` Thomas Gleixner
2017-03-16 21:50 ` [patch 7/7] x86/pci/mmcfg: Switch to ECAM config mode if possible Thomas Gleixner
2017-03-17 0:26 ` Andi Kleen
2017-03-17 6:15 ` Thomas Gleixner
2017-06-27 21:31 ` Bjorn Helgaas
2017-06-28 20:46 ` [tip:x86/platform] x86/PCI/mmcfg: " tip-bot for Thomas Gleixner
2017-06-29 6:45 ` tip-bot for Thomas Gleixner
2017-06-29 23:26 ` Yinghai Lu
2017-06-30 3:18 ` Andi Kleen
2017-06-30 14:30 ` Thomas Gleixner
2017-06-30 17:16 ` Linus Torvalds
2017-06-30 18:30 ` Ivan Kokshaysky
2017-06-30 18:46 ` Thomas Gleixner
2017-06-13 0:25 ` [patch 0/7] x86/pci: Switch to lockless ECAM configuration mode Andi Kleen
2017-06-21 22:28 ` Thomas Gleixner
2017-06-27 20:55 ` Bjorn Helgaas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170627210033.GD764@bhelgaas-glaptop.roam.corp.google.com \
--to=helgaas@kernel.org \
--cc=ak@linux.intel.com \
--cc=bp@alien8.de \
--cc=eranian@google.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®