Blame SOURCES/mdadm-3.2.6-imsm-improved-platform-capabilities-checking.patch

fc6001
From d71612d0bdfa0da58261b970a5188c98b1412c6e Mon Sep 17 00:00:00 2001
fc6001
From: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
fc6001
Date: Fri, 28 Feb 2014 11:29:28 +0100
fc6001
Subject: [PATCH 2/2] imsm: improved platform capabilities checking
fc6001
fc6001
This patch ensures that on Intel platforms only AHCI controllers with
fc6001
RAID mode enabled are seen as IMSM capable by mdadm.
fc6001
fc6001
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
fc6001
Reviewed-by: Lukasz Dorau <lukasz.dorau@intel.com>
fc6001
---
fc6001
 platform-intel.c | 16 +++++++++++++---
fc6001
 platform-intel.h |  3 ++-
fc6001
 super-intel.c    | 13 ++++++-------
fc6001
 3 files changed, 21 insertions(+), 11 deletions(-)
fc6001
fc6001
diff --git a/platform-intel.c b/platform-intel.c
fc6001
index 77f8639..3d4d9c7 100644
fc6001
--- a/platform-intel.c
fc6001
+++ b/platform-intel.c
fc6001
@@ -59,6 +59,7 @@ struct sys_dev *find_driver_devices(const char *bus, const char *driver)
fc6001
 	struct sys_dev *list = NULL;
fc6001
 	enum sys_dev_type type;
fc6001
 	unsigned long long dev_id;
fc6001
+	unsigned long long class;
fc6001
 
fc6001
 	if (strcmp(driver, "isci") == 0)
fc6001
 		type = SYS_DEV_SAS;
fc6001
@@ -99,6 +100,9 @@ struct sys_dev *find_driver_devices(const char *bus, const char *driver)
fc6001
 		if (devpath_to_ll(path, "device", &dev_id) != 0)
fc6001
 			continue;
fc6001
 
fc6001
+		if (devpath_to_ll(path, "class", &class) != 0)
fc6001
+			continue;
fc6001
+
fc6001
 		/* start / add list entry */
fc6001
 		if (!head) {
fc6001
 			head = malloc(sizeof(*head));
fc6001
@@ -114,6 +118,7 @@ struct sys_dev *find_driver_devices(const char *bus, const char *driver)
fc6001
 		}
fc6001
 
fc6001
 		list->dev_id = (__u16) dev_id;
fc6001
+		list->class = (__u32) class;
fc6001
 		list->type = type;
fc6001
 		list->path = canonicalize_file_name(path);
fc6001
 		list->next = NULL;
fc6001
@@ -348,6 +353,8 @@ static const struct imsm_orom *find_imsm_hba_orom(enum sys_dev_type hba_id)
fc6001
 #define VENDOR_GUID \
fc6001
 	EFI_GUID(0x193dfefa, 0xa445, 0x4302, 0x99, 0xd8, 0xef, 0x3a, 0xad, 0x1a, 0x04, 0xc6)
fc6001
 
fc6001
+#define PCI_CLASS_RAID_CNTRL 0x010400
fc6001
+
fc6001
 int populated_efi[SYS_DEV_MAX] = { 0, 0 };
fc6001
 
fc6001
 static struct imsm_orom imsm_efi[SYS_DEV_MAX];
fc6001
@@ -445,14 +452,16 @@ const struct imsm_orom *find_imsm_orom(void)
fc6001
 	return find_imsm_hba_orom(SYS_DEV_SATA);
fc6001
 }
fc6001
 
