linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Helgaas <bhelgaas@google.com>
To: Guenter Roeck <groeck@juniper.net>
Cc: Rajat Jain <rajatxjain@gmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	Rajat Jain <rajatjain@juniper.net>
Subject: Re: [PATCH v2] PCI: pciehp: Check link state before accessing device during removal
Date: Thu, 11 Dec 2014 14:00:06 -0700	[thread overview]
Message-ID: <CAErSpo4WAbb=n+cNARRgKWPhbn6LZqwL-htB_Uv2OWB9BwTXpw@mail.gmail.com> (raw)
In-Reply-To: <20141211204515.GA4472@svl-evodev-groeck.juniper.net>

On Thu, Dec 11, 2014 at 1:45 PM, Guenter Roeck <groeck@juniper.net> wrote:
> On Thu, Dec 11, 2014 at 01:26:47PM -0700, Bjorn Helgaas wrote:
>> On Thu, Dec 11, 2014 at 9:38 AM, Guenter Roeck <groeck@juniper.net> wrote:
>> > On Wed, Dec 10, 2014 at 05:26:30PM -0700, Bjorn Helgaas wrote:
>> >> On Thu, Nov 20, 2014 at 02:54:24PM -0800, Rajat Jain wrote:

>> >> If we do need it (and it looks like most or all hotplug drivers copied it),
>> >> isn't there still a race?  Can't we have the following sequence?
>> >>
>> >>   - pciehp_check_link_active()                # returns true
>> >>   - Link goes down
>> >>   - pci_read_config_byte()            # fails because link is down
>> >>
>> > I would guess so. Question is how to address it. Read the configuration byte
>> > first, then check if the link is down ? Check if link is still up after reading
>> > the configuration byte ? Add a note that there may be a potential race condition
>> > and do nothing until it is actually seen ?
>>
>> I think we should just read PCI_BRIDGE_CONTROL and look for a 0xff
>> value.  That's not a legal value for the register, so if we see it, it
>> should be pretty safe to assume the link is down or the device is not
>> present at all.
>>
> Something like
>         if (bctl != 0xff && (bctl & PCI_BRIDGE_CTL_VGA)) {
> in addition to Rajat's changes ?
>
> I think it would be good to keep the change Rajat proposed, ie to check
> the link state instead of presence. Question then is if you'd want a new
> revision of Rajat's patch or another patch on top of it with the bctl
> related change.

Why do we need the link state or the presence check?  It seems like
those are sort of a 90% solution, and doing them provides the illusion
of value but without real value.  If we think that checking for 0xff
is a 100% solution, we should rely on that and not bother with
anything else.

Bjorn

  reply	other threads:[~2014-12-11 21:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-20 22:54 [PATCH v2] PCI: pciehp: Check link state before accessing device during removal Rajat Jain
2014-12-08  6:15 ` Rajat Jain
2014-12-11  0:26 ` Bjorn Helgaas
2014-12-11 16:38   ` Guenter Roeck
2014-12-11 20:26     ` Bjorn Helgaas
2014-12-11 20:45       ` Guenter Roeck
2014-12-11 21:00         ` Bjorn Helgaas [this message]
2014-12-11 21:39           ` Guenter Roeck

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='CAErSpo4WAbb=n+cNARRgKWPhbn6LZqwL-htB_Uv2OWB9BwTXpw@mail.gmail.com' \
    --to=bhelgaas@google.com \
    --cc=groeck@juniper.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=rajatjain@juniper.net \
    --cc=rajatxjain@gmail.com \
    /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).