[PATCH]: Add support for Apple Power Mac

classic Classic list List threaded Threaded
23 messages Options
12
Reply | Threaded
Open this post in threaded view
|

[PATCH]: Add support for Apple Power Mac

John Paul Adrian Glaubitz
Hi!

The following three patches are required to get ofpathname to return
proper OF paths on Apple Power Macs.

The first patch adds adding the partition number to the end of the
OpenFirmware path when the logical device node points to a partition
instead of the whole disk.

The second patch adds support for differentiating between multiple
plugs of a SATA host. This is necessary for differentiating multiple
SATA drives on the Power Mac G5, for example.

And the third patch omits the strings "disk" and "scsi" when printing
OpenFirmware paths on a Power Mac.

With these changes applied, ofpathname returns the same OF paths
as Yaboot's ofpath script from the last Debian package which
is known to produce OF pathnames understood by the OpenFirmware
implemenation found on Power Macs.

Thanks,
Adrian


Reply | Threaded
Open this post in threaded view
|

[PATCH 1/3] ofpathname: Add partition support to l2of_ide() and l2of_scsi()

John Paul Adrian Glaubitz
Currently, only l2of_nvme() supports handling of partitions which
will print the partition number at the end of an OF path. However,
this feature is also useful for IDE and SCSI targets as well and
mandatory for Macintosh systems.

Signed-off-by: John Paul Adrian Glaubitz <[hidden email]>
---
 scripts/ofpathname | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/scripts/ofpathname b/scripts/ofpathname
index c37c6bd..0e58005 100755
--- a/scripts/ofpathname
+++ b/scripts/ofpathname
@@ -519,6 +519,13 @@ l2of_ide()
     if [[ -z $link ]]; then
         err $ERR_NO_SYSFS_DEVINFO
     fi
+
+    # partition number: N in sd*N
+    local devpart="${DEVICE##*[a-z]}"
+    if [[ $devpart = $DEVICE ]]; then
+        devpart='' # no partition number
+    fi
+
     cd $link
 
     # get the device number
@@ -584,6 +591,13 @@ l2of_vd()
     if [[ -z $OF_PATH ]]; then
         err $ERR_NO_OFPATH
     fi
+
+    # No partition specified.
+    if [[ -z $devpart ]]; then
+        return
+    fi
+
+    OF_PATH="${OF_PATH}:${devpart}"
 }
 
 #
@@ -786,6 +800,12 @@ l2of_scsi()
         err $ERR_NOT_CONFIG
     fi
 
+    # partition number: N in sd*N
+    local devpart="${DEVICE##*[a-z]}"
+    if [[ $devpart = $DEVICE ]]; then
+        devpart='' # no partition number
+    fi
+
     # follow the 'device' link
     local link=`get_link "device"`
     if [[ -z $link ]]; then
@@ -944,6 +964,13 @@ l2of_scsi()
              OF_PATH=$OF_PATH/sd@$ID,$LUN
        fi
     fi
+
+    # No partition specified.
+    if [[ -z $devpart ]]; then
+        return
+    fi
+
+    OF_PATH="${OF_PATH}:${devpart}"
 }
 
 #
--
2.26.1

Reply | Threaded
Open this post in threaded view
|

[PATCH 2/3] ofpathname: Add support for the plug ID of a SCSI/SATA host

John Paul Adrian Glaubitz
In reply to this post by John Paul Adrian Glaubitz
Signed-off-by: John Paul Adrian Glaubitz <[hidden email]>
---
 scripts/ofpathname | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/scripts/ofpathname b/scripts/ofpathname
index 0e58005..fe50781 100755
--- a/scripts/ofpathname
+++ b/scripts/ofpathname
@@ -824,6 +824,7 @@ l2of_scsi()
     goto_dir $PWD "devspec"
 
     OF_PATH=`$CAT $PWD/devspec`
+    SYS_PATH=$PWD
     if [[ -z $OF_PATH ]]; then
         err $ERR_NO_OFPATH
     fi
@@ -942,6 +943,13 @@ l2of_scsi()
             fi
  fi
     else
+
+        plug_id=$(ls -dv $SYS_PATH/*/host* 2>/dev/null | grep -n "/host$HOST$")
+        [ -z "$plug_id" ] && {
+                plug_id=$(ls -dv $SYS_PATH/host* 2>/dev/null | grep -n "/host$HOST$")
+        }
+        plug_id=$((${plug_id%%:*}-1))
+
         # make sure the "scsi" information is on the end of the path
         local scsi_name=${OF_PATH##/*/}
         scsi_name=${scsi_name%%@*}
