linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brian King <brking@us.ibm.com>
To: Grant Grundler <grundler@parisc-linux.org>
Cc: Paul Mackerras <paulus@samba.org>, Andrew Morton <akpm@osdl.org>,
	greg@kroah.com, matthew@wil.cx, benh@kernel.crashing.org,
	ak@muc.de, linux-kernel@vger.kernel.org,
	alan@lxorguk.ukuu.org.uk, linux-pci@atrey.karlin.mff.cuni.cz
Subject: Re: [PATCH 1/2] pci: Block config access during BIST (resend)
Date: Sat, 03 Sep 2005 18:37:52 -0500	[thread overview]
Message-ID: <431A33D0.1040807@us.ibm.com> (raw)
In-Reply-To: <20050903000854.GC8463@colo.lackof.org>

Grant Grundler wrote:
> On Sat, Sep 03, 2005 at 09:11:30AM +1000, Paul Mackerras wrote:
> 
>>Think about it.  Taking the lock ensures that we don't do the
>>assignment (dev->block_ucfg_access = 1) while any other cpu has the
>>pci_lock.  In other words, the reason for taking the lock is so that
>>we wait until nobody else is doing an access, not to make others wait.
> 
> 
> The block_ucfg_access field is only used when making the choice to
> use saved state or call the PCI bus cfg accessor.
> I don't what problem waiting solves here since any CPU already
> accessing real cfg space will finish what they are doing anyway.
> ie they already made the choice to access real cfg space.
> We just need to make sure successive accesses to cfg space
> for this device only access the saved state. For that, a memory barrier
> around all uses of block_ucfg_access should be sufficient.
> Or do you think I'm still drinking the wrong color cool-aid?

Without the locking, we introduce a race condition.

CPU 0                                           CPU 1

					pci_block_user_cfg_access
						pci_save_state
pci_read_user_config_space
	check block_ucfg_access
						set block_ucfg_access
					other code that puts the device
					in a state such that it cannot
					handle read config i/o, such as
					running BIST.

	pci read config

In this scenario, If the real read on the left happens after the flag is 
set to block user config accesses, then the thread that set the flag 
could go off and start BIST or do something else to put the pci device 
in a state where it cannot accept real config I/O and we end up with a 
target abort, which is exactly what this patch is attempting to fix.

Granted, for the specific usage scenario in ipr, where I am using this 
to block config space over BIST, I use a pci config write to start BIST, 
which would end up being a point of synchronization, but that seems a 
bit non-obvious and limits how the patch can be used by others...

>>>If you had:
>>>	spin_lock_irqsave(&pci_lock, flags);
>>>	pci_save_state(dev);
>>>	dev->block_ucfg_access = 1;
>>>	spin_unlock_irqrestore(&pci_lock, flags);
>>>
>>>Then I could buy your arguement since the flag now implies
>>>we need to atomically save state and set the flag.
>>
>>That's probably a good thing to do to.
> 
> 
> One needs to verify pci_lock isn't acquired in pci_save_state()
> (or some other obvious dead lock).

Unfortunately, it is... Every pci config access grabs the lock, so we 
would need to use some special code that did not acquire the lock in 
pci_save_state if we wanted to do such a thing.

Brian


