From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Yicong Yang <yangyicong@hisilicon.com>
Cc: Bjorn Helgaas <helgaas@kernel.org>,
Bjorn Helgaas <bhelgaas@google.com>,
Kalle Valo <kvalo@codeaurora.org>,
linux-pci@vger.kernel.org
Subject: Re: [PATCH] PCI: Make pcie_find_root_port() work for PCIe root ports as well
Date: Wed, 1 Jul 2020 13:15:41 +0300 [thread overview]
Message-ID: <20200701101541.GO5180@lahna.fi.intel.com> (raw)
In-Reply-To: <c4282c55-8312-53a0-d9e6-4818b9206c1f@hisilicon.com>
On Wed, Jul 01, 2020 at 09:53:51AM +0800, Yicong Yang wrote:
> > static inline struct pci_dev *pcie_find_root_port(struct pci_dev *dev)
> > {
> > - struct pci_dev *bridge = pci_upstream_bridge(dev);
> > -
> > - while (bridge) {
> > - if (pci_pcie_type(bridge) == PCI_EXP_TYPE_ROOT_PORT)
> > - return bridge;
> > - bridge = pci_upstream_bridge(bridge);
> > + while (dev) {
> > + if (pci_is_pcie(dev) &&
> > + pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT)
> > + return dev;
> > + dev = pci_upstream_bridge(dev);
> > }
> >
>
> We may have some problems here, as after pcie_find_root_port() called, *dev will
> be either root port or NULL but users may want it unchanged. One such usage is
> in acpi_pci_bridge_d3(), drivers/pci/pci-acpi.c, *dev is used as origin
> after called this.
>
> So we should use a temporary point to *dev rather than directly modify it.
dev is already a copy of what is passed by the caller so it does not
matter if it gets changed here. You would need to pass it through struct
pci_dev **dev in order to modify the passed pointer.
next prev parent reply other threads:[~2020-07-01 10:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-22 16:12 [PATCH] PCI: Make pcie_find_root_port() work for PCIe root ports as well Mika Westerberg
2020-06-30 22:01 ` Bjorn Helgaas
2020-07-01 1:53 ` Yicong Yang
2020-07-01 10:15 ` Mika Westerberg [this message]
2020-07-01 12:47 ` Yicong Yang
2020-07-01 10:14 ` Mika Westerberg
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=20200701101541.GO5180@lahna.fi.intel.com \
--to=mika.westerberg@linux.intel.com \
--cc=bhelgaas@google.com \
--cc=helgaas@kernel.org \
--cc=kvalo@codeaurora.org \
--cc=linux-pci@vger.kernel.org \
--cc=yangyicong@hisilicon.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).