From: Xiongfeng Wang <wangxiongfeng2@huawei.com>
To: <fbarrat@linux.ibm.com>, <ajd@linux.ibm.com>, <arnd@arndb.de>,
<gregkh@linuxfoundation.org>
Cc: linuxppc-dev@lists.ozlabs.org, wangxiongfeng2@huawei.com,
yangyingliang@huawei.com
Subject: [RFC PATCH] cxl: Use pci_find_vsec_capability() to simplify the code
Date: Fri, 4 Aug 2023 15:56:30 +0800 [thread overview]
Message-ID: <20230804075630.186054-1-wangxiongfeng2@huawei.com> (raw)
PCI core add pci_find_vsec_capability() to query VSEC. We can use that
core API to simplify the code.
The only logical change is that pci_find_vsec_capability check the
Vendor ID before finding the VSEC.
PCI spec rev 5.0 says in 7.9.5.2 Vendor-Specific Header:
VSEC ID - This field is a vendor-defined ID number that indicates the
nature and format of the VSEC structure
Software must qualify the Vendor ID before interpreting this field.
Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
---
drivers/misc/cxl/pci.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
index 0ff944860dda..f3108977755d 100644
--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -150,16 +150,8 @@ static inline resource_size_t p2_size(struct pci_dev *dev)
static int find_cxl_vsec(struct pci_dev *dev)
{
- int vsec = 0;
- u16 val;
-
- while ((vsec = pci_find_next_ext_capability(dev, vsec, PCI_EXT_CAP_ID_VNDR))) {
- pci_read_config_word(dev, vsec + 0x4, &val);
- if (val == CXL_PCI_VSEC_ID)
- return vsec;
- }
- return 0;
-
+ return pci_find_vsec_capability(dev, PCI_VENDOR_ID_IBM,
+ CXL_PCI_VSEC_ID);
}
static void dump_cxl_config_space(struct pci_dev *dev)
--
2.20.1
next reply other threads:[~2023-08-04 8:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-04 7:56 Xiongfeng Wang [this message]
2023-08-07 3:45 ` [RFC PATCH] cxl: Use pci_find_vsec_capability() to simplify the code Andrew Donnellan
2023-08-23 11:55 ` Michael Ellerman
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=20230804075630.186054-1-wangxiongfeng2@huawei.com \
--to=wangxiongfeng2@huawei.com \
--cc=ajd@linux.ibm.com \
--cc=arnd@arndb.de \
--cc=fbarrat@linux.ibm.com \
--cc=gregkh@linuxfoundation.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=yangyingliang@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;
as well as URLs for NNTP newsgroup(s).