Skip to contentSkip to conversation

sparc64: fix OF path names for sun4v systems

PATCH In review Eric Snowberg 4 participants 9 messages Feb 15, 2016 – Feb 17, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sparc64: fix OF path names for sun4v systems

Fix the open firmware path property for sun4v SPARC systems. These platforms do not have a /sas/ within their path. Over time different OF addressing schemes have been supported. There is no generic addressing scheme that works across every HBA.

---
 grub-core/osdep/linux/ofpath.c |  192 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 190 insertions(+), 2 deletions(-)
grub-core/osdep/linux/ofpath.c +190 -2
index a79682a..de51c57 100644
@@ -336,6 +336,85 @@ vendor_is_ATA(const char *path)
 }
 
 static void
+check_hba_identifiers(const char *sysfs_path, int *vendor, int *device_id)
+{
+  char *ed = strstr (sysfs_path, "host");
+  size_t path_size;
+  char *p, *path;
+  char buf[8];
+  int fd;
+
+  if (!ed)
+    return;
+
+  p = xstrdup (sysfs_path);
+  ed = strstr (p, "host");
+
+  if (!ed)
+    {
+      free (p);
+      return;
+    }
+  *ed = '\0';
+
+  path_size = (strlen (p) + sizeof("vendor"));
+  path = xmalloc (path_size);
+
+  if (!path)
+    {
+      free (p);
+      return;
+    }
+
+  snprintf (path, path_size, "%svendor", p);
+  fd = open (path, O_RDONLY);
+
+  if (fd < 0)
+    {
+      free (p);
+      free (path);
+      return;
+    }
+
+  memset (buf, 0, sizeof (buf));
+
+  if (read (fd, buf, sizeof (buf) - 1) < 0)
+    {
+      close (fd);
+      free (p);
+      free (path);
+      return;
+    }
+
+  close (fd);
+  sscanf (buf, "%x", vendor);
+  snprintf (path, path_size, "%sdevice", p);
+  fd = open (path, O_RDONLY);
+
+  if (fd < 0)
+    {
+      free (p);
+      free (path);
+      return;
+    }
+
+  memset (buf, 0, sizeof (buf));
+
+  if (read (fd, buf, sizeof (buf) - 1) < 0)
+    {
+      close (fd);
+      free (p);
+      free (path);
+      return;
+    }
+
+  close (fd);
+  sscanf (buf, "%x", device_id);
+  free (path);
+  free (p);
+}
+
+static void
 check_sas (const char *sysfs_path, int *tgt, unsigned long int *sas_address)
 {
   char *ed = strstr (sysfs_path, "end_device");
@@ -413,9 +492,11 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev
     }
 
   of_path = find_obppath(sysfs_path);
-  free (sysfs_path);
   if (!of_path)
-    return NULL;
+    {
+      free (sysfs_path);
+      return NULL;
+    }
 
   if (strstr (of_path, "qlc"))
     strcat (of_path, "/fp@0,0");
