qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: BALATON Zoltan <balaton@eik.bme.hu>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	qemu-devel@nongnu.org,  shentey@gmail.com
Subject: Re: [PATCH v3 8/9] mips/loongson3_virt: do not require CONFIG_USB
Date: Thu, 15 Feb 2024 15:27:16 +0100 (CET)	[thread overview]
Message-ID: <d02bde71-c4b8-4b07-bc40-3b74d37b0738@eik.bme.hu> (raw)
In-Reply-To: <47a999a8-a0e0-4995-8f8c-8d18f564c30b@linaro.org>

[-- Attachment #1: Type: text/plain, Size: 3075 bytes --]

On Thu, 15 Feb 2024, Philippe Mathieu-Daudé wrote:
> On 13/2/24 16:50, Paolo Bonzini wrote:
>> Once the Kconfig for hw/mips is cleaned up, it will be possible to build a
>> binary that does not include any USB host controller and therefore that
>> does not include the code guarded by CONFIG_USB.  While the simpler
>> creation functions such as usb_create_simple can be inlined, this is not
>> true of usb_bus_find().  Remove it, replacing it with a search of the
>> single USB bus created by loongson3_virt_devices_init().
>> 
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>>   hw/mips/loongson3_virt.c | 5 +++--
>>   1 file changed, 3 insertions(+), 2 deletions(-)
>> 
>> diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c
>> index caedde2df00..bedd3d496bd 100644
>> --- a/hw/mips/loongson3_virt.c
>> +++ b/hw/mips/loongson3_virt.c
>> @@ -447,8 +447,9 @@ static inline void 
>> loongson3_virt_devices_init(MachineState *machine,
>>         if (defaults_enabled() && object_class_by_name("pci-ohci")) {
>>           pci_create_simple(pci_bus, -1, "pci-ohci");
>> -        usb_create_simple(usb_bus_find(-1), "usb-kbd");
>> -        usb_create_simple(usb_bus_find(-1), "usb-tablet");
>> +        Object *usb_bus = object_resolve_path_type("", TYPE_USB_BUS, 
>> NULL);
>> +        usb_create_simple(USB_BUS(usb_bus), "usb-kbd");
>> +        usb_create_simple(USB_BUS(usb_bus), "usb-tablet");
>>       }
>>         pci_init_nic_devices(pci_bus, mc->default_nic);
>
> Can we remove usb_bus_find() completely instead?
>
> $ git grep -w usb_bus_find
> hw/hppa/machine.c:401:        usb_create_simple(usb_bus_find(-1), "usb-kbd");
> hw/hppa/machine.c:402:        usb_create_simple(usb_bus_find(-1), 
> "usb-mouse");
> hw/mips/loongson3_virt.c:450:        usb_create_simple(usb_bus_find(-1), 
> "usb-kbd");
> hw/mips/loongson3_virt.c:451:        usb_create_simple(usb_bus_find(-1), 
> "usb-tablet");
> hw/ppc/mac_newworld.c:434:            USBBus *usb_bus = usb_bus_find(-1);
> hw/ppc/sam460ex.c:423:    usb_create_simple(usb_bus_find(-1), "usb-kbd");
> hw/ppc/sam460ex.c:424:    usb_create_simple(usb_bus_find(-1), "usb-mouse");
> hw/ppc/spapr.c:3027:            USBBus *usb_bus = usb_bus_find(-1);
> hw/sh4/r2d.c:315:    usb_create_simple(usb_bus_find(-1), "usb-kbd");
> hw/usb/bus.c:103:USBBus *usb_bus_find(int busnr)
> hw/usb/bus.c:669:    USBBus *bus = usb_bus_find(-1 /* any */);
> include/hw/usb.h:500:USBBus *usb_bus_find(int busnr);

These are all the machines that add devices to a USB bus, there's no other 
example to do it in a different way currently. We could change this to get 
the usb bus in a different way but how? We could either peek into the 
object that owns the usb_bus or try using qdev_get_child_bus() but that 
needs the name of the bus which might change if other usb hosts are added 
so neither of these options seem better than this function. What would it 
bring to remove this function other than more complex or uglier code? I 
don't mind if you remove it just don't see the benefit in that.

Regards,
BALATON Zoltan

  parent reply	other threads:[~2024-02-15 14:27 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-13 15:49 [PATCH v3 0/9] mips: do not list individual devices from configs/ Paolo Bonzini
2024-02-13 15:49 ` [PATCH v3 1/9] usb: inline device creation functions Paolo Bonzini
2024-02-16 11:14   ` Philippe Mathieu-Daudé
2024-02-17  9:49     ` Paolo Bonzini
2024-02-13 15:49 ` [PATCH v3 2/9] isa: clean up Kconfig selections for ISA_SUPERIO Paolo Bonzini
2024-02-13 15:49 ` [PATCH v3 3/9] hw/mips/Kconfig: Remove ISA dependencies from MIPSsim board Paolo Bonzini
2024-02-13 15:49 ` [PATCH v3 4/9] isa: fix ISA_SUPERIO dependencies Paolo Bonzini
2024-02-13 15:50 ` [PATCH v3 5/9] isa: specify instance_size in isa_superio_type_info Paolo Bonzini
2024-02-13 15:50 ` [PATCH v3 6/9] isa: extract FDC37M81X to a separate file Paolo Bonzini
2024-02-13 19:07   ` Bernhard Beschow
2024-02-13 15:50 ` [PATCH v3 7/9] mips: allow compiling out CONFIG_MIPS_ITU Paolo Bonzini
2024-02-13 15:50 ` [PATCH v3 8/9] mips/loongson3_virt: do not require CONFIG_USB Paolo Bonzini
2024-02-15  7:55   ` Philippe Mathieu-Daudé
2024-02-15 11:12     ` Paolo Bonzini
2024-02-15 14:27     ` BALATON Zoltan [this message]
2024-02-15 17:31       ` Paolo Bonzini
2024-02-13 15:50 ` [PATCH v3 9/9] mips: do not list individual devices from configs/ Paolo Bonzini
2024-02-15 17:51 ` [PATCH v3 0/9] " Philippe Mathieu-Daudé

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=d02bde71-c4b8-4b07-bc40-3b74d37b0738@eik.bme.hu \
    --to=balaton@eik.bme.hu \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=shentey@gmail.com \
    /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).