fc6001
-const struct imsm_orom *find_imsm_capability(enum sys_dev_type hba_id)
fc6001
+const struct imsm_orom *find_imsm_capability(struct sys_dev *hba)
fc6001
 {
fc6001
 	const struct imsm_orom *cap=NULL;
fc6001
 
fc6001
-
fc6001
-	if ((cap = find_imsm_efi(hba_id)) != NULL)
fc6001
+	if (hba->type == SYS_DEV_SATA && hba->class != PCI_CLASS_RAID_CNTRL)
fc6001
+		return NULL;
fc6001
+
fc6001
+	if ((cap = find_imsm_efi(hba->type)) != NULL)
fc6001
 		return cap;
fc6001
-	if ((cap = find_imsm_hba_orom(hba_id)) != NULL)
fc6001
+	if ((cap = find_imsm_hba_orom(hba->type)) != NULL)
fc6001
 		return cap;
fc6001
 	return NULL;
fc6001
 }
fc6001
diff --git a/platform-intel.h b/platform-intel.h
fc6001
index bcd84b7..6887097 100644
fc6001
--- a/platform-intel.h
fc6001
+++ b/platform-intel.h
fc6001
@@ -180,6 +180,7 @@ struct sys_dev {
fc6001
 	char *path;
fc6001
 	char *pci_id;
fc6001
 	__u16  dev_id;
fc6001
+	__u32  class;
fc6001
 	struct sys_dev *next;
fc6001
 };
fc6001
 
fc6001
@@ -202,9 +202,9 @@ static inline char *guid_str(char *buf, struct efi_guid guid)
fc6001
 char *diskfd_to_devpath(int fd);
fc6001
 struct sys_dev *find_driver_devices(const char *bus, const char *driver);
fc6001
 struct sys_dev *find_intel_devices(void);
fc6001
 void free_sys_dev(struct sys_dev **list);
fc6001
-const struct imsm_orom *find_imsm_capability(enum sys_dev_type hba_id);
fc6001
+const struct imsm_orom *find_imsm_capability(struct sys_dev *hba);
fc6001
 const struct imsm_orom *find_imsm_orom(void);
fc6001
 int disk_attached_to_hba(int fd, const char *hba_path);
fc6001
 char *devt_to_devpath(dev_t dev);
fc6001
 int path_attached_to_hba(const char *disk_path, const char *hba_path);
fc6001
diff --git a/super-intel.c b/super-intel.c
fc6001
index f0a7ab5..b21fe67 100644
fc6001
--- a/super-intel.c
fc6001
+++ b/super-intel.c
fc6001
@@ -1886,12 +1886,13 @@ static int detail_platform_imsm(int verbose, int enumerate_only, char *controlle
fc6001
 		if (!list)
fc6001
 			return 2;
fc6001
 		for (hba = list; hba; hba = hba->next) {
fc6001
-			orom = find_imsm_capability(hba->type);
fc6001
-			if (!orom) {
fc6001
-				result = 2;
fc6001
+			if (find_imsm_capability(hba)) {
fc6001
+				result = 0;
fc6001
 				break;
fc6001
 			}
fc6001
+ 			else
fc6001
+				result = 2;
fc6001
 		}
fc6001
 		free_sys_dev(&list);
fc6001
 		return result;
fc6001
 	}
fc6001
@@ -1909,7 +1908,7 @@ static int detail_platform_imsm(int verbose, int enumerate_only, char *controlle
fc6001
 		print_found_intel_controllers(list);
fc6001
 
fc6001
 	for (hba = list; hba; hba = hba->next) {
fc6001
-		orom = find_imsm_capability(hba->type);
fc6001
+		orom = find_imsm_capability(hba);
fc6001
 		if (!orom)
fc6001
 			fprintf(stderr, Name ": imsm capabilities not found for controller: %s (type %s)\n",
fc6001
 				hba->path, get_sys_dev_type(hba->type));
fc6001
@@ -3839,9 +3838,9 @@ static int find_intel_hba_capability(int fd, struct intel_super *super, char *de
fc6001
 		}
fc6001
 		free_sys_dev(&hba_name);
fc6001
 		return 2;
fc6001
 	}
fc6001
-	super->orom = find_imsm_capability(hba_name->type);
fc6001
+	super->orom = find_imsm_capability(hba_name);
fc6001
 	free_sys_dev(&hba_name);
fc6001
 	if (!super->orom)
fc6001
 		return 3;
fc6001
 	return 0;