--
2.26.1

Reply | Threaded
Open this post in threaded view
|

[PATCH 3/3] ofpathname: Add support for Mac-compatible OF pathnames

John Paul Adrian Glaubitz
In reply to this post by John Paul Adrian Glaubitz
On Macintosh systems, OpenFirmware path follow a slightly
different syntax as compared to other OF systems. In particular,
the disk ID is not preceeded by the string "disk" and - on
SATA systems - the path does not contain the BUS ID as
"scsi@ID" but rather the plug ID in the form "@ID".

Signed-off-by: John Paul Adrian Glaubitz <[hidden email]>
---
 scripts/ofpathname | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/scripts/ofpathname b/scripts/ofpathname
index fe50781..7011ca5 100755
--- a/scripts/ofpathname
+++ b/scripts/ofpathname
@@ -37,6 +37,8 @@ PSERIES_PLATFORM=$(dirname $0)/pseries_platform
 PLATFORM=$(sed /proc/cpuinfo -ne "s/^machine\t*: \(.*\)/\1/p")
 case $PLATFORM in
     EFIKA5K2\ *) PLATFORM=efika ;;
+    PowerBook*) PLATFORM=mac ;;
+    PowerMac*) PLATFORM=mac ;;
 esac
 
 # Usage statemnet
@@ -554,7 +556,11 @@ l2of_ide()
         devno=0,0
     fi
 
-    OF_PATH=$OF_PATH/disk@$devno
+    if [ "$PLATFORM" = "mac" ] ; then
+        OF_PATH=$OF_PATH/@$devno
+    else
+        OF_PATH=$OF_PATH/disk@$devno
+    fi
 }
 
 #
@@ -953,9 +959,12 @@ l2of_scsi()
         # make sure the "scsi" information is on the end of the path
         local scsi_name=${OF_PATH##/*/}
         scsi_name=${scsi_name%%@*}
-        if [[ $scsi_name != "scsi" ]]; then
+        if [[ $scsi_name != "scsi" && "$PLATFORM" != "mac" ]]; then
             scsi_name="scsi@$BUS"
             OF_PATH=$OF_PATH/$scsi_name
+        elif [[ $scsi_name != "scsi" && "$PLATFORM" = "mac" && $devtype != "ata" ]]; then
+            scsi_name="@$plug_id"
+            OF_PATH=$OF_PATH/$scsi_name
         fi
 
         local modalias=""
@@ -969,7 +978,11 @@ l2of_scsi()
              diskno=`get_scsi_disk_no $device_dir`
              OF_PATH=$OF_PATH/disk\@$diskno
         else
-             OF_PATH=$OF_PATH/sd@$ID,$LUN
+             if [ "$PLATFORM" = "mac" ] ; then
+                 OF_PATH=$OF_PATH/@$ID
+             else
+                 OF_PATH=$OF_PATH/sd@$ID,$LUN
+             fi
        fi
     fi
 
--
2.26.1

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH]: Add support for Apple Power Mac

John Paul Adrian Glaubitz
In reply to this post by John Paul Adrian Glaubitz
Hi!

On 4/19/20 11:35 AM, John Paul Adrian Glaubitz wrote:
> The following three patches are required to get ofpathname to return
> proper OF paths on Apple Power Macs.

Any chance someone could have a look at this?

Thanks,
Adrian

--
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [hidden email]
`. `'   Freie Universitaet Berlin - [hidden email]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH]: Add support for Apple Power Mac

Luke-7
Hi all, I've try the 2020-04-19 image but I still have a black screen of death.
With default installation, the partitioning create a boot partition of 128Mb, but grub fail to install.
So I create it manually of 256Mb and it go well.
Gnome Desktop environment don't install because there's some blocked packets.
I've selected Cinnamon instead and this install.
In any case the screen still black!
I don't know what else to do.

Il dom 17 mag 2020, 12:33 John Paul Adrian Glaubitz <[hidden email]> ha scritto:
Hi!

On 4/19/20 11:35 AM, John Paul Adrian Glaubitz wrote:
> The following three patches are required to get ofpathname to return
> proper OF paths on Apple Power Macs.

Any chance someone could have a look at this?

Thanks,
Adrian

--
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [hidden email]
`. `'   Freie Universitaet Berlin - [hidden email]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH]: Add support for Apple Power Mac

