[SLOF] [PATCH] Correctly set ibm,my-drc-index

Michael Roth mdroth at linux.vnet.ibm.com
Mon Sep 14 12:25:17 AEST 2015


Quoting David Gibson (2015-09-13 18:45:00)
> On Fri, 11 Sep 2015 18:48:19 +0200
> Laurent Vivier <lvivier at redhat.com> wrote:
> 
> > The current calculation of DRC index for PCI card doesn't take
> > into account the PHB bridge index, so with several bridges we
> > can have several devices with the same DRC index.
> > 
> > This is a problem when we want to unplug a PCI card with
> > drmgr which is based on the DRC index.
> > 
> > Signed-off-by: Laurent Vivier <lvivier at redhat.com>
> 
> Actually, I think the safer fix is just for SLOF not to touch the
> ibm,my-drc-index property if it's already present.  QEMU is already
> setting it correctly, and SLOF is overwriting it  :(.

This patch makes sense and fixes a real bug, but my understanding is that
SLOF only fills in properties missing from device node rather than
overwriting ones provided by QEMU. On my end, on the second PHB, I see
this for a hotplugged device in slot 1 (where prop comes from QEMU via
RTAS):

mdroth at ubuntu:/proc/device-tree/pci at 800000020000001/pci at 2$ od -x
ibm,my-drc-index
0000000 0140 1000
0000004

And after reboot (where prop comes from QEMU via SLOF):

mdroth at ubuntu:/proc/device-tree/pci at 800000020000001/ethernet at 2$ od -x
ibm,my-drc-index
0000000 0140 1000
0000004

If you're getting the buggy values (0040 1000, i.e. 40000010 be32 value)
it makes me think you're not using the QEMU-generated DTs for device
nodes. Older SLOF that doesn't have Nikunj's updates possibly? I think
in that case values might get overwritten/thrown out.

> 
> Adding Mike Roth to CC, since git blame says he wrote this bit of SLOF
> code.
> 
> >  slof/fs/pci-properties.fs | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/slof/fs/pci-properties.fs b/slof/fs/pci-properties.fs
> > index 4f13402..d132426 100644
> > --- a/slof/fs/pci-properties.fs
> > +++ b/slof/fs/pci-properties.fs
> > @@ -599,9 +599,10 @@
> >          pci-reg-props
> >          pci-hotplug-enabled IF
> >              \ QEMU uses static assignments for my-drc-index:
> > -            \ 40000000h + $bus << 8 + $slot << 3
> > +            \ 40000000h + $phbindex << 16 + $bus << 8 + $slot << 3
> >              dup dup pci-addr2bus 8 lshift
> >              swap pci-addr2dev 3 lshift or
> > +            puid ff and 10 lshift or
> >              40000000 + encode-int s" ibm,my-drc-index" property
> >              \ QEMU uses "Slot $bus*32$slotno" for loc-code

I think loc-code may need to be updated to match QEMU as well.

> >              dup dup pci-addr2bus 20 *
> > -- 
> > 2.1.0
> > 
> 
> 
> -- 
> David Gibson <dgibson at redhat.com>
> Senior Software Engineer, Virtualization, Red Hat



More information about the SLOF mailing list