qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@kaod.org>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, Greg Kurz <groug@kaod.org>
Subject: Re: [Qemu-devel] [PATCH v3 1/3] spapr: introduce a fixed IRQ number space
Date: Fri, 6 Jul 2018 09:40:20 +0200	[thread overview]
Message-ID: <d6a9a37f-4ac9-6a72-5215-8d68c70d2621@kaod.org> (raw)
In-Reply-To: <20180706054458.GQ3450@umbus.fritz.box>

On 07/06/2018 07:44 AM, David Gibson wrote:
> On Tue, Jul 03, 2018 at 05:19:56PM +0200, Cédric Le Goater wrote:
>> On 07/02/2018 01:11 PM, Cédric Le Goater wrote:
>>> On 07/02/2018 12:03 PM, Cédric Le Goater wrote:
>>>>> --- a/hw/ppc/spapr_vio.c
>>>>> +++ b/hw/ppc/spapr_vio.c
>>>>> @@ -436,6 +436,9 @@ static void spapr_vio_busdev_reset(DeviceState *qdev)
>>>>>      }
>>>>>  }
>>>>>  
>>>>> +/* TODO : poor VIO device indexing ... */
>>>>> +static uint32_t vio_index;
>>>>
>>>> I think we could also use (dev->reg & 0xff) as an index for 
>>>> the VIO devices.
>>>>
>>>> The unit address of the virtual IOA is simply allocated using 
>>>> an increment of bus->next_reg, next_reg being initialized at
>>>> 0x71000000.
>>>>
>>>> I did not see any restrictions in the PAPR specs or in QEMU 
>>>> that would break the above.
>>>
>>> That was until I discovered this macro : 
>>>
>>>   #define DEFINE_SPAPR_PROPERTIES(type, field)           \
>>>         DEFINE_PROP_UINT32("reg", type, field.reg, -1)
>>>  
>>> so 'reg' could have any value. We can not use it ...
>>
>> Would moving vio_index under the bus and incrementing it each time
>> a VIO device is created be acceptable ? 
> 
> Not really, no.
> 
>> It does look like an allocator but I really don't know what else to 
>> propose :/ See below.
> 
> Not only is it a stealth allocator, it also means we have two
> different unique ids for VIO devices - the 'reg' and this new index.
> That sounds like a recipe for confusion.
> 
> I think we can do better.  I had a look at how these are allocated and
> it seems to be this:
> 
> In qemu:
> 	VIO devices start at reg=0x71000000, and just increment by one
> 	from there.
> 
> In libvirt:
> 	VIO net devices start at reg=0x1000
> 	VIO scsi devices start at reg=0x2000
> 	VIO nvram devices start at reg=0x3000

but a default VIO nvram device is always created by the machine. Here is 
a typical /vdevice layout :

  drwxr-xr-x. 2 root root 0 Jul  2 04:22 /proc/device-tree/vdevice/nvram@71000000
  drwxr-xr-x. 2 root root 0 Jul  2 04:22 /proc/device-tree/vdevice/vty@30000000

which is going to have collisions.

Should we set the "register" property of the defaut nvram device to some 
high value ? the sPAPR platform expects to always have a nvram device:

    R1–8.1–1.

      Platforms must implement at least 8 KB of Non-Volatile Memory. 
      The actual amount is platform dependent and must allow for 4 KB 
      for the OS. Platforms must provide an additional 4 KB for each 
      installed OS beyond the first.

So we can not remove it. 

The vty devices are dependent on the chardev backends. We are fine on that
side.

Thanks,

C.

> 	VIO vty devices start at reg=0x30000000
> 	    and increment by 0x1000 each type
> 
> So we could go for say:
> 	irq = (reg & 0xf) ^ ((reg >> 12) & 0xf);
> 
> Obviously it's easily to construct cases where that will result in
> collisions, but I don't think it'll happen for anyone not going out of
> there way to make it happen.
> 

  parent reply	other threads:[~2018-07-06  7:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-19 14:07 [Qemu-devel] [PATCH v3 0/3] spapr: introduce a fixed IRQ number space and an IRQ controller backend Cédric Le Goater
2018-06-19 14:07 ` [Qemu-devel] [PATCH v3 1/3] spapr: introduce a fixed IRQ number space Cédric Le Goater
2018-07-02 10:03   ` Cédric Le Goater
2018-07-02 11:11     ` Cédric Le Goater
2018-07-03 15:19       ` Cédric Le Goater
2018-07-04  8:13         ` Greg Kurz
2018-07-06  5:44         ` David Gibson
2018-07-06  6:29           ` Cédric Le Goater
2018-07-06  7:40           ` Cédric Le Goater [this message]
2018-07-06  7:46             ` [Qemu-devel] [Qemu-ppc] " Cédric Le Goater
2018-06-19 14:07 ` [Qemu-devel] [PATCH v3 2/3] spapr: introduce a IRQ controller backend to the machine Cédric Le Goater
2018-06-19 14:07 ` [Qemu-devel] [PATCH v3 3/3] spapr: increase the size of the IRQ number space Cédric Le Goater
2018-06-19 15:16 ` [Qemu-devel] [PATCH v3 3/3 bonus] spapr: remove the XICS header from the machine and device models Cédric Le Goater

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d6a9a37f-4ac9-6a72-5215-8d68c70d2621@kaod.org \
    --to=clg@kaod.org \
    --cc=david@gibson.dropbear.id.au \
    --cc=groug@kaod.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).