lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210407222625.320177-7-ben.widawsky@intel.com>
Date:   Wed,  7 Apr 2021 15:26:24 -0700
From:   Ben Widawsky <ben.widawsky@...el.com>
To:     linux-cxl@...r.kernel.org
Cc:     Ben Widawsky <ben.widawsky@...el.com>, linux-pci@...r.kernel.org,
        linux-acpi@...r.kernel.org, ira.weiny@...el.com,
        vishal.l.verma@...el.com, alison.schofield@...el.com,
        dan.j.williams@...el.com, linux-kernel@...r.kernel.org
Subject: [PATCH 6/7] cxl/mem: Create a helper to setup device regs

Memory devices have a list of required register regions within the
register block, but this isn't required of all CXL components or
devices. To make things more tidy, and allow for easily setting up other
block types in this loop, the helper is introduced.

Signed-off-by: Ben Widawsky <ben.widawsky@...el.com>
---
 drivers/cxl/mem.c | 38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c
index 49f651694cb0..b7342aaf38c4 100644
--- a/drivers/cxl/mem.c
+++ b/drivers/cxl/mem.c
@@ -974,6 +974,24 @@ static int cxl_mem_dvsec(struct pci_dev *pdev, int dvsec)
 	return 0;
 }
 
+static int __cxl_setup_device_regs(struct cxl_mem *cxlm, void __iomem *base)
+{
+	struct cxl_regs *regs = &cxlm->regs;
+	struct pci_dev *pdev = cxlm->pdev;
+	struct device *dev = &pdev->dev;
+
+	cxl_setup_device_regs(dev, base, &regs->device_regs);
+	if (!regs->status || !regs->mbox || !regs->memdev) {
+		dev_err(dev, "registers not found: %s%s%s\n",
+				!regs->status ? "status " : "",
+				!regs->mbox ? "mbox " : "",
+				!regs->memdev ? "memdev" : "");
+		return -ENXIO;
+	}
+
+	return 0;
+}
+
 /**
  * cxl_mem_setup_regs() - Setup necessary MMIO.
  * @cxlm: The CXL memory device to communicate with.
@@ -986,12 +1004,11 @@ static int cxl_mem_dvsec(struct pci_dev *pdev, int dvsec)
  */
 static int cxl_mem_setup_regs(struct cxl_mem *cxlm)
 {
-	struct cxl_regs *regs = &cxlm->regs;
 	struct pci_dev *pdev = cxlm->pdev;
 	struct device *dev = &pdev->dev;
 	u32 regloc_size, regblocks;
 	void __iomem *base;
-	int regloc, i;
+	int regloc, i, rc;
 
 	regloc = cxl_mem_dvsec(pdev, PCI_DVSEC_ID_CXL_REGLOC_OFFSET);
 	if (!regloc) {
@@ -1021,23 +1038,14 @@ static int cxl_mem_setup_regs(struct cxl_mem *cxlm)
 			if (IS_ERR(base))
 				return PTR_ERR(base);
 
-			cxl_setup_device_regs(dev, base, &regs->device_regs);
-			if (!regs->status || !regs->mbox || !regs->memdev) {
-				dev_err(dev, "registers not found: %s%s%s\n",
-						!regs->status ? "status " : "",
-						!regs->mbox ? "mbox " : "",
-						!regs->memdev ? "memdev" : "");
-				return -ENXIO;
-			}
+			rc = __cxl_setup_device_regs(cxlm, base);
+			if (rc)
+				return rc;
+
 			break;
 		}
 	}
 
-	if (i == regblocks) {
-		dev_err(dev, "Missing register locator for device registers\n");
-		return -ENXIO;
-	}
-
 	return 0;
 }
 
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