diff mbox series

[12/13] ppc440_pcix: Don't use iomem for regs

Message ID 576b54159060392c8bc12a63c665928053b58f24.1688421085.git.balaton@eik.bme.hu
State New
Headers show
Series PPC440 devices misc clean up | expand

Commit Message

BALATON Zoltan July 3, 2023, 10:02 p.m. UTC
The iomem memory region is better used for the PCI IO space but
currently used for registers. Stop using it for that to allow this to
be cleaned up in the next patch.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
 hw/ppc/ppc440_pcix.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Philippe Mathieu-Daudé July 4, 2023, 8:59 a.m. UTC | #1
On 4/7/23 00:02, BALATON Zoltan wrote:
> The iomem memory region is better used for the PCI IO space but
> currently used for registers. Stop using it for that to allow this to
> be cleaned up in the next patch.
> 
> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
> ---
>   hw/ppc/ppc440_pcix.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/ppc/ppc440_pcix.c b/hw/ppc/ppc440_pcix.c
> index adfecf1e76..ee2dc44f67 100644
> --- a/hw/ppc/ppc440_pcix.c
> +++ b/hw/ppc/ppc440_pcix.c
> @@ -484,6 +484,7 @@ static void ppc440_pcix_realize(DeviceState *dev, Error **errp)
>       SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
>       PPC440PCIXState *s;
>       PCIHostState *h;
> +    MemoryRegion *regs = g_new(MemoryRegion, 1);

Why not hold it within PPC440PCIXState?

>       h = PCI_HOST_BRIDGE(dev);
>       s = PPC440_PCIX_HOST(dev);
> @@ -507,11 +508,11 @@ static void ppc440_pcix_realize(DeviceState *dev, Error **errp)
>                             h, "pci-conf-idx", 4);
>       memory_region_init_io(&h->data_mem, OBJECT(s), &pci_host_data_le_ops,
>                             h, "pci-conf-data", 4);
> -    memory_region_init_io(&s->iomem, OBJECT(s), &pci_reg_ops, s,
> -                          "pci.reg", PPC440_REG_SIZE);
> +    memory_region_init_io(regs, OBJECT(s), &pci_reg_ops, s, "pci-reg",
> +                          PPC440_REG_SIZE);
>       memory_region_add_subregion(&s->container, PCIC0_CFGADDR, &h->conf_mem);
>       memory_region_add_subregion(&s->container, PCIC0_CFGDATA, &h->data_mem);
> -    memory_region_add_subregion(&s->container, PPC440_REG_BASE, &s->iomem);
> +    memory_region_add_subregion(&s->container, PPC440_REG_BASE, regs);
>       sysbus_init_mmio(sbd, &s->container);
>   }
>
BALATON Zoltan July 4, 2023, 9:37 a.m. UTC | #2
On Tue, 4 Jul 2023, Philippe Mathieu-Daudé wrote:
> On 4/7/23 00:02, BALATON Zoltan wrote:
>> The iomem memory region is better used for the PCI IO space but
>> currently used for registers. Stop using it for that to allow this to
>> be cleaned up in the next patch.
>> 
>> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
>> ---
>>   hw/ppc/ppc440_pcix.c | 7 ++++---
>>   1 file changed, 4 insertions(+), 3 deletions(-)
>> 
>> diff --git a/hw/ppc/ppc440_pcix.c b/hw/ppc/ppc440_pcix.c
>> index adfecf1e76..ee2dc44f67 100644
>> --- a/hw/ppc/ppc440_pcix.c
>> +++ b/hw/ppc/ppc440_pcix.c
>> @@ -484,6 +484,7 @@ static void ppc440_pcix_realize(DeviceState *dev, Error 
>> **errp)
>>       SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
>>       PPC440PCIXState *s;
>>       PCIHostState *h;
>> +    MemoryRegion *regs = g_new(MemoryRegion, 1);
>
> Why not hold it within PPC440PCIXState?

Because it's never needed after this function.

Regards,
BALATON Zoltan