John Paul Adrian Glaubitz
On 5/17/20 8:05 PM, Luke wrote:
> Hi all, I've try the 2020-04-19 image but I still have a black screen of
> death.

Please don't hijack threads on the mailing list.

Instead, post a new thread on the debian-powerpc mailing list.

Thanks,
Adrian

--
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [hidden email]
`. `'   Freie Universitaet Berlin - [hidden email]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH]: Add support for Apple Power Mac

Rui Salvaterra
In reply to this post by John Paul Adrian Glaubitz
Hi, Adrian,

On Sun, 17 May 2020 at 11:33, John Paul Adrian Glaubitz
<[hidden email]> wrote:
>
> Any chance someone could have a look at this?
>

I tried to run ofpathname as-is, and it seems to work, apart from that
I/O error with find…? I haven't tested your patches, but here's the
output I'm getting (lsblk for context), when compared to my
boot-device entry on the NVRAM…

rui@mcnugget:~$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0  74,5G  0 disk
├─sda1   8:1    0  31,5K  0 part
├─sda2   8:2    0  30,5M  0 part /boot/grub
├─sda3   8:3    0 122,1M  0 part /boot
├─sda4   8:4    0   7,5G  0 part /
├─sda5   8:5    0    67G  0 part /home
└─sda6   8:6    0  24,5K  0 part
sr0     11:0    1  1024M  0 rom
zram0  254:0    0   1,2G  0 disk [SWAP]
rui@mcnugget:~$ sudo nvram --print-config | grep boot-device
boot-device=/pci@f4000000/ata-6@d/@0:2,\grub
rui@mcnugget:~$ sudo ofpathname /dev/sda2
/usr/bin/find: ‘/sys/firmware/devicetree/base/uni-n@f8000000/i2c@f8001000/i2c-bus@1/fan@5c’:
Input/output error
/pci@f4000000/ata-6@d/@0:2
rui@mcnugget:~$

… and the returned Open Firmware path looks correct. Am I missing
something obvious?

Cheers,
Rui

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH]: Add support for Apple Power Mac

John Paul Adrian Glaubitz
Hello Rui!

On 5/18/20 10:26 PM, Rui Salvaterra wrote:
> I tried to run ofpathname as-is, and it seems to work, apart from that
> I/O error with find…? I haven't tested your patches, but here's the
> output I'm getting (lsblk for context), when compared to my
> boot-device entry on the NVRAM…
> (...)
> … and the returned Open Firmware path looks correct. Am I missing
> something obvious?

I remember running into this issue as well and I think it occurred
when running the command on a Debian Jessie system or so.

What kind of environment are you running the command in?

Adrian

--
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [hidden email]
`. `'   Freie Universitaet Berlin - [hidden email]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH]: Add support for Apple Power Mac

Rui Salvaterra
Hi, Adrian,

On Mon, 18 May 2020 at 21:47, John Paul Adrian Glaubitz
<[hidden email]> wrote:
>
> I remember running into this issue as well and I think it occurred
> when running the command on a Debian Jessie system or so.
>
> What kind of environment are you running the command in?

Indeed, I just invoked ofpathname as root on a normal Debian powerpc
installation. Is the d-i environment so special it could cause issues
with ofpathname?

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH]: Add support for Apple Power Mac

John Paul Adrian Glaubitz
Hello!

On 5/19/20 12:24 AM, Rui Salvaterra wrote:
>> I remember running into this issue as well and I think it occurred
>> when running the command on a Debian Jessie system or so.
>>
>> What kind of environment are you running the command in?
>
> Indeed, I just invoked ofpathname as root on a normal Debian powerpc
> installation. Is the d-i environment so special it could cause issues
> with ofpathname?

I'm confused now as I have not observed the issue in d-i. I have only
seen it when running the command on an old Debian Jessie system.

On unstable, both in a normal environment and within d-i, the script
works as expected for me.

Adrian

--
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [hidden email]
`. `'   Freie Universitaet Berlin - [hidden email]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH]: Add support for Apple Power Mac

Rui Salvaterra
Hi, Adrian,

On Tue, 19 May 2020 at 12:54, John Paul Adrian Glaubitz
<[hidden email]> wrote:
>
> I'm confused now as I have not observed the issue in d-i. I have only
> seen it when running the command on an old Debian Jessie system.
>
> On unstable, both in a normal environment and within d-i, the script
> works as expected for me.

