From: Gu Zheng <guz.fnst@cn.fujitsu.com>
To: Yijing Wang <wangyijing@huawei.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
Hanjun Guo <guohanjun@huawei.com>,
Paul Bolle <pebolle@tiscali.nl>, Oliver Neukum <oneukum@suse.de>
Subject: Re: [PATCH part1 v6 4/7] PCI: Introduce pci_serial_number_changed()
Date: Wed, 12 Feb 2014 15:26:26 +0800 [thread overview]
Message-ID: <52FB2222.20402@cn.fujitsu.com> (raw)
In-Reply-To: <1392173573-59844-5-git-send-email-wangyijing@huawei.com>
Hi Yijing,
On 02/12/2014 10:52 AM, Yijing Wang wrote:
> Sometimes OS do not know the physical device swap,
> for instance, some device hotplug during system suspend.
> Interrupt can not deliver to OS in some platform.
> So we can use pci serial number capability to detect this
> issue if device supports serial number.
>
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Cc: Paul Bolle <pebolle@tiscali.nl>
> Cc: Oliver Neukum <oneukum@suse.de>
> Cc: Gu Zheng <guz.fnst@cn.fujitsu.com>
> Cc: linux-pci@vger.kernel.org
> ---
> drivers/pci/pci.c | 28 ++++++++++++++++++++++++++++
> include/linux/pci.h | 2 ++
> 2 files changed, 30 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index a8c1c2d..af34057 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -2199,6 +2199,34 @@ void pci_dsn_init(struct pci_dev *dev)
> }
>
> /**
> + * pci_serial_number_changed - check the device SN is changed
How about the name “pci_device_changed”? I think it's more readable,
though the judgement is according to SN.
Regards,
Gu
> + * @pdev: the PCI device
> + *
> + * check the device serial number is changed.
> + * if device does not support device serial number,
> + * return false.
> + */
> +bool pci_serial_number_changed(struct pci_dev *pdev)
> +{
> + u64 old, new;
> + old = pdev->sn;
> +
> + if (!pci_is_pcie(pdev))
> + return false;
> +
> + new = pci_device_serial_number(pdev->bus,
> + pdev->devfn);
> +
> + if (old != new) {
> + pr_info("%s: Device Serial Number Changed!\n",
> + pci_name(pdev));
> + return true;
> + } else
> + return false;
> +}
> +EXPORT_SYMBOL(pci_serial_number_changed);
> +
> +/**
> * pci_configure_ari - enable or disable ARI forwarding
> * @dev: the PCI device
> *
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 3631859..d60c0b6 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -1025,6 +1025,8 @@ void pci_unlock_rescan_remove(void);
> ssize_t pci_read_vpd(struct pci_dev *dev, loff_t pos, size_t count, void *buf);
> ssize_t pci_write_vpd(struct pci_dev *dev, loff_t pos, size_t count, const void *buf);
>
> +bool pci_serial_number_changed(struct pci_dev *pdev);
> +
> /* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */
> resource_size_t pcibios_retrieve_fw_addr(struct pci_dev *dev, int idx);
> void pci_bus_assign_resources(const struct pci_bus *bus);
next prev parent reply other threads:[~2014-02-12 7:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-12 2:52 [PATCH part1 v6 0/7] Introduce PCIe Device Serial Number capability support Yijing Wang
2014-02-12 2:52 ` [PATCH part1 v6 1/7] PCI: rework pci_find_next_ext_capability() Yijing Wang
2014-02-12 2:52 ` [PATCH part1 v6 2/7] PCI: introduce pci_bus_find_ext_capability() Yijing Wang
2014-02-12 2:52 ` [PATCH part1 v6 3/7] PCI: Add support for Device Serial Number capability Yijing Wang
2014-02-12 2:52 ` [PATCH part1 v6 4/7] PCI: Introduce pci_serial_number_changed() Yijing Wang
2014-02-12 7:26 ` Gu Zheng [this message]
2014-02-12 7:57 ` Yijing Wang
2014-02-12 2:52 ` [PATCH part1 v6 5/7] PCI: Add pci_dummy_ops to isolate pci device temporarily Yijing Wang
2014-02-12 7:46 ` Gu Zheng
2014-02-12 7:59 ` Yijing Wang
2014-02-12 2:52 ` [PATCH part1 v6 6/7] PCI: Check pci device serial number when scan device Yijing Wang
2014-02-12 2:52 ` [PATCH part1 v6 7/7] PCI: pciehp: Don't enable/disable slot on resume unless status changed Yijing Wang
2014-02-17 8:52 ` [PATCH part1 v6 0/7] Introduce PCIe Device Serial Number capability support Yijing Wang
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=52FB2222.20402@cn.fujitsu.com \
--to=guz.fnst@cn.fujitsu.com \
--cc=bhelgaas@google.com \
--cc=guohanjun@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=oneukum@suse.de \
--cc=pebolle@tiscali.nl \
--cc=wangyijing@huawei.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).