linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: linux-hotplug@vger.kernel.org
Subject: Re: How does Linux handle PCI-E Surprise unplug?
Date: Fri, 19 Feb 2010 04:27:35 +0000	[thread overview]
Message-ID: <20100219042735.GB4616@kroah.com> (raw)
In-Reply-To: <8506939B503B404A84BBB12293FC45F606B883BA@emailbng3.jnpr.net>

On Fri, Feb 19, 2010 at 09:31:46AM +0530, Rajat Jain wrote:
> > The driver will suddenly start reading all 0xff and will then need to
> > abort whatever it was doing.  Usually all drivers handle this just
> fine
> > today, as this is what they needed to do when they were pccard
> devices.
> > Nothing new here at all.
> 
> It is fairly common for the drivers to have such code:
> 
> Val1 = ioread32(reg1);
> Val2 = ioread32(reg2);
> Val3 = ioread32(reg3);
> Val4 = ioread32(reg4);
> 
> Do you mean the above code is wrong and it should be re-written as:
> 
> If ((Val1 = ioread32(reg1)) = 0xFFFFFFFF)
> 	/* Abort */
> If ((Val2 = ioread32(reg2)) = 0xFFFFFFFF)
> 	/* Abort */
> Etc ....

No, they can check the last one, or something every once in a while.

> Checking for 0xFFFFFFFF at every read is a pain, don't you think so? And
> more over, what is a register ACTUALLY contains the value 0xFFFFFFFF?
> How do we differentiate this with the case when the device has been
> plugged out?

Test a value that you know will not be this one.

> Finally, how do we re-write the following code to handle this correctly?
> 
> iowrite32(val1, reg1);
> iowrite32(val2, reg2);
> iowrite32(val3, reg3);
> iowrite32(val4, reg4);

You wait until you do a read :)

Seriously, look at the existing drivers in the kernel, they should all
handle this just fine.

thanks,

greg k-h

  parent reply	other threads:[~2010-02-19  4:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-18  6:17 How does Linux handle PCI-E Surprise unplug? Rajat Jain
2010-02-18 14:52 ` Greg KH
2010-02-19  4:13 ` Rajat Jain
2010-02-19  4:27 ` Greg KH [this message]
2010-02-19  6:41 ` Hidetoshi Seto
2010-03-08  7:23 ` Rajat Jain
2010-03-08  8:24 ` Kenji Kaneshige
2010-03-08 22:49 ` Grant Grundler

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=20100219042735.GB4616@kroah.com \
    --to=greg@kroah.com \
    --cc=linux-hotplug@vger.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;
as well as URLs for NNTP newsgroup(s).