@@ -444,6 +525,111 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev
     }
   else
     {
+#ifdef __sparc__
+      int vendor = 0, device_id = 0;
+      check_hba_identifiers(sysfs_path, &vendor, &device_id);
+
+      if (vendor == 0x1000) /* LSI Logic Vendor ID */
+        {
+           /* Over time different OF addressing schemes have been supported */
+           /* There is no generic addressing scheme that works across */
+           /* every HBA */
+          switch (device_id)
+            {
+            case 0x30: /* Rhea, Jasper 320, LSI53C1020/1030 */
+            case 0x50: /* SAS-1068E                         */
+            case 0x56: /* SAS-1064E                         */
+            case 0x58: /* Pandora SAS-1068E                 */
+            case 0x5d: /* Aspen, Invader, LSI SAS-3108      */
+            case 0x79: /* Niwot, SAS 2108                   */
+              /* Use Target/lun OF path */
+              if (*digit_string == '\0')
+                {
+                  if ( lun ==  0 )
+                    {
+                      snprintf(disk, sizeof (disk), "/%s@%x", disk_name, tgt);
+                    }
+                  else
+                    {
+                      snprintf(disk, sizeof (disk), "/%s@%x,%x",
+                               disk_name, tgt, lun);
+                    }
+                }
+              else
+                {
+                  int part;
+
+                  sscanf(digit_string, "%d", &part);
+                  if ( lun == 0 )
+                    {
+                      snprintf(disk, sizeof (disk),
+                               "/%s@%x:%c", disk_name, tgt, 'a' + (part - 1));
+                    }
+                  else
+                    {
+                      snprintf(disk, sizeof (disk),
+                               "/%s@%x,%x:%c", disk_name, tgt,
+                               lun, 'a' + (part - 1));
+                    }
+                }
+              break;
+            case 0x72:  /* Erie, Falcon, LSI SAS 2008   */
+            case 0x7e:  /* LSI WarpDrive 6203           */
+            case 0x87:  /* LSI SAS 2308                 */
+            case 0x97:  /* LSI SAS 3008                 */
+            default:
+              if (*digit_string == '\0')
+                {
+                  if ( lun == 0 )
+                    {
+                      /* Use non-standard disk@p<PHY> OF path */
+                      snprintf(disk, sizeof (disk), "/%s@p%x", disk_name, tgt);
+                    }
+                  else
+                    {
+                      /* Use WWN OF path */
+                      snprintf(disk, sizeof (disk), "/%s@w%lx", disk_name,
+                               sas_address);
+                    }
+                }
+              else
+                {
+                  int part;
+
+                  sscanf(digit_string, "%d", &part);
+                  if ( lun == 0)
+                    {
+                      /* Use non-standard disk@p<PHY> OF path */
+                      snprintf(disk, sizeof (disk), "/%s@p%x:%c",
+                               disk_name, tgt, 'a' + (part - 1));
+                    }
+                  else
+                    {
+                        /* Use WWN OF path */
+                        snprintf(disk, sizeof (disk), "/%s@w%lx:%c",
+                                 disk_name, sas_address, 'a' + (part - 1));
+                    }
+                }
+              break;
+            }
+        }
+      else
+        {
+          /* Use Target OF path */
+          if (*digit_string == '\0')
+            {
+              snprintf(disk, sizeof (disk), "/%s@%x", disk_name, tgt);
+            }
+          else
+            {
+              int part;
+
+              sscanf(digit_string, "%d", &part);
+              snprintf(disk, sizeof (disk),
+                       "/%s@%x:%c", disk_name, tgt, 'a' + (part - 1));
+            }
+        }
+#else
       if (lun == 0)
         {
           int sas_id = 0;
@@ -491,7 +677,9 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev
             }
 	  free (lunstr);
         }
+#endif
     }
+  free (sysfs_path);
   strcat(of_path, disk);
   return of_path;
 }
Signature · 1 line
1.7.1
#1 lore raw
Quoted 14 lines · Eric Snowberg

Fix the open firmware path property for sun4v SPARC systems. These platforms do not have a /sas/ within their path. Over time different OF addressing schemes have been supported. There is no generic addressing scheme that works across every HBA.

---
 grub-core/osdep/linux/ofpath.c |  192 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 190 insertions(+), 2 deletions(-)
grub-core/osdep/linux/ofpath.c +0 -0
index a79682a..de51c57 100644

...

