From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Li Ming <ming4.li@intel.com>
Cc: <bhelgaas@google.com>, <ira.weiny@intel.com>,
<linux-pci@vger.kernel.org>
Subject: Re: [PATCH 1/1] PCI/DOE: adjust data object length
Date: Fri, 11 Nov 2022 16:47:17 +0000 [thread overview]
Message-ID: <20221111164717.00002d7e@Huawei.com> (raw)
In-Reply-To: <20221109022044.1827423-1-ming4.li@intel.com>
On Wed, 9 Nov 2022 10:20:44 +0800
Li Ming <ming4.li@intel.com> wrote:
> The value of data object length 0x0 indicates 2^18 dwords being
> transferred, it is introduced in PCIe r6.0,sec 6.30.1. This patch
Was introduced prior to that in the DOE ECN, so perhaps just drop "introduced".
I'm not sure why we missed that little detail of the spec originally so good to fix this up.
Probably deserves a fixes tag though it would be very hard to hit
with the only protocol we currently have upstream.
Other than what Bjorn pointed out and the missing bracket the
Robot found, looks good to me.
> adjusts the value of data object length for the above case on both
> sending side and receiving side.
>
> Besides, it is unnecessary to check whether length is greater than
> SZ_1M while receiving a response data object, because length from LENGTH
> field of data object header, max value is 2^18.
>
> Signed-off-by: Li Ming <ming4.li@intel.com>
> ---
> drivers/pci/doe.c | 21 +++++++++++++++++----
> 1 file changed, 17 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pci/doe.c b/drivers/pci/doe.c
> index e402f05068a5..204cbc570f63 100644
> --- a/drivers/pci/doe.c
> +++ b/drivers/pci/doe.c
> @@ -29,6 +29,9 @@
> #define PCI_DOE_FLAG_CANCEL 0
> #define PCI_DOE_FLAG_DEAD 1
>
> +/* Max data object length is 2^18 dwords */
> +#define PCI_DOE_MAX_LENGTH (2 << 18)
> +
> /**
> * struct pci_doe_mb - State for a single DOE mailbox
> *
> @@ -107,6 +110,7 @@ static int pci_doe_send_req(struct pci_doe_mb *doe_mb,
> {
> struct pci_dev *pdev = doe_mb->pdev;
> int offset = doe_mb->cap_offset;
> + u32 length;
> u32 val;
> int i;
>
> @@ -128,10 +132,12 @@ static int pci_doe_send_req(struct pci_doe_mb *doe_mb,
> FIELD_PREP(PCI_DOE_DATA_OBJECT_HEADER_1_TYPE, task->prot.type);
> pci_write_config_dword(pdev, offset + PCI_DOE_WRITE, val);
> /* Length is 2 DW of header + length of payload in DW */
> + length = 2 + task->request_pl_sz / sizeof(u32);
> + if (length == PCI_DOE_MAX_LENGTH)
> + length = 0;
> pci_write_config_dword(pdev, offset + PCI_DOE_WRITE,
> FIELD_PREP(PCI_DOE_DATA_OBJECT_HEADER_2_LENGTH,
> - 2 + task->request_pl_sz /
> - sizeof(u32)));
> + length);
> for (i = 0; i < task->request_pl_sz / sizeof(u32); i++)
> pci_write_config_dword(pdev, offset + PCI_DOE_WRITE,
> task->request_pl[i]);
> @@ -178,7 +184,10 @@ static int pci_doe_recv_resp(struct pci_doe_mb *doe_mb, struct pci_doe_task *tas
> pci_write_config_dword(pdev, offset + PCI_DOE_READ, 0);
>
> length = FIELD_GET(PCI_DOE_DATA_OBJECT_HEADER_2_LENGTH, val);
> - if (length > SZ_1M || length < 2)
> + /* A value of 0x0 indicates max data object length */
> + if (!length)
> + length = PCI_DOE_MAX_LENGTH;
> + if (length < 2)
> return -EIO;
>
> /* First 2 dwords have already been read */
> @@ -520,8 +529,12 @@ int pci_doe_submit_task(struct pci_doe_mb *doe_mb, struct pci_doe_task *task)
> /*
> * DOE requests must be a whole number of DW and the response needs to
> * be big enough for at least 1 DW
> + *
> + * Max data object length is 1MB, and data object header occupies 8B,
> + * thus request_pl_sz should not be greater than 1MB - 8B.
> */
> - if (task->request_pl_sz % sizeof(u32) ||
> + if (task->request_pl_sz > SZ_1M - 8 ||
> + task->request_pl_sz % sizeof(u32) ||
> task->response_pl_sz < sizeof(u32))
> return -EINVAL;
>
prev parent reply other threads:[~2022-11-11 16:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-09 2:20 [PATCH 1/1] PCI/DOE: adjust data object length Li Ming
2022-11-09 17:52 ` Bjorn Helgaas
2022-11-10 1:27 ` Li, Ming
2022-11-10 17:14 ` Bjorn Helgaas
2022-11-11 16:47 ` Jonathan Cameron [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=20221111164717.00002d7e@Huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=bhelgaas@google.com \
--cc=ira.weiny@intel.com \
--cc=linux-pci@vger.kernel.org \
--cc=ming4.li@intel.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).