From: Yanfei Xu <yanfei.xu@intel.com>
To: linux-cxl@vger.kernel.org
Cc: dave@stgolabs.net, jonathan.cameron@huawei.com,
dave.jiang@intel.com, alison.schofield@intel.com,
vishal.l.verma@intel.com, ira.weiny@intel.com,
dan.j.williams@intel.com, ming4.li@intel.com,
yanfei.xu@intel.com
Subject: [v3 4/4] cxl/pci: simplify the check of mem_enabled in cxl_hdm_decode_init()
Date: Tue, 13 Aug 2024 19:05:32 +0800 [thread overview]
Message-ID: <20240813110532.870869-5-yanfei.xu@intel.com> (raw)
In-Reply-To: <20240813110532.870869-1-yanfei.xu@intel.com>
Cases can be divided into two categories which are DVSEC range enabled and
not enabled when HDM decoders exist but is not enabled. To avoid checking
info->mem_enabled, which indicates the enablement of DVSEC range, every
time, we can check !info->mem_enabled once in advance. This simplification
can make the code clearer.
No functional change intended.
Signed-off-by: Yanfei Xu <yanfei.xu@intel.com>
---
drivers/cxl/core/pci.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c
index 519989ada48e..be00266c8907 100644
--- a/drivers/cxl/core/pci.c
+++ b/drivers/cxl/core/pci.c
@@ -426,7 +426,15 @@ int cxl_hdm_decode_init(struct cxl_dev_state *cxlds, struct cxl_hdm *cxlhdm,
return -ENODEV;
}
- for (i = 0, allowed = 0; info->mem_enabled && i < info->ranges; i++) {
+ if (!info->mem_enabled) {
+ rc = devm_cxl_enable_hdm(&port->dev, cxlhdm);
+ if (rc)
+ return rc;
+
+ return devm_cxl_enable_mem(&port->dev, cxlds);
+ }
+
+ for (i = 0, allowed = 0; i < info->ranges; i++) {
struct device *cxld_dev;
cxld_dev = device_find_child(&root->dev, &info->dvsec_range[i],
@@ -440,7 +448,7 @@ int cxl_hdm_decode_init(struct cxl_dev_state *cxlds, struct cxl_hdm *cxlhdm,
allowed++;
}
- if (!allowed && info->mem_enabled) {
+ if (!allowed) {
dev_err(dev, "Range register decodes outside platform defined CXL ranges.\n");
return -ENXIO;
}
@@ -454,14 +462,7 @@ int cxl_hdm_decode_init(struct cxl_dev_state *cxlds, struct cxl_hdm *cxlhdm,
* match. If at least one DVSEC range is enabled and allowed, skip HDM
* Decoder Capability Enable.
*/
- if (info->mem_enabled)
- return 0;
-
- rc = devm_cxl_enable_hdm(&port->dev, cxlhdm);
- if (rc)
- return rc;
-
- return devm_cxl_enable_mem(&port->dev, cxlds);
+ return 0;
}
EXPORT_SYMBOL_NS_GPL(cxl_hdm_decode_init, CXL);
--
2.39.2
next prev parent reply other threads:[~2024-08-13 11:13 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-13 11:05 [v3 0/4] Fixes for hdm docoder initialization from DVSEC ranges Yanfei Xu
2024-08-13 11:05 ` [v3 1/4] cxl/pci: Fix to record only non-zero ranges Yanfei Xu
2024-08-27 16:11 ` Jonathan Cameron
2024-08-13 11:05 ` [v3 2/4] cxl/pci: Remove duplicated implementation of waiting for memory_info_valid Yanfei Xu
2024-08-27 16:16 ` Jonathan Cameron
2024-08-28 2:49 ` Yanfei Xu
2024-08-13 11:05 ` [v3 3/4] cxl/pci: Check Mem_info_valid bit for each applicable DVSEC Yanfei Xu
2024-08-27 16:22 ` Jonathan Cameron
2024-08-28 2:54 ` Yanfei Xu
2024-08-13 11:05 ` Yanfei Xu [this message]
2024-08-27 16:25 ` [v3 4/4] cxl/pci: simplify the check of mem_enabled in cxl_hdm_decode_init() Jonathan Cameron
2024-08-27 5:04 ` [v3 0/4] Fixes for hdm docoder initialization from DVSEC ranges Yanfei Xu
2024-08-27 16:08 ` Jonathan Cameron
2024-08-28 2:45 ` Yanfei Xu
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=20240813110532.870869-5-yanfei.xu@intel.com \
--to=yanfei.xu@intel.com \
--cc=alison.schofield@intel.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=ira.weiny@intel.com \
--cc=jonathan.cameron@huawei.com \
--cc=linux-cxl@vger.kernel.org \
--cc=ming4.li@intel.com \
--cc=vishal.l.verma@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