[PATCH 3/7] powerpc/eeh_cache: Add a way to dump the EEH address cache

Michael Ellerman mpe at ellerman.id.au
Mon Feb 11 13:16:55 AEDT 2019


Oliver <oohall at gmail.com> writes:
> On Fri, Feb 8, 2019 at 8:47 PM Michael Ellerman <mpe at ellerman.id.au> wrote:
>> Oliver O'Halloran <oohall at gmail.com> writes:
>> > diff --git a/arch/powerpc/kernel/eeh_cache.c b/arch/powerpc/kernel/eeh_cache.c
>> > index b2c320e0fcef..dba421a577e7 100644
>> > --- a/arch/powerpc/kernel/eeh_cache.c
>> > +++ b/arch/powerpc/kernel/eeh_cache.c
>> > @@ -298,9 +299,34 @@ void eeh_addr_cache_build(void)
>> >               eeh_addr_cache_insert_dev(dev);
>> >               eeh_sysfs_add_device(dev);
>> >       }
>> > +}
>> >
>> > -#ifdef DEBUG
>> > -     /* Verify tree built up above, echo back the list of addrs. */
>> > -     eeh_addr_cache_print(&pci_io_addr_cache_root);
>> > -#endif
>> > +static int eeh_addr_cache_show(struct seq_file *s, void *v)
>> > +{
>> > +     struct rb_node *n = rb_first(&pci_io_addr_cache_root.rb_root);
>> > +     struct pci_io_addr_range *piar;
>> > +     int cnt = 0;
>> > +
>> > +     spin_lock(&pci_io_addr_cache_root.piar_lock);
>> > +     while (n) {
>> > +             piar = rb_entry(n, struct pci_io_addr_range, rb_node);
>> > +
>> > +             seq_printf(s, "%s addr range %3d [%pap-%pap]: %s\n",
>> > +                    (piar->flags & IORESOURCE_IO) ? "i/o" : "mem", cnt,
>> > +                    &piar->addr_lo, &piar->addr_hi, pci_name(piar->pcidev));
>> > +
>> > +             n = rb_next(n);
>> > +             cnt++;
>> > +     }
>>
>> You can write that as a for loop can't you?
>>
>>         struct rb_node *n;
>>         int i = 0;
>>
>>         for (n = rb_first(&pci_io_addr_cache_root.rb_root); n; n = rb_next(n), i++) {
>
> IIRC I did try that, but it's too long. 85 cols wide according to my editor.

Don't care.

Long lines aren't inherently evil, they have some downsides but so do
the other options. In a case like this 85 columns would be preferable to
splitting the line or writing it a while loop.

cheers


More information about the Linuxppc-dev mailing list