I'm glad to know that, maybe the ofpathname problem was caused by some
other issue which got fixed in the meantime…? I really can't pinpoint
when ofpathname started working correctly for me. I've been using GRUB
since early 2016 (when I got my Power Mac G5 and installed Debian
ppc64 unstable), but at that time it wasn't really user-friendly:
every time GRUB was updated, I had to copy grub.elf to the bootstrap
partition, change its type attribute to tbxi and fix the NVRAM
boot-device entry (it was a "fun" procedure, but at least it worked
and allowed me to run xz-compressed kernels). I remember I used the
devalias in the boot-device entry because ofpathname wasn't working
correctly and I didn't feel like traversing the device tree by hand.
:)

Cheers,
Rui

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH]: Add support for Apple Power Mac

John Paul Adrian Glaubitz
On 5/19/20 3:18 PM, Rui Salvaterra wrote:

>> On unstable, both in a normal environment and within d-i, the script
>> works as expected for me.
>
> I'm glad to know that, maybe the ofpathname problem was caused by some
> other issue which got fixed in the meantime…? I really can't pinpoint
> when ofpathname started working correctly for me. I've been using GRUB
> since early 2016 (when I got my Power Mac G5 and installed Debian
> ppc64 unstable), but at that time it wasn't really user-friendly:
> every time GRUB was updated, I had to copy grub.elf to the bootstrap
> partition, change its type attribute to tbxi and fix the NVRAM
> boot-device entry (it was a "fun" procedure, but at least it worked
> and allowed me to run xz-compressed kernels). I remember I used the
> devalias in the boot-device entry because ofpathname wasn't working
> correctly and I didn't feel like traversing the device tree by hand.
> :)

This patch set is fixing ofpathname for Apple PowerMacs.

Which version of Debian are you running?

Adrian

--
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [hidden email]
`. `'   Freie Universitaet Berlin - [hidden email]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH]: Add support for Apple Power Mac

Rui Salvaterra
On Tue, 19 May 2020 at 14:36, John Paul Adrian Glaubitz
<[hidden email]> wrote:
>
> This patch set is fixing ofpathname for Apple PowerMacs.
>
> Which version of Debian are you running?

I'm running Debian unstable. Actually, Debian on big-endian POWER is a
port, are there even stable releases? (Not that I want to run them,
just genuinely curious.)

Reply | Threaded
Open this post in threaded view
|

Ping: Re: [PATCH]: Add support for Apple Power Mac

John Paul Adrian Glaubitz
In reply to this post by John Paul Adrian Glaubitz
Hi!

On 5/17/20 12:33 PM, John Paul Adrian Glaubitz wrote:
> On 4/19/20 11:35 AM, John Paul Adrian Glaubitz wrote:
>> The following three patches are required to get ofpathname to return
>> proper OF paths on Apple Power Macs.
>
> Any chance someone could have a look at this?

Gentle ping.

--
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [hidden email]
`. `'   Freie Universitaet Berlin - [hidden email]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

Reply | Threaded
Open this post in threaded view
|

Re: Ping: Re: [PATCH]: Add support for Apple Power Mac

Nathan Lynch
John Paul Adrian Glaubitz <[hidden email]> writes:

> Hi!
>
> On 5/17/20 12:33 PM, John Paul Adrian Glaubitz wrote:
>> On 4/19/20 11:35 AM, John Paul Adrian Glaubitz wrote:
>>> The following three patches are required to get ofpathname to return
>>> proper OF paths on Apple Power Macs.
>>
>> Any chance someone could have a look at this?
>
> Gentle ping.

Thanks for your persistence. Tyrel, I've looked these over and didn't
see anything wrong.

Reply | Threaded
Open this post in threaded view
|

Re: Ping: Re: [PATCH]: Add support for Apple Power Mac

John Paul Adrian Glaubitz
On 6/5/20 4:15 PM, Nathan Lynch wrote:

> John Paul Adrian Glaubitz <[hidden email]> writes:
>> Hi!
>>
>> On 5/17/20 12:33 PM, John Paul Adrian Glaubitz wrote:
>>> On 4/19/20 11:35 AM, John Paul Adrian Glaubitz wrote:
>>>> The following three patches are required to get ofpathname to return
>>>> proper OF paths on Apple Power Macs.
>>>
>>> Any chance someone could have a look at this?
>>
>> Gentle ping.
>
> Thanks for your persistence. Tyrel, I've looked these over and didn't
> see anything wrong.

Thank you :-).

Adrian

--
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [hidden email]
`. `'   Freie Universitaet Berlin - [hidden email]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

Reply | Threaded
Open this post in threaded view
|

Re: Ping: Re: [PATCH]: Add support for Apple Power Mac

Tyrel Datwyler
In reply to this post by Nathan Lynch
On 6/5/20 7:15 AM, Nathan Lynch wrote:

> John Paul Adrian Glaubitz <[hidden email]> writes:
>> Hi!
>>
>> On 5/17/20 12:33 PM, John Paul Adrian Glaubitz wrote:
>>> On 4/19/20 11:35 AM, John Paul Adrian Glaubitz wrote:
>>>> The following three patches are required to get ofpathname to return
>>>> proper OF paths on Apple Power Macs.
>>>
>>> Any chance someone could have a look at this?
>>
>> Gentle ping.
>
> Thanks for your persistence. Tyrel, I've looked these over and didn't
> see anything wrong.
>

Thanks, for getting an extra set of eyes on these Nathan. I'll add your
reviewed-by when I merge.

-Tyrel

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 3/3] ofpathname: Add support for Mac-compatible OF pathnames

Tyrel Datwyler
In reply to this post by John Paul Adrian Glaubitz
On 4/19/20 2:35 AM, John Paul Adrian Glaubitz wrote:
> On Macintosh systems, OpenFirmware path follow a slightly
> different syntax as compared to other OF systems. In particular,
> the disk ID is not preceeded by the string "disk" and - on
> SATA systems - the path does not contain the BUS ID as
> "scsi@ID" but rather the plug ID in the form "@ID".
>
> Signed-off-by: John Paul Adrian Glaubitz <[hidden email]>
> ---

Series applied to powerpc-utils next.

https://github.com/ibm-power-utilities/powerpc-utils/commit/f8f2f09c413838fe9f0b30478de5d08bdb3e95aa

Thanks,
Tyrel

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 1/3] ofpathname: Add partition support to l2of_ide() and l2of_scsi()

Tyrel Datwyler
In reply to this post by John Paul Adrian Glaubitz
On 4/19/20 2:35 AM, John Paul Adrian Glaubitz wrote:

> Currently, only l2of_nvme() supports handling of partitions which
> will print the partition number at the end of an OF path. However,
> this feature is also useful for IDE and SCSI targets as well and
> mandatory for Macintosh systems.
>
> Signed-off-by: John Paul Adrian Glaubitz <[hidden email]>
> ---
>  scripts/ofpathname | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
>
> diff --git a/scripts/ofpathname b/scripts/ofpathname
> index c37c6bd..0e58005 100755
> --- a/scripts/ofpathname
> +++ b/scripts/ofpathname
> @@ -519,6 +519,13 @@ l2of_ide()
>      if [[ -z $link ]]; then
>          err $ERR_NO_SYSFS_DEVINFO
>      fi
> +
> +    # partition number: N in sd*N
> +    local devpart="${DEVICE##*[a-z]}"
> +    if [[ $devpart = $DEVICE ]]; then
> +        devpart='' # no partition number
> +    fi
> +
>      cd $link
>  
>      # get the device number
> @@ -584,6 +591,13 @@ l2of_vd()
>      if [[ -z $OF_PATH ]]; then
>          err $ERR_NO_OFPATH
>      fi
> +
> +    # No partition specified.
> +    if [[ -z $devpart ]]; then
> +        return
> +    fi
> +
> +    OF_PATH="${OF_PATH}:${devpart}"
>  }
>  
>  #
> @@ -786,6 +800,12 @@ l2of_scsi()
>          err $ERR_NOT_CONFIG
>      fi
>  
> +    # partition number: N in sd*N
> +    local devpart="${DEVICE##*[a-z]}"
> +    if [[ $devpart = $DEVICE ]]; then
> +        devpart='' # no partition number
> +    fi
> +
>      # follow the 'device' link
>      local link=`get_link "device"`
>      if [[ -z $link ]]; then
> @@ -944,6 +964,13 @@ l2of_scsi()
>               OF_PATH=$OF_PATH/sd@$ID,$LUN
>         fi
>      fi
> +
> +    # No partition specified.
> +    if [[ -z $devpart ]]; then
> +        return
> +    fi
> +
> +    OF_PATH="${OF_PATH}:${devpart}"

Heads up this may be problematic for pseries lpars. The current behavior is that
regardless of the scsi partition the logical device always translates to the
full underlying disk. I will need to confirm whether OF is going to complain
when the partition number is appended.

-Tyrel

>  }
>  
>  #
>

12