>>       h = PCI_HOST_BRIDGE(dev);
>>       s = PPC440_PCIX_HOST(dev);
>> @@ -507,11 +508,11 @@ static void ppc440_pcix_realize(DeviceState *dev, 
>> Error **errp)
>>                             h, "pci-conf-idx", 4);
>>       memory_region_init_io(&h->data_mem, OBJECT(s), &pci_host_data_le_ops,
>>                             h, "pci-conf-data", 4);
>> -    memory_region_init_io(&s->iomem, OBJECT(s), &pci_reg_ops, s,
>> -                          "pci.reg", PPC440_REG_SIZE);
>> +    memory_region_init_io(regs, OBJECT(s), &pci_reg_ops, s, "pci-reg",
>> +                          PPC440_REG_SIZE);
>>       memory_region_add_subregion(&s->container, PCIC0_CFGADDR, 
>> &h->conf_mem);
>>       memory_region_add_subregion(&s->container, PCIC0_CFGDATA, 
>> &h->data_mem);
>> -    memory_region_add_subregion(&s->container, PPC440_REG_BASE, 
>> &s->iomem);
>> +    memory_region_add_subregion(&s->container, PPC440_REG_BASE, regs);
>>       sysbus_init_mmio(sbd, &s->container);
>>   }
>> 
>
>
>
Philippe Mathieu-Daudé July 4, 2023, 9:57 a.m. UTC | #3
On 4/7/23 11:37, BALATON Zoltan wrote:
> On Tue, 4 Jul 2023, Philippe Mathieu-Daudé wrote:
>> On 4/7/23 00:02, BALATON Zoltan wrote:
>>> The iomem memory region is better used for the PCI IO space but
>>> currently used for registers. Stop using it for that to allow this to
>>> be cleaned up in the next patch.
>>>
>>> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
>>> ---
>>>   hw/ppc/ppc440_pcix.c | 7 ++++---
>>>   1 file changed, 4 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/hw/ppc/ppc440_pcix.c b/hw/ppc/ppc440_pcix.c
>>> index adfecf1e76..ee2dc44f67 100644
>>> --- a/hw/ppc/ppc440_pcix.c
>>> +++ b/hw/ppc/ppc440_pcix.c
>>> @@ -484,6 +484,7 @@ static void ppc440_pcix_realize(DeviceState *dev, 
>>> Error **errp)
>>>       SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
>>>       PPC440PCIXState *s;
>>>       PCIHostState *h;
>>> +    MemoryRegion *regs = g_new(MemoryRegion, 1);
>>
>> Why not hold it within PPC440PCIXState?
> 
> Because it's never needed after this function.

But we can't free() it because it has to stay valid as long as
PPC440PCIXState is in use. So it seems to belong there.

> 
> Regards,
> BALATON Zoltan
> 
>>>       h = PCI_HOST_BRIDGE(dev);
>>>       s = PPC440_PCIX_HOST(dev);
>>> @@ -507,11 +508,11 @@ static void ppc440_pcix_realize(DeviceState 
>>> *dev, Error **errp)
>>>                             h, "pci-conf-idx", 4);
>>>       memory_region_init_io(&h->data_mem, OBJECT(s), 
>>> &pci_host_data_le_ops,
>>>                             h, "pci-conf-data", 4);
>>> -    memory_region_init_io(&s->iomem, OBJECT(s), &pci_reg_ops, s,
>>> -                          "pci.reg", PPC440_REG_SIZE);
>>> +    memory_region_init_io(regs, OBJECT(s), &pci_reg_ops, s, "pci-reg",
>>> +                          PPC440_REG_SIZE);
>>>       memory_region_add_subregion(&s->container, PCIC0_CFGADDR, 
>>> &h->conf_mem);
>>>       memory_region_add_subregion(&s->container, PCIC0_CFGDATA, 
>>> &h->data_mem);
>>> -    memory_region_add_subregion(&s->container, PPC440_REG_BASE, 
>>> &s->iomem);
>>> +    memory_region_add_subregion(&s->container, PPC440_REG_BASE, regs);
>>>       sysbus_init_mmio(sbd, &s->container);
>>>   }
>>>
>>
>>
>>
BALATON Zoltan July 4, 2023, 10:14 a.m. UTC | #4
On Tue, 4 Jul 2023, Philippe Mathieu-Daudé wrote:
> On 4/7/23 11:37, BALATON Zoltan wrote:
>> On Tue, 4 Jul 2023, Philippe Mathieu-Daudé wrote:
>>> On 4/7/23 00:02, BALATON Zoltan wrote:
>>>> The iomem memory region is better used for the PCI IO space but
>>>> currently used for registers. Stop using it for that to allow this to
>>>> be cleaned up in the next patch.
>>>> 
>>>> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
>>>> ---
>>>>   hw/ppc/ppc440_pcix.c | 7 ++++---
>>>>   1 file changed, 4 insertions(+), 3 deletions(-)
>>>> 
>>>> diff --git a/hw/ppc/ppc440_pcix.c b/hw/ppc/ppc440_pcix.c
>>>> index adfecf1e76..ee2dc44f67 100644
>>>> --- a/hw/ppc/ppc440_pcix.c
>>>> +++ b/hw/ppc/ppc440_pcix.c
>>>> @@ -484,6 +484,7 @@ static void ppc440_pcix_realize(DeviceState *dev, 
>>>> Error **errp)
>>>>       SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
>>>>       PPC440PCIXState *s;
>>>>       PCIHostState *h;
>>>> +    MemoryRegion *regs = g_new(MemoryRegion, 1);
>>> 
>>> Why not hold it within PPC440PCIXState?
>> 
>> Because it's never needed after this function.
>
> But we can't free() it because it has to stay valid as long as
> PPC440PCIXState is in use. So it seems to belong there.

