From: Bjorn Helgaas <helgaas@kernel.org>
To: Liang He <windhl@126.com>
Cc: marek.vasut+renesas@gmail.com, yoshihiro.shimoda.uh@renesas.com,
lpieralisi@kernel.org, robh@kernel.org, kw@linux.com,
bhelgaas@google.com, linux-pci@vger.kernel.org,
linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH] pci/controller/pcie-rcar-host: Hold the reference returned by of_find_matching_node
Date: Tue, 21 Jun 2022 17:49:52 -0500 [thread overview]
Message-ID: <20220621224952.GA1340618@bhelgaas> (raw)
In-Reply-To: <20220621070145.4080147-1-windhl@126.com>
On Tue, Jun 21, 2022 at 03:01:45PM +0800, Liang He wrote:
> In rcar_pcie_init(), we need to hold the reference returned by
> of_find_matching_node() which is used to call of_node_put() for
> refcount balance.
>
> Signed-off-by: Liang He <windhl@126.com>
> ---
> drivers/pci/controller/pcie-rcar-host.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pci/controller/pcie-rcar-host.c b/drivers/pci/controller/pcie-rcar-host.c
> index 997c4df6a1e7..405ec3d64f30 100644
> --- a/drivers/pci/controller/pcie-rcar-host.c
> +++ b/drivers/pci/controller/pcie-rcar-host.c
> @@ -1158,7 +1158,10 @@ static const struct of_device_id rcar_pcie_abort_handler_of_match[] __initconst
>
> static int __init rcar_pcie_init(void)
> {
> - if (of_find_matching_node(NULL, rcar_pcie_abort_handler_of_match)) {
> + struct device_node *np = of_find_matching_node(NULL, rcar_pcie_abort_handler_of_match);
> +
> + if (np) {
> + of_node_put(np);
I think this is correct, but it would be nicer to update the way this
driver uses of_device_get_match_data(), e.g.,
struct rcar_variant {
int (*phy_init_fn)(struct rcar_pcie_host *host);
bool hook_abort;
};
struct rcar_pcie_host {
...
const struct rcar_variant *variant;
};
static int rcar_pcie_probe(...)
{
host->variant = of_device_get_match_data(dev);
err = host->variant->phy_init_fn(host);
...
#ifdef CONFIG_ARM
if (host->variant->hook_abort) {
#ifdef CONFIG_ARM_LPAE
hook_fault_code(17, ...);
# else
hook_fault_code(22, ...);
#endif
}
#endif
}
Or keep the hook in a separate function called from rcar_pcie_probe()
if you think that's cleaner.
I'm not sure hook_fault_code() needs to be called separately as a
device_initcall(). The pci-ixp4xx.c driver does it in
ixp4xx_pci_probe(), so I assume rcar could do it in probe as well.
> #ifdef CONFIG_ARM_LPAE
> hook_fault_code(17, rcar_pcie_aarch32_abort_handler, SIGBUS, 0,
> "asynchronous external abort");
> --
> 2.25.1
>
next prev parent reply other threads:[~2022-06-21 22:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-21 7:01 [PATCH] pci/controller/pcie-rcar-host: Hold the reference returned by of_find_matching_node Liang He
2022-06-21 8:36 ` Geert Uytterhoeven
2022-06-21 22:49 ` Bjorn Helgaas [this message]
2022-06-22 1:32 ` Liang He
2022-06-22 7:49 ` Geert Uytterhoeven
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=20220621224952.GA1340618@bhelgaas \
--to=helgaas@kernel.org \
--cc=bhelgaas@google.com \
--cc=kw@linux.com \
--cc=linux-pci@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=marek.vasut+renesas@gmail.com \
--cc=robh@kernel.org \
--cc=windhl@126.com \
--cc=yoshihiro.shimoda.uh@renesas.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