Quoted 11 lines
grub-core/osdep/linux/ofpath.c +7 -0
@@ -444,6 +525,111 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev
     }
   else
     {
+#ifdef __sparc__
+      int vendor = 0, device_id = 0;
+      check_hba_identifiers(sysfs_path, &vendor, &device_id);
+
+      if (vendor == 0x1000) /* LSI Logic Vendor ID */
+        {
+           /* Over time different OF addressing schemes have been supported */

grub-core/osdep/linux/ofpath.c of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev · line 544

Quoted 10 lines
grub-core/osdep/linux/ofpath.c +10 -0
+           /* There is no generic addressing scheme that works across */
+           /* every HBA */
+          switch (device_id)
+            {
+            case 0x30: /* Rhea, Jasper 320, LSI53C1020/1030 */
+            case 0x50: /* SAS-1068E                         */
+            case 0x56: /* SAS-1064E                         */
+            case 0x58: /* Pandora SAS-1068E                 */
+            case 0x5d: /* Aspen, Invader, LSI SAS-3108      */
+            case 0x79: /* Niwot, SAS 2108                   */

That really does not scale. Can we enumerate device aliases and take diskN and cdromN? So that we do not need to duplicate OBP logic?

#2 lore raw
Quoted 36 lines · Andrei Borzenkov
Quoted 14 lines · Eric Snowberg

Fix the open firmware path property for sun4v SPARC systems. These platforms do not have a /sas/ within their path. Over time different OF addressing schemes have been supported. There is no generic addressing scheme that works across every HBA.

---
grub-core/osdep/linux/ofpath.c | 192 +++++++++++++++++++++++++++++++++++++++-

1 files changed, 190 insertions(+), 2 deletions(-)
grub-core/osdep/linux/ofpath.c +0 -0
index a79682a..de51c57 100644

...

Quoted 16 lines
grub-core/osdep/linux/ofpath.c +12 -0
@@ -444,6 +525,111 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev
    }
  else
    {
+#ifdef __sparc__
+      int vendor = 0, device_id = 0;
+      check_hba_identifiers(sysfs_path, &vendor, &device_id);
+
+      if (vendor == 0x1000) /* LSI Logic Vendor ID */
+        {
+           /* Over time different OF addressing schemes have been supported */
+           /* There is no generic addressing scheme that works across */
+           /* every HBA */
+          switch (device_id)
+            {
+            case 0x30: /* Rhea, Jasper 320, LSI53C1020/1030 */
Quoted 9 lines

grub-core/osdep/linux/ofpath.c of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev · line 544

Quoted 5 lines
grub-core/osdep/linux/ofpath.c +5 -0
+            case 0x50: /* SAS-1068E                         */
+            case 0x56: /* SAS-1064E                         */
+            case 0x58: /* Pandora SAS-1068E                 */
+            case 0x5d: /* Aspen, Invader, LSI SAS-3108      */
+            case 0x79: /* Niwot, SAS 2108                   */

That really does not scale. Can we enumerate device aliases and take diskN and cdromN? So that we do not need to duplicate OBP logic?

Do you have an idea in mind on how to do this differently to make it scale better? This patch will default to the old disk@N for unknown HBAs. I agree it doesn’t scale that well, but new HBAs for SPARC with OF support don't come out that often.

Before this patch, there isn’t a single SAS HBA that is enumerated correctly on SPARC. I went back 10 years and believe I have added every HBA with OF support. This isn’t duplicating OBP logic. The final part of the device path is vendor specific. OBP does not control that part of the path, it just uses it. Unfortunately there isn’t a standard. This code only gets run during setup/install (not boot) to return the path for OBP to use.

You mentioned cdroms being enumerated with cdromN. I believe that type of enumeration stopped with IDE drives. A USB cdrom would be enumerated something like this:

/pci@308/pci@1/usb@0/hub@1/storage@1/disk@0

So the function that runs during boot: check_string_removable does not identify the cdrom properly.

I’m open to making any changes to this patch if you have some ideas in mind. I tried to base it off of what was already in ofpath.c and I have some follow on patches coming the rely on this path being correct.

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#3 lore raw

17.02.2016 05:02, Eric Snowberg пишет:

Quoted 50 lines
Quoted 36 lines · Andrei Borzenkov
Quoted 14 lines · Eric Snowberg

Fix the open firmware path property for sun4v SPARC systems. These platforms do not have a /sas/ within their path. Over time different OF addressing schemes have been supported. There is no generic addressing scheme that works across every HBA.

---
grub-core/osdep/linux/ofpath.c | 192 +++++++++++++++++++++++++++++++++++++++-

1 files changed, 190 insertions(+), 2 deletions(-)
grub-core/osdep/linux/ofpath.c +0 -0
index a79682a..de51c57 100644

...

Quoted 16 lines
grub-core/osdep/linux/ofpath.c +12 -0
@@ -444,6 +525,111 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev
    }
  else
    {
+#ifdef __sparc__
+      int vendor = 0, device_id = 0;
+      check_hba_identifiers(sysfs_path, &vendor, &device_id);
+
+      if (vendor == 0x1000) /* LSI Logic Vendor ID */
+        {
+           /* Over time different OF addressing schemes have been supported */
+           /* There is no generic addressing scheme that works across */
+           /* every HBA */
+          switch (device_id)
+            {
+            case 0x30: /* Rhea, Jasper 320, LSI53C1020/1030 */
Quoted 9 lines

grub-core/osdep/linux/ofpath.c of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev · line 544

Quoted 5 lines
grub-core/osdep/linux/ofpath.c +5 -0
+            case 0x50: /* SAS-1068E                         */
+            case 0x56: /* SAS-1064E                         */
+            case 0x58: /* Pandora SAS-1068E                 */
+            case 0x5d: /* Aspen, Invader, LSI SAS-3108      */
+            case 0x79: /* Niwot, SAS 2108                   */

That really does not scale. Can we enumerate device aliases and take diskN and cdromN? So that we do not need to duplicate OBP logic?

Do you have an idea in mind on how to do this differently to make it scale better? This patch will default to the old disk@N for unknown HBAs. I agree it doesn’t scale that well, but new HBAs for SPARC with OF support don't come out that often.

Before this patch, there isn’t a single SAS HBA that is enumerated correctly on SPARC. I went back 10 years and believe I have added every HBA with OF support. This isn’t duplicating OBP logic. The final part of the device path is vendor specific. OBP does not control that part of the path, it just uses it. Unfortunately there isn’t a standard. This code only gets run during setup/install (not boot) to return the path for OBP to use.

Quoted 8 lines

You mentioned cdroms being enumerated with cdromN. I believe that type of enumeration stopped with IDE drives. A USB cdrom would be enumerated something like this:

/pci@308/pci@1/usb@0/hub@1/storage@1/disk@0

So the function that runs during boot: check_string_removable does not identify the cdrom properly.

I’m open to making any changes to this patch if you have some ideas in mind. I tried to base it off of what was already in ofpath.c and I have some follow on patches coming the rely on this path being correct.

I mean to read device aliases created by OBP (those displayed by devalias OBP command).

disk0 /pci@308/pci@1/usb@0/hub@1/storage@1/disk@0
...

#4 lore raw
Quoted 57 lines · Andrei Borzenkov

17.02.2016 05:02, Eric Snowberg пишет:

Quoted 56 lines
Quoted 36 lines · Andrei Borzenkov
Quoted 14 lines · Eric Snowberg

Fix the open firmware path property for sun4v SPARC systems. These platforms do not have a /sas/ within their path. Over time different OF addressing schemes have been supported. There is no generic addressing scheme that works across every HBA.

---
grub-core/osdep/linux/ofpath.c | 192 +++++++++++++++++++++++++++++++++++++++-

1 files changed, 190 insertions(+), 2 deletions(-)
grub-core/osdep/linux/ofpath.c +0 -0
index a79682a..de51c57 100644

...

Quoted 16 lines
grub-core/osdep/linux/ofpath.c +12 -0
@@ -444,6 +525,111 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev
    }
  else
    {
+#ifdef __sparc__
+      int vendor = 0, device_id = 0;
+      check_hba_identifiers(sysfs_path, &vendor, &device_id);
+
+      if (vendor == 0x1000) /* LSI Logic Vendor ID */
+        {
+           /* Over time different OF addressing schemes have been supported */
+           /* There is no generic addressing scheme that works across */
+           /* every HBA */
+          switch (device_id)
+            {
+            case 0x30: /* Rhea, Jasper 320, LSI53C1020/1030 */
Quoted 9 lines

grub-core/osdep/linux/ofpath.c of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev · line 544

Quoted 5 lines
grub-core/osdep/linux/ofpath.c +5 -0
+            case 0x50: /* SAS-1068E                         */
+            case 0x56: /* SAS-1064E                         */
+            case 0x58: /* Pandora SAS-1068E                 */
+            case 0x5d: /* Aspen, Invader, LSI SAS-3108      */
+            case 0x79: /* Niwot, SAS 2108                   */

That really does not scale. Can we enumerate device aliases and take diskN and cdromN? So that we do not need to duplicate OBP logic?

Do you have an idea in mind on how to do this differently to make it scale better? This patch will default to the old disk@N for unknown HBAs. I agree it doesn’t scale that well, but new HBAs for SPARC with OF support don't come out that often.

Before this patch, there isn’t a single SAS HBA that is enumerated correctly on SPARC. I went back 10 years and believe I have added every HBA with OF support. This isn’t duplicating OBP logic. The final part of the device path is vendor specific. OBP does not control that part of the path, it just uses it. Unfortunately there isn’t a standard. This code only gets run during setup/install (not boot) to return the path for OBP to use.

You mentioned cdroms being enumerated with cdromN. I believe that type of enumeration stopped with IDE drives. A USB cdrom would be enumerated something like this:

/pci@308/pci@1/usb@0/hub@1/storage@1/disk@0

So the function that runs during boot: check_string_removable does not identify the cdrom properly.

Quoted 8 lines
Quoted 2 lines

I’m open to making any changes to this patch if you have some ideas in mind. I tried to base it off of what was already in ofpath.c and I have some follow on patches coming the rely on this path being correct.

I mean to read device aliases created by OBP (those displayed by devalias OBP command).

disk0 /pci@308/pci@1/usb@0/hub@1/storage@1/disk@0
...

Here is example

    Node 0xf022d638
        screen:  '/pci@400/pci@1/pci@0/pci@7/pci@0/display@0'
        mouse:
'/pci@400/pci@1/pci@0/pci@8/pci@0/usb@0,2/hub@2/device@4/mouse@1'
        disk7:  '/pci@700/pci@1/pci@0/pci@0/@0/disk@p3'
        disk6:  '/pci@700/pci@1/pci@0/pci@0/@0/disk@p2'
        disk5:  '/pci@700/pci@1/pci@0/pci@0/@0/disk@p1'
        disk4:  '/pci@700/pci@1/pci@0/pci@0/@0/disk@p0'
        scsi1:  '/pci@700/pci@1/pci@0/pci@0/@0'
        net3:  '/pci@600/pci@2/pci@0/pci@3/network@0,1'
        net2:  '/pci@600/pci@2/pci@0/pci@3/network@0'
        rcdrom:
'/pci@400/pci@1/pci@0/pci@8/pci@0/usb@0,2/hub@2/hub@3/storage@2/disk@0'
        rkeyboard:
'/pci@400/pci@1/pci@0/pci@8/pci@0/usb@0,2/hub@2/device@4/keyboard@0'
        rscreen:  '/pci@400/pci@1/pci@0/pci@7/pci@0/display@0:r1280x1024x60'
        net1:  '/pci@400/pci@1/pci@0/pci@2/network@0,1'
        net0:  '/pci@400/pci@1/pci@0/pci@2/network@0'
        net:  '/pci@400/pci@1/pci@0/pci@2/network@0'
        disk3:  '/pci@400/pci@1/pci@0/pci@0/@0/disk@p3'
        disk2:  '/pci@400/pci@1/pci@0/pci@0/@0/disk@p2'
        disk1:  '/pci@400/pci@1/pci@0/pci@0/@0/disk@p1'
        disk0:  '/pci@400/pci@1/pci@0/pci@0/@0/disk@p0'
        disk:  '/pci@400/pci@1/pci@0/pci@0/@0/disk@p0'
        scsi0:  '/pci@400/pci@1/pci@0/pci@0/@0'
        scsi:  '/pci@400/pci@1/pci@0/pci@0/@0'
        virtual-console:  '/virtual-devices@100/console@1'
        name:  'aliases'
#5 lore raw
Quoted 92 lines · Andrei Borzenkov
Quoted 57 lines · Andrei Borzenkov

17.02.2016 05:02, Eric Snowberg пишет:

Quoted 56 lines
Quoted 36 lines · Andrei Borzenkov
Quoted 14 lines · Eric Snowberg

Fix the open firmware path property for sun4v SPARC systems. These platforms do not have a /sas/ within their path. Over time different OF addressing schemes have been supported. There is no generic addressing scheme that works across every HBA.

---
grub-core/osdep/linux/ofpath.c | 192 +++++++++++++++++++++++++++++++++++++++-

1 files changed, 190 insertions(+), 2 deletions(-)
grub-core/osdep/linux/ofpath.c +0 -0
index a79682a..de51c57 100644

...

Quoted 16 lines
grub-core/osdep/linux/ofpath.c +12 -0
@@ -444,6 +525,111 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev
   }
 else
   {
+#ifdef __sparc__
+      int vendor = 0, device_id = 0;
+      check_hba_identifiers(sysfs_path, &vendor, &device_id);
+
+      if (vendor == 0x1000) /* LSI Logic Vendor ID */
+        {
+           /* Over time different OF addressing schemes have been supported */
+           /* There is no generic addressing scheme that works across */
+           /* every HBA */
+          switch (device_id)
+            {
+            case 0x30: /* Rhea, Jasper 320, LSI53C1020/1030 */
Quoted 9 lines

grub-core/osdep/linux/ofpath.c of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev · line 544

Quoted 5 lines
grub-core/osdep/linux/ofpath.c +5 -0
+            case 0x50: /* SAS-1068E                         */
+            case 0x56: /* SAS-1064E                         */
+            case 0x58: /* Pandora SAS-1068E                 */
+            case 0x5d: /* Aspen, Invader, LSI SAS-3108      */
+            case 0x79: /* Niwot, SAS 2108                   */

That really does not scale. Can we enumerate device aliases and take diskN and cdromN? So that we do not need to duplicate OBP logic?

Do you have an idea in mind on how to do this differently to make it scale better? This patch will default to the old disk@N for unknown HBAs. I agree it doesn’t scale that well, but new HBAs for SPARC with OF support don't come out that often.

Before this patch, there isn’t a single SAS HBA that is enumerated correctly on SPARC. I went back 10 years and believe I have added every HBA with OF support. This isn’t duplicating OBP logic. The final part of the device path is vendor specific. OBP does not control that part of the path, it just uses it. Unfortunately there isn’t a standard. This code only gets run during setup/install (not boot) to return the path for OBP to use.

You mentioned cdroms being enumerated with cdromN. I believe that type of enumeration stopped with IDE drives. A USB cdrom would be enumerated something like this:

/pci@308/pci@1/usb@0/hub@1/storage@1/disk@0

So the function that runs during boot: check_string_removable does not identify the cdrom properly.

Quoted 8 lines
Quoted 2 lines

I’m open to making any changes to this patch if you have some ideas in mind. I tried to base it off of what was already in ofpath.c and I have some follow on patches coming the rely on this path being correct.

I mean to read device aliases created by OBP (those displayed by devalias OBP command).

disk0 /pci@308/pci@1/usb@0/hub@1/storage@1/disk@0
...

Here is example

   Node 0xf022d638
       screen:  '/pci@400/pci@1/pci@0/pci@7/pci@0/display@0'
       mouse:
'/pci@400/pci@1/pci@0/pci@8/pci@0/usb@0,2/hub@2/device@4/mouse@1'
       disk7:  '/pci@700/pci@1/pci@0/pci@0/@0/disk@p3'
       disk6:  '/pci@700/pci@1/pci@0/pci@0/@0/disk@p2'
       disk5:  '/pci@700/pci@1/pci@0/pci@0/@0/disk@p1'
       disk4:  '/pci@700/pci@1/pci@0/pci@0/@0/disk@p0'
       scsi1:  '/pci@700/pci@1/pci@0/pci@0/@0'
       net3:  '/pci@600/pci@2/pci@0/pci@3/network@0,1'
       net2:  '/pci@600/pci@2/pci@0/pci@3/network@0'
       rcdrom:
'/pci@400/pci@1/pci@0/pci@8/pci@0/usb@0,2/hub@2/hub@3/storage@2/disk@0'
       rkeyboard:
'/pci@400/pci@1/pci@0/pci@8/pci@0/usb@0,2/hub@2/device@4/keyboard@0'
       rscreen:  '/pci@400/pci@1/pci@0/pci@7/pci@0/display@0:r1280x1024x60'
       net1:  '/pci@400/pci@1/pci@0/pci@2/network@0,1'
       net0:  '/pci@400/pci@1/pci@0/pci@2/network@0'
       net:  '/pci@400/pci@1/pci@0/pci@2/network@0'
       disk3:  '/pci@400/pci@1/pci@0/pci@0/@0/disk@p3'
Quoted 9 lines
       disk2:  '/pci@400/pci@1/pci@0/pci@0/@0/disk@p2'
       disk1:  '/pci@400/pci@1/pci@0/pci@0/@0/disk@p1'
       disk0:  '/pci@400/pci@1/pci@0/pci@0/@0/disk@p0'
       disk:  '/pci@400/pci@1/pci@0/pci@0/@0/disk@p0'
       scsi0:  '/pci@400/pci@1/pci@0/pci@0/@0'
       scsi:  '/pci@400/pci@1/pci@0/pci@0/@0'
       virtual-console:  '/virtual-devices@100/console@1'
       name:  ‘aliases'

With the example provided, the current code in ofpath.c, will not correctly enumerate any of those drives.

To prove this, simply run grub-ofpathname /dev/sd<n> on your machine.

Then look at what follows disk@. I’m sure you will not see the “p”. Therefore the wrong path is placed in grub.cfg and in core.img.

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#6 lore raw
In reply to Andrei Borzenkov
Quoted 58 lines · Andrei Borzenkov

17.02.2016 05:02, Eric Snowberg пишет:

Quoted 53 lines
Quoted 36 lines · Andrei Borzenkov
Quoted 14 lines · Eric Snowberg

Fix the open firmware path property for sun4v SPARC systems. These platforms do not have a /sas/ within their path. Over time different OF addressing schemes have been supported. There is no generic addressing scheme that works across every HBA.

---
grub-core/osdep/linux/ofpath.c | 192 +++++++++++++++++++++++++++++++++++++++-

1 files changed, 190 insertions(+), 2 deletions(-)
grub-core/osdep/linux/ofpath.c +0 -0
index a79682a..de51c57 100644

...

Quoted 16 lines
grub-core/osdep/linux/ofpath.c +12 -0
@@ -444,6 +525,111 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev
   }
 else
   {
+#ifdef __sparc__
+      int vendor = 0, device_id = 0;
+      check_hba_identifiers(sysfs_path, &vendor, &device_id);
+
+      if (vendor == 0x1000) /* LSI Logic Vendor ID */
+        {
+           /* Over time different OF addressing schemes have been supported */
+           /* There is no generic addressing scheme that works across */
+           /* every HBA */
+          switch (device_id)
+            {
+            case 0x30: /* Rhea, Jasper 320, LSI53C1020/1030 */
Quoted 8 lines

grub-core/osdep/linux/ofpath.c of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev · line 544

Quoted 5 lines
grub-core/osdep/linux/ofpath.c +5 -0
+            case 0x50: /* SAS-1068E                         */
+            case 0x56: /* SAS-1064E                         */
+            case 0x58: /* Pandora SAS-1068E                 */
+            case 0x5d: /* Aspen, Invader, LSI SAS-3108      */
+            case 0x79: /* Niwot, SAS 2108                   */

That really does not scale. Can we enumerate device aliases and take diskN and cdromN? So that we do not need to duplicate OBP logic?

Do you have an idea in mind on how to do this differently to make it scale better? This patch will default to the old disk@N for unknown HBAs. I agree it doesn’t scale that well, but new HBAs for SPARC with OF support don't come out that often.

Before this patch, there isn’t a single SAS HBA that is enumerated correctly on SPARC. I went back 10 years and believe I have added every HBA with OF support. This isn’t duplicating OBP logic. The final part of the device path is vendor specific. OBP does not control that part of the path, it just uses it. Unfortunately there isn’t a standard. This code only gets run during setup/install (not boot) to return the path for OBP to use.

You mentioned cdroms being enumerated with cdromN. I believe that type of enumeration stopped with IDE drives. A USB cdrom would be enumerated something like this:

/pci@308/pci@1/usb@0/hub@1/storage@1/disk@0

Quoted 8 lines
Quoted 3 lines

So the function that runs during boot: check_string_removable does not identify the cdrom properly.

I’m open to making any changes to this patch if you have some ideas in mind. I tried to base it off of what was already in ofpath.c and I have some follow on patches coming the rely on this path being correct.

I mean to read device aliases created by OBP (those displayed by devalias OBP command).

disk0 /pci@308/pci@1/usb@0/hub@1/storage@1/disk@0

Devaliases are not guaranteed to be there for all devices. It is highly dependent on the system vendor to create them and we certainly have systems with disk drives that have no aliases.

--S

Quoted 6 lines

...

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#7 lore raw
Quoted 7 lines · Seth Goldberg
Quoted 2 lines

disk0 /pci@308/pci@1/usb@0/hub@1/storage@1/disk@0

Devaliases are not guaranteed to be there for all devices. It is highly dependent on the system vendor to create them and we certainly have systems with disk drives that have no aliases.

guest LDOMS do not have aliases set up, unless admin will create them.

rgds,
toomas

#8 lore raw
In reply to Seth Goldberg
Quoted 65 lines · Seth Goldberg
Quoted 63 lines · Andrei Borzenkov

17.02.2016 05:02, Eric Snowberg пишет:

Quoted 56 lines
Quoted 36 lines · Andrei Borzenkov
Quoted 14 lines · Eric Snowberg

Fix the open firmware path property for sun4v SPARC systems. These platforms do not have a /sas/ within their path. Over time different OF addressing schemes have been supported. There is no generic addressing scheme that works across every HBA.

---
grub-core/osdep/linux/ofpath.c | 192 +++++++++++++++++++++++++++++++++++++++-

1 files changed, 190 insertions(+), 2 deletions(-)
grub-core/osdep/linux/ofpath.c +0 -0
index a79682a..de51c57 100644

...

Quoted 16 lines
grub-core/osdep/linux/ofpath.c +0 -0
@@ -444,6 +525,111 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev
  }

else
{

grub-core/osdep/linux/ofpath.c +12 -0
+#ifdef __sparc__
+      int vendor = 0, device_id = 0;
+      check_hba_identifiers(sysfs_path, &vendor, &device_id);
+
+      if (vendor == 0x1000) /* LSI Logic Vendor ID */
+        {
+           /* Over time different OF addressing schemes have been supported */
+           /* There is no generic addressing scheme that works across */
+           /* every HBA */
+          switch (device_id)
+            {
+            case 0x30: /* Rhea, Jasper 320, LSI53C1020/1030 */
Quoted 8 lines

grub-core/osdep/linux/ofpath.c of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev · line 544

Quoted 5 lines
grub-core/osdep/linux/ofpath.c +5 -0
+            case 0x50: /* SAS-1068E                         */
+            case 0x56: /* SAS-1064E                         */
+            case 0x58: /* Pandora SAS-1068E                 */
+            case 0x5d: /* Aspen, Invader, LSI SAS-3108      */
+            case 0x79: /* Niwot, SAS 2108                   */

That really does not scale. Can we enumerate device aliases and take diskN and cdromN? So that we do not need to duplicate OBP logic?

Do you have an idea in mind on how to do this differently to make it scale better? This patch will default to the old disk@N for unknown HBAs. I agree it doesn’t scale that well, but new HBAs for SPARC with OF support don't come out that often.

Before this patch, there isn’t a single SAS HBA that is enumerated correctly on SPARC. I went back 10 years and believe I have added every HBA with OF support. This isn’t duplicating OBP logic. The final part of the device path is vendor specific. OBP does not control that part of the path, it just uses it. Unfortunately there isn’t a standard. This code only gets run during setup/install (not boot) to return the path for OBP to use.

You mentioned cdroms being enumerated with cdromN. I believe that type of enumeration stopped with IDE drives. A USB cdrom would be enumerated something like this:

/pci@308/pci@1/usb@0/hub@1/storage@1/disk@0

So the function that runs during boot: check_string_removable does not identify the cdrom properly.

I’m open to making any changes to this patch if you have some ideas in mind. I tried to base it off of what was already in ofpath.c and I have some follow on patches coming the rely on this path being correct.

Quoted 8 lines
Quoted 4 lines

I mean to read device aliases created by OBP (those displayed by devalias OBP command).

disk0 /pci@308/pci@1/usb@0/hub@1/storage@1/disk@0

Devaliases are not guaranteed to be there for all devices. It is highly dependent on the system vendor to create them and we certainly have systems with disk drives that have no aliases.

—S

And we also have systems with pre-populated devaliases for disks that don’t exist (that could be added in the future). This is part of the reason why it can take 20 - 30 minutes to get to the grub menu on some SPARC systems. On boot, grub builds a tree from the devaliases and then tries to open and close disks that don’t exist. The HBA finally times out.

But we are getting ahead of things here, since the patch I submitted only starts to solve this problem. This will be fixed in later patches.

Quoted 14 lines
Quoted 9 lines

...

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel