linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Friedberg <kev.friedberg@gmail.com>
To: linux-raid@vger.kernel.org
Subject: [PATCH] treat AHCI controllers under VMD as part of VMD
Date: Wed, 25 Jan 2023 21:16:59 -0500	[thread overview]
Message-ID: <20230126021659.3801-1-kev.friedberg@gmail.com> (raw)

Detect when a SATA controller has been mapped under Intel Alderlake RST
VMD and list it as part of the domain, instead of independently, so that
it can use the VMD controller's RAID capabilities.

Signed-off-by: Kevin Friedberg <kev.friedberg@gmail.com>
---
 platform-intel.c | 15 +++++++++------
 super-intel.c    | 25 ++++++++++++++++++++++++-
 2 files changed, 33 insertions(+), 7 deletions(-)

diff --git a/platform-intel.c b/platform-intel.c
index 757f0b1b..859bf743 100644
--- a/platform-intel.c
+++ b/platform-intel.c
@@ -64,10 +64,12 @@ struct sys_dev *find_driver_devices(const char *bus, const char *driver)
 
 	if (strcmp(driver, "isci") == 0)
 		type = SYS_DEV_SAS;
-	else if (strcmp(driver, "ahci") == 0)
+	else if (strcmp(driver, "ahci") == 0) {
+		/* if looking for sata devs, ignore vmd */
+		vmd = find_driver_devices("pci", "vmd");
 		type = SYS_DEV_SATA;
-	else if (strcmp(driver, "nvme") == 0) {
-		/* if looking for nvme devs, first look for vmd */
+	} else if (strcmp(driver, "nvme") == 0) {
+		/* if looking for nvme devs, also look for vmd */
 		vmd = find_driver_devices("pci", "vmd");
 		type = SYS_DEV_NVME;
 	} else if (strcmp(driver, "vmd") == 0)
@@ -104,8 +106,8 @@ struct sys_dev *find_driver_devices(const char *bus, const char *driver)
 		sprintf(path, "/sys/bus/%s/drivers/%s/%s",
 			bus, driver, de->d_name);
 
-		/* if searching for nvme - skip vmd connected one */
-		if (type == SYS_DEV_NVME) {
+		/* if searching for nvme or ahci - skip vmd connected one */
+		if (type == SYS_DEV_NVME || type == SYS_DEV_SATA) {
 			struct sys_dev *dev;
 			char *rp = realpath(path, NULL);
 			for (dev = vmd; dev; dev = dev->next) {
@@ -166,7 +168,8 @@ struct sys_dev *find_driver_devices(const char *bus, const char *driver)
 	}
 	closedir(driver_dir);
 
-	if (vmd) {
+	/* VMD adopts multiple types but should only be listed once */
+	if (vmd && type == SYS_DEV_NVME) {
 		if (list)
 			list->next = vmd;
 		else
diff --git a/super-intel.c b/super-intel.c
index 89fac626..4ef8f0d8 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -2680,6 +2680,8 @@ static void print_imsm_capability_export(const struct imsm_orom *orom)
 	printf("IMSM_MAX_VOLUMES_PER_CONTROLLER=%d\n",orom->vphba);
 }
 
+#define PCI_CLASS_AHCI_CNTRL "0x010601"
+
 static int detail_platform_imsm(int verbose, int enumerate_only, char *controller_path)
 {
 	/* There are two components to imsm platform support, the ahci SATA
@@ -2752,11 +2754,32 @@ static int detail_platform_imsm(int verbose, int enumerate_only, char *controlle
 			for (hba = list; hba; hba = hba->next) {
 				if (hba->type == SYS_DEV_VMD) {
 					char buf[PATH_MAX];
+					struct dirent *ent;
+					DIR *dir;
+
 					printf(" I/O Controller : %s (%s)\n",
 						vmd_domain_to_controller(hba, buf), get_sys_dev_type(hba->type));
+					dir = opendir(hba->path);
+					for (ent = readdir(dir); ent; ent = readdir(dir)) {
+						char ent_path[PATH_MAX];
+
+						sprintf(ent_path, "%s/%s", hba->path, ent->d_name);
+						devpath_to_char(ent_path, "class", buf, sizeof(buf), 0);
+						if (strcmp(buf, PCI_CLASS_AHCI_CNTRL) == 0) {
+							host_base = ahci_get_port_count(ent_path, &port_count);
+							if (ahci_enumerate_ports(ent_path, port_count, host_base, verbose)) {
+								if (verbose > 0)
+								pr_err("failed to enumerate ports on VMD SATA controller at %s.\n",
+									hba->pci_id);
+								result |= 2;
+							}
+						}
+					}
+					closedir(dir);
+
 					if (print_nvme_info(hba)) {
 						if (verbose > 0)
-							pr_err("failed to get devices attached to VMD domain.\n");
+							pr_err("failed to get NVMe devices attached to VMD domain.\n");
 						result |= 2;
 					}
 				}
-- 
2.39.0


             reply	other threads:[~2023-01-26  2:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-26  2:16 Kevin Friedberg [this message]
2023-02-01  8:54 ` [PATCH] treat AHCI controllers under VMD as part of VMD Mariusz Tkaczyk
2023-02-05  6:23   ` Kevin Friedberg
2023-02-07  8:44 ` Mariusz Tkaczyk
2023-02-09  0:39   ` Xiao Ni
2023-02-10 10:17     ` Mariusz Tkaczyk
2023-02-13  7:02   ` Kevin Friedberg

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=20230126021659.3801-1-kev.friedberg@gmail.com \
    --to=kev.friedberg@gmail.com \
    --cc=linux-raid@vger.kernel.org \
    /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).