linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Helgaas <bhelgaas@google.com>
To: Keith Busch <keith.busch@intel.com>
Cc: linux-pci@vger.kernel.org, linux-nvme@lists.infradead.org
Subject: Re: [PATCH 1/2] PCI: Device driver function reset notification
Date: Wed, 30 Apr 2014 16:46:37 -0600	[thread overview]
Message-ID: <20140430224637.GA31315@google.com> (raw)
In-Reply-To: <1397000541-1085-1-git-send-email-keith.busch@intel.com>

On Tue, Apr 08, 2014 at 05:42:20PM -0600, Keith Busch wrote:
> A user can issue a pci function level reset to a device using sysfs entry
> /sys/bus/pci/devices/.../reset. A kernel driver handling the pci device
> might like to know this reset is about to occur and when the reset attempt
> completes. This is so the driver has a chance to take appropriate device
> specific actions; for example, it may need to quiesce before the reset,
> and reinitialize the device after.
> 
> Signed-off-by: Keith Busch <keith.busch@intel.com>
> ---
>  drivers/pci/pci.c   |   13 +++++++++++++
>  include/linux/pci.h |    3 +++
>  2 files changed, 16 insertions(+)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index fdbc294..cb24bbe 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -3320,6 +3320,15 @@ static int pci_dev_reset(struct pci_dev *dev, int probe)
>  
>  	return rc;
>  }
> +
> +static void pci_reset_notify(struct pci_dev *dev, bool prepare)
> +{
> +	const struct pci_error_handlers *err_handler =
> +			dev->driver ? dev->driver->err_handler : NULL;
> +	if (err_handler && err_handler->reset_notify)
> +		err_handler->reset_notify(dev, prepare);
> +}
> +
>  /**
>   * __pci_reset_function - reset a PCI device function
>   * @dev: PCI device to reset
> @@ -3408,11 +3417,13 @@ int pci_reset_function(struct pci_dev *dev)
>  	if (rc)
>  		return rc;
>  
> +	pci_reset_notify(dev, true);
>  	pci_dev_save_and_disable(dev);
>  
>  	rc = pci_dev_reset(dev, 0);
>  
>  	pci_dev_restore(dev);
> +	pci_reset_notify(dev, false);
>  
>  	return rc;
>  }
> @@ -3432,6 +3443,7 @@ int pci_try_reset_function(struct pci_dev *dev)
>  	if (rc)
>  		return rc;
>  
> +	pci_reset_notify(dev, true);
>  	pci_dev_save_and_disable(dev);
>  
>  	if (pci_dev_trylock(dev)) {
> @@ -3441,6 +3453,7 @@ int pci_try_reset_function(struct pci_dev *dev)
>  		rc = -EAGAIN;
>  
>  	pci_dev_restore(dev);
> +	pci_reset_notify(dev, false);

You put the notify in these functions:

  pci_reset_function()
  pci_try_reset_function()

but what about these:

  pci_reset_slot()
  pci_try_reset_slot()
  pci_reset_bus()
  pci_try_reset_bus()

It seems like this ought to work the same way over all kinds of reset.

>  	return rc;
>  }
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 33aa2ca..d82dd3f 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -603,6 +603,9 @@ struct pci_error_handlers {
>  	/* PCI slot has been reset */
>  	pci_ers_result_t (*slot_reset)(struct pci_dev *dev);
>  
> +	/* PCI function reset prepare or completed */
> +	void (*reset_notify)(struct pci_dev *dev, bool prepare);
> +
>  	/* Device driver may resume normal operations */
>  	void (*resume)(struct pci_dev *dev);
>  };
> -- 
> 1.7.10.4
> 

  parent reply	other threads:[~2014-04-30 22:46 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-08 23:42 [PATCH 1/2] PCI: Device driver function reset notification Keith Busch
2014-04-08 23:42 ` [PATCH 2/2] NVMe: Implement PCI-e reset notification callback Keith Busch
2014-04-22  1:34   ` Learner Study
2014-04-22  1:57     ` Keith Busch
2014-04-22  2:45       ` Learner
2014-04-22  3:34         ` Learner Study
2014-04-22  5:02           ` Mayes, Barrett N
2014-04-22 10:07             ` Learner Study
     [not found]               ` <7174f4a8.23ad7.14589360cb2.Coremail.liaohengquan1986@163.com>
2014-04-22 15:57                 ` Wheather the NVMe driver has been tried on the IBM or Lenovo server? Bjorn Helgaas
2014-04-22 16:08                   ` Learner Study
2014-04-22 14:22             ` [PATCH 2/2] NVMe: Implement PCI-e reset notification callback Keith Busch
2014-04-22 15:00               ` Learner Study
2014-04-30 22:46 ` Bjorn Helgaas [this message]
2014-05-01 19:57   ` [PATCH 1/2] PCI: Device driver function reset notification Keith Busch
2014-05-01 20:10     ` Bjorn Helgaas
2014-05-01 20:20       ` Keith Busch

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=20140430224637.GA31315@google.com \
    --to=bhelgaas@google.com \
    --cc=keith.busch@intel.com \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-pci@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).