From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: "Kobayashi,Daisuke" <kobayashi.da-06@fujitsu.com>
Cc: <kobayashi.da-06@jp.fujitsu.com>, <linux-cxl@vger.kernel.org>,
<y-goto@fujitsu.com>, <mj@ucw.cz>, <dan.j.williams@intel.com>
Subject: Re: [PATCH v13 1/2] cxl/core/regs: Add rcd_pcie_cap initialization
Date: Mon, 17 Jun 2024 17:39:26 +0100 [thread overview]
Message-ID: <20240617173926.00003b84@Huawei.com> (raw)
In-Reply-To: <20240617043702.62028-2-kobayashi.da-06@fujitsu.com>
On Mon, 17 Jun 2024 13:37:01 +0900
"Kobayashi,Daisuke" <kobayashi.da-06@fujitsu.com> wrote:
> Add rcd_pcie_cap and its initialization to cache the offset of cxl1.1
> device link status information. By caching it, avoid the walking
> memory map area to find the offset when output the register value.
>
> Signed-off-by: "Kobayashi,Daisuke" <kobayashi.da-06@fujitsu.com>
Hi.
One minor style change inline. With that done,
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> diff --git a/drivers/cxl/core/regs.c b/drivers/cxl/core/regs.c
> index 372786f80955..a5d1ae09bded 100644
> --- a/drivers/cxl/core/regs.c
> +++ b/drivers/cxl/core/regs.c
> @@ -505,6 +505,67 @@ u16 cxl_rcrb_to_aer(struct device *dev, resource_size_t rcrb)
> return offset;
> }
>
> +resource_size_t cxl_rcrb_to_linkcap(struct device *dev, struct cxl_dport *dport)
> +{
> + resource_size_t rcrb = dport->rcrb.base;
> + void __iomem *addr;
> + u32 cap_hdr;
> + u16 offset;
> +
> + if (!request_mem_region(rcrb, SZ_4K, "CXL RCRB"))
> + return CXL_RESOURCE_NONE;
> +
> + addr = ioremap(rcrb, SZ_4K);
> + if (!addr) {
> + dev_err(dev, "Failed to map region %pr\n", addr);
> + release_mem_region(rcrb, SZ_4K);
> + return CXL_RESOURCE_NONE;
> + }
> +
> + offset = FIELD_GET(PCI_RCRB_CAP_LIST_ID_MASK, readw(addr + PCI_CAPABILITY_LIST));
> + cap_hdr = readl(addr + offset);
> + while ((FIELD_GET(PCI_RCRB_CAP_HDR_ID_MASK, cap_hdr)) != PCI_CAP_ID_EXP) {
> + offset = FIELD_GET(PCI_RCRB_CAP_HDR_NEXT_MASK, cap_hdr);
> + if (offset == 0 || offset > SZ_4K) {
> + offset = 0;
> + break;
> + }
> + cap_hdr = readl(addr + offset);
> + }
> +
> + iounmap(addr);
> + release_mem_region(rcrb, SZ_4K);
> + if (offset > 0)
> + return offset;
> + else
> + return CXL_RESOURCE_NONE;
Have the error handling case first
if (!offset)
return CXL_RESOURCE_NONE;
return offset;
> +}
next prev parent reply other threads:[~2024-06-17 16:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-17 4:37 [PATCH v13 0/2] Export cxl1.1 device link status register value to pci device sysfs Kobayashi,Daisuke
2024-06-17 4:37 ` [PATCH v13 1/2] cxl/core/regs: Add rcd_pcie_cap initialization Kobayashi,Daisuke
2024-06-17 16:39 ` Jonathan Cameron [this message]
2024-06-17 4:37 ` [PATCH v13 2/2] cxl/pci: Add sysfs attribute for CXL 1.1 device link status Kobayashi,Daisuke
2024-07-08 2:59 ` [PATCH v13 0/2] Export cxl1.1 device link status register value to pci device sysfs Daisuke Kobayashi (Fujitsu)
2024-07-08 3:03 ` Daisuke Kobayashi (Fujitsu)
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=20240617173926.00003b84@Huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=dan.j.williams@intel.com \
--cc=kobayashi.da-06@fujitsu.com \
--cc=kobayashi.da-06@jp.fujitsu.com \
--cc=linux-cxl@vger.kernel.org \
--cc=mj@ucw.cz \
--cc=y-goto@fujitsu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.