-- 
Brian King
eServer Storage I/O
IBM Linux Technology Center

  reply	other threads:[~2005-09-03 17:38 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-10 14:49 [PATCH 1/1] pci: Block config access during BIST (resend) brking
2005-01-10 16:10 ` Andi Kleen
2005-01-10 16:25   ` Brian King
2005-01-10 16:29     ` Andi Kleen
2005-01-10 22:57       ` Brian King
2005-01-11 14:37         ` Alan Cox
2005-01-11 17:33           ` Andi Kleen
2005-01-11 22:17             ` Brian King
2005-01-13 15:36               ` Alan Cox
2005-01-13 15:35             ` Alan Cox
2005-01-13 18:03               ` Andi Kleen
2005-01-13 18:46                 ` Alan Cox
2005-01-13 20:23                   ` Andi Kleen
2005-01-13 19:44                     ` Alan Cox
2005-01-13 21:50                       ` Andi Kleen
2005-01-15  0:33                         ` Alan Cox
2005-01-15  1:44                           ` Andi Kleen
2005-01-15  1:01                             ` Alan Cox
2005-01-15  6:20                               ` Benjamin Herrenschmidt
2005-01-16  0:58                                 ` Alan Cox
2005-01-16  4:01                                   ` Benjamin Herrenschmidt
2005-01-16  4:48                                     ` Andi Kleen
2005-01-16 20:53                                       ` Benjamin Herrenschmidt
2005-01-16 22:07                                         ` Andi Kleen
2005-01-16 22:14                                           ` Benjamin Herrenschmidt
2005-01-16 21:10                                       ` Alan Cox
2005-01-18 15:14                     ` Brian King
2005-01-18 23:31                       ` Andi Kleen
2005-01-18 23:36                         ` Brian King
2005-01-19 22:40                       ` Alan Cox
2005-01-26 16:34                         ` Brian King
2005-01-26 22:10                           ` Benjamin Herrenschmidt
2005-01-27 15:53                             ` Alan Cox
2005-01-27 18:44                               ` Brian King
2005-01-27 23:15                               ` Benjamin Herrenschmidt
2005-01-28 14:35                               ` Brian King
2005-02-01  7:27                                 ` Greg KH
2005-02-01 15:12                                   ` Brian King
2005-02-01 15:44                                     ` Matthew Wilcox
2005-02-01 17:35                                       ` Brian King
2005-02-01 17:47                                         ` Matthew Wilcox
2005-02-01 19:01                                           ` Brian King
2005-02-01 23:00                                           ` Benjamin Herrenschmidt
2005-02-02 15:33                                           ` Brian King
2005-02-08 20:08                                             ` Greg KH
2005-06-21 16:08                                               ` Brian King
2005-08-23 15:11                                                 ` [PATCH 1/2] " Brian King
2005-08-23 15:14                                                   ` [PATCH 2/2] ipr: " Brian King
2005-09-01 23:03                                                   ` [PATCH 1/2] pci: " Andrew Morton
2005-09-02 23:56                                                     ` Brian King
2005-09-02 22:43                                                       ` Grant Grundler
2005-09-02 23:11                                                         ` Paul Mackerras
2005-09-03  0:08                                                           ` Grant Grundler
2005-09-03 23:37                                                             ` Brian King [this message]
2005-09-03 19:39                                                               ` Grant Grundler
2005-09-05 18:31                                                                 ` Brian King
2005-09-06  4:48                                                                   ` Grant Grundler
2005-09-06 14:28                                                                     ` Brian King
2005-09-07  5:49                                                                 ` Paul Mackerras
2005-09-07 14:58                                                                   ` Grant Grundler
2005-09-07 22:39                                                                     ` Paul Mackerras
2005-09-08  1:21                                                                       ` Grant Grundler
2005-09-08  3:05                                                                         ` Brian King
2005-09-08  4:08                                                                           ` Grant Grundler
2005-02-01 18:58                                       ` [PATCH 1/1] " Greg KH
2005-02-01 23:07                                         ` Benjamin Herrenschmidt
2005-02-01 22:58                                       ` Benjamin Herrenschmidt
2005-01-10 19:23   ` Alan Cox

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=431A33D0.1040807@us.ibm.com \
    --to=brking@us.ibm.com \
    --cc=ak@muc.de \
    --cc=akpm@osdl.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=benh@kernel.crashing.org \
    --cc=greg@kroah.com \
    --cc=grundler@parisc-linux.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@atrey.karlin.mff.cuni.cz \
    --cc=matthew@wil.cx \
    --cc=paulus@samba.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;
as well as URLs for NNTP newsgroup(s).