From: Bjorn Helgaas <helgaas@kernel.org>
To: Jiantao Zhang <water.zhangjiantao@huawei.com>
Cc: jingoohan1@gmail.com, gustavo.pimentel@synopsys.com,
lpieralisi@kernel.org, kw@linux.com, robh@kernel.org,
bhelgaas@google.com, linux-pci@vger.kernel.org,
linux-kernel@vger.kernel.org, tjoseph@cadence.com,
zhangjianrong5@huawei.com
Subject: Re: [PATCH] PCI: controller: Fix calculation error of msix pending table offset
Date: Mon, 20 Nov 2023 14:08:58 -0600 [thread overview]
Message-ID: <20231120200858.GA211414@bhelgaas> (raw)
In-Reply-To: <20230531142442.27576-1-water.zhangjiantao@huawei.com>
On Wed, May 31, 2023 at 10:24:42PM +0800, Jiantao Zhang wrote:
> The interrupts already minus 1 in pci_epc_set_msix() according to pcie
> specification. So we must add 1 otherwise data corruption will happen.
I'm not sure what happened to this.
Can you include a citation to the section of the spec, which will help
reviewers?
Have you observed a crash or similar defect that is fixed by this
patch? If so, a few details would be useful in the commit log to help
people find this fix.
> Signed-off-by: Jiantao Zhang <water.zhangjiantao@huawei.com>
> Signed-off-by: Jianrong Zhang <zhangjianrong5@huawei.com>
> ---
> drivers/pci/controller/cadence/pcie-cadence-ep.c | 2 +-
> drivers/pci/controller/dwc/pcie-designware-ep.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/controller/cadence/pcie-cadence-ep.c b/drivers/pci/controller/cadence/pcie-cadence-ep.c
> index b8b655d4047e..ff608c46b8ac 100644
> --- a/drivers/pci/controller/cadence/pcie-cadence-ep.c
> +++ b/drivers/pci/controller/cadence/pcie-cadence-ep.c
> @@ -310,7 +310,7 @@ static int cdns_pcie_ep_set_msix(struct pci_epc *epc, u8 fn, u8 vfn,
>
> /* Set PBA BAR and offset. BAR must match MSIX BAR */
> reg = cap + PCI_MSIX_PBA;
> - val = (offset + (interrupts * PCI_MSIX_ENTRY_SIZE)) | bir;
> + val = (offset + ((interrupts + 1) * PCI_MSIX_ENTRY_SIZE)) | bir;
> cdns_pcie_ep_fn_writel(pcie, fn, reg, val);
>
> return 0;
> diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c
> index f9182f8d552f..3d078ebe2517 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-ep.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
> @@ -417,7 +417,7 @@ static int dw_pcie_ep_set_msix(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
> dw_pcie_writel_dbi(pci, reg, val);
>
> reg = ep_func->msix_cap + func_offset + PCI_MSIX_PBA;
> - val = (offset + (interrupts * PCI_MSIX_ENTRY_SIZE)) | bir;
> + val = (offset + ((interrupts + 1) * PCI_MSIX_ENTRY_SIZE)) | bir;
> dw_pcie_writel_dbi(pci, reg, val);
>
> dw_pcie_dbi_ro_wr_dis(pci);
> --
> 2.17.1
>
prev parent reply other threads:[~2023-11-20 20:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-31 14:24 [PATCH] PCI: controller: Fix calculation error of msix pending table offset Jiantao Zhang
2023-11-20 20:08 ` Bjorn Helgaas [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=20231120200858.GA211414@bhelgaas \
--to=helgaas@kernel.org \
--cc=bhelgaas@google.com \
--cc=gustavo.pimentel@synopsys.com \
--cc=jingoohan1@gmail.com \
--cc=kw@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=robh@kernel.org \
--cc=tjoseph@cadence.com \
--cc=water.zhangjiantao@huawei.com \
--cc=zhangjianrong5@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