From: Frank Li <Frank.li@nxp.com>
To: Riyan Dhiman <riyandhiman14@gmail.com>
Cc: hongxing.zhu@nxp.com, l.stach@pengutronix.de,
lpieralisi@kernel.org, bhelgaas@google.com,
linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
imx@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH next] PCI: imx6: Add error handling in imx_pcie_cpu_addr_fixup()
Date: Thu, 5 Sep 2024 11:19:45 -0400 [thread overview]
Message-ID: <ZtnMERH+/3HiqNtg@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20240905054255.126676-1-riyandhiman14@gmail.com>
On Thu, Sep 05, 2024 at 11:12:55AM +0530, Riyan Dhiman wrote:
> Added error handling to the imx_pcie_cpu_addr_fixup function for cases
> where the memory window retrieval fails. The initial implementation did
> not have error handling, and the function simply returned cpu_addr without
> checking for failure conditions.
>
> I have added -0ULL as a error return code but what should be the ideal return
> code for error handling in this function, given the u64 return type? Common
> approaches include returning ~0ULL or another invalid address value, but
> clarification on best practices would be appreciated.
>
> Signed-off-by: Riyan Dhiman <riyandhiman14@gmail.com>
> ---
It is not necessary, because pp->bridge->windows should be always success.
If it is wrong, whole PCI will not work.
Even it is wrong, return 0 also wrong. dwc use it do out-bound ATU setting.
Map address 0 to outbound range have unexpected behaviors.
If it is scanned by static tool, it should be false alarm. If you really
met the issue, let me know. It is too late check it here.
Frank
> Compile tested only. I am new to the PCI subsystem and not sure how to test these
> modules. Do I need dedicated hardware, or is there another way to test these changes?
>
> drivers/pci/controller/dwc/pci-imx6.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
> index 0dbc333adcff..6af39852d2c2 100644
> --- a/drivers/pci/controller/dwc/pci-imx6.c
> +++ b/drivers/pci/controller/dwc/pci-imx6.c
> @@ -1023,6 +1023,10 @@ static u64 imx_pcie_cpu_addr_fixup(struct dw_pcie *pcie, u64 cpu_addr)
> return cpu_addr;
>
> entry = resource_list_first_type(&pp->bridge->windows, IORESOURCE_MEM);
> + if(!entry) {
> + dev_err(pcie->dev, "Unable to get memory window.");
> + return -0ULL;
> + }
> offset = entry->offset;
>
> return (cpu_addr - offset);
> --
> 2.46.0
>
prev parent reply other threads:[~2024-09-05 15:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-05 5:42 [PATCH next] PCI: imx6: Add error handling in imx_pcie_cpu_addr_fixup() Riyan Dhiman
2024-09-05 15:19 ` Frank Li [this message]
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=ZtnMERH+/3HiqNtg@lizhi-Precision-Tower-5810 \
--to=frank.li@nxp.com \
--cc=bhelgaas@google.com \
--cc=hongxing.zhu@nxp.com \
--cc=imx@lists.linux.dev \
--cc=l.stach@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=riyandhiman14@gmail.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