OK, moved it to PPC440PCIXState.

Regards,
BALATON Zoltan

>>>>       h = PCI_HOST_BRIDGE(dev);
>>>>       s = PPC440_PCIX_HOST(dev);
>>>> @@ -507,11 +508,11 @@ static void ppc440_pcix_realize(DeviceState *dev, 
>>>> Error **errp)
>>>>                             h, "pci-conf-idx", 4);
>>>>       memory_region_init_io(&h->data_mem, OBJECT(s), 
>>>> &pci_host_data_le_ops,
>>>>                             h, "pci-conf-data", 4);
>>>> -    memory_region_init_io(&s->iomem, OBJECT(s), &pci_reg_ops, s,
>>>> -                          "pci.reg", PPC440_REG_SIZE);
>>>> +    memory_region_init_io(regs, OBJECT(s), &pci_reg_ops, s, "pci-reg",
>>>> +                          PPC440_REG_SIZE);
>>>>       memory_region_add_subregion(&s->container, PCIC0_CFGADDR, 
>>>> &h->conf_mem);
>>>>       memory_region_add_subregion(&s->container, PCIC0_CFGDATA, 
>>>> &h->data_mem);
>>>> -    memory_region_add_subregion(&s->container, PPC440_REG_BASE, 
>>>> &s->iomem);
>>>> +    memory_region_add_subregion(&s->container, PPC440_REG_BASE, regs);
>>>>       sysbus_init_mmio(sbd, &s->container);
>>>>   }
>>>> 
>>> 
>>> 
>>> 
>
>
>
diff mbox series

Patch

diff --git a/hw/ppc/ppc440_pcix.c b/hw/ppc/ppc440_pcix.c
index adfecf1e76..ee2dc44f67 100644
--- a/hw/ppc/ppc440_pcix.c
+++ b/hw/ppc/ppc440_pcix.c
@@ -484,6 +484,7 @@  static void ppc440_pcix_realize(DeviceState *dev, Error **errp)
     SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
     PPC440PCIXState *s;
     PCIHostState *h;
+    MemoryRegion *regs = g_new(MemoryRegion, 1);
 
     h = PCI_HOST_BRIDGE(dev);
     s = PPC440_PCIX_HOST(dev);
@@ -507,11 +508,11 @@  static void ppc440_pcix_realize(DeviceState *dev, Error **errp)
                           h, "pci-conf-idx", 4);
     memory_region_init_io(&h->data_mem, OBJECT(s), &pci_host_data_le_ops,
                           h, "pci-conf-data", 4);
-    memory_region_init_io(&s->iomem, OBJECT(s), &pci_reg_ops, s,
-                          "pci.reg", PPC440_REG_SIZE);
+    memory_region_init_io(regs, OBJECT(s), &pci_reg_ops, s, "pci-reg",
+                          PPC440_REG_SIZE);
     memory_region_add_subregion(&s->container, PCIC0_CFGADDR, &h->conf_mem);
     memory_region_add_subregion(&s->container, PCIC0_CFGDATA, &h->data_mem);
-    memory_region_add_subregion(&s->container, PPC440_REG_BASE, &s->iomem);
+    memory_region_add_subregion(&s->container, PPC440_REG_BASE, regs);
     sysbus_init_mmio(sbd, &s->container);
 }