From: Igor Mammedov <imammedo@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: Laurent Vivier <lvivier@redhat.com>,
Thomas Huth <thuth@redhat.com>,
Eduardo Habkost <ehabkost@redhat.com>,
Sergio Lopez <slp@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Sai Pavan Boddu <sai.pavan.boddu@xilinx.com>,
qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
Richard Henderson <rth@twiddle.net>
Subject: Re: [PATCH v2 4/9] microvm: add usb support
Date: Tue, 6 Oct 2020 12:03:26 +0200 [thread overview]
Message-ID: <20201006120326.765e4e61@redhat.com> (raw)
In-Reply-To: <20201001082834.15821-5-kraxel@redhat.com>
On Thu, 1 Oct 2020 10:28:29 +0200
Gerd Hoffmann <kraxel@redhat.com> wrote:
> Wire up "usb=on" machine option, when enabled add
> a sysbus xhci controller with 8 ports.
first pci, and now usb - not so micro anymore.
why not just reuse pci to add usb controller?
what/how much do we win avoiding PCI?
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> include/hw/i386/microvm.h | 5 ++++-
> hw/i386/acpi-microvm.c | 9 +++++++++
> hw/i386/microvm.c | 13 +++++++++++++
> 3 files changed, 26 insertions(+), 1 deletion(-)
>
> diff --git a/include/hw/i386/microvm.h b/include/hw/i386/microvm.h
> index 91b064575d55..0fc216007777 100644
> --- a/include/hw/i386/microvm.h
> +++ b/include/hw/i386/microvm.h
> @@ -41,7 +41,7 @@
> * 7 | parallel |
> * 8 | rtc | rtc (rtc=on)
> * 9 | acpi | acpi (ged)
> - * 10 | pci lnk |
> + * 10 | pci lnk | xhci (usb=on)
> * 11 | pci lnk |
> * 12 | ps2 | pcie
> * 13 | fpu | pcie
> @@ -60,6 +60,9 @@
> #define GED_MMIO_BASE_REGS (GED_MMIO_BASE + 0x200)
> #define GED_MMIO_IRQ 9
>
> +#define MICROVM_XHCI_BASE 0xfe900000
> +#define MICROVM_XHCI_IRQ 10
> +
> #define PCIE_MMIO_BASE 0xc0000000
> #define PCIE_MMIO_SIZE 0x20000000
> #define PCIE_ECAM_BASE 0xe0000000
> diff --git a/hw/i386/acpi-microvm.c b/hw/i386/acpi-microvm.c
> index f16f2311955c..7e8a6894ba26 100644
> --- a/hw/i386/acpi-microvm.c
> +++ b/hw/i386/acpi-microvm.c
> @@ -35,6 +35,7 @@
> #include "hw/i386/microvm.h"
> #include "hw/pci/pci.h"
> #include "hw/pci/pcie_host.h"
> +#include "hw/usb/xhci.h"
> #include "hw/virtio/virtio-mmio.h"
>
> #include "acpi-common.h"
> @@ -89,6 +90,13 @@ static void acpi_dsdt_add_virtio(Aml *scope,
> }
> }
>
> +static void acpi_dsdt_add_xhci(Aml *scope, MicrovmMachineState *mms)
> +{
> + if (machine_usb(MACHINE(mms))) {
> + xhci_sysbus_build_aml(scope, MICROVM_XHCI_BASE, MICROVM_XHCI_IRQ);
> + }
> +}
> +
> static void acpi_dsdt_add_pci(Aml *scope, MicrovmMachineState *mms)
> {
> if (mms->pcie != ON_OFF_AUTO_ON) {
> @@ -123,6 +131,7 @@ build_dsdt_microvm(GArray *table_data, BIOSLinker *linker,
> GED_MMIO_IRQ, AML_SYSTEM_MEMORY, GED_MMIO_BASE);
> acpi_dsdt_add_power_button(sb_scope);
> acpi_dsdt_add_virtio(sb_scope, mms);
> + acpi_dsdt_add_xhci(sb_scope, mms);
> acpi_dsdt_add_pci(sb_scope, mms);
> aml_append(dsdt, sb_scope);
>
> diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c
> index 17e3f2f15265..0f61fc61ca44 100644
> --- a/hw/i386/microvm.c
> +++ b/hw/i386/microvm.c
> @@ -47,6 +47,7 @@
> #include "hw/acpi/acpi.h"
> #include "hw/acpi/generic_event_device.h"
> #include "hw/pci-host/gpex.h"
> +#include "hw/usb/xhci.h"
>
> #include "cpu.h"
> #include "elf.h"
> @@ -197,6 +198,18 @@ static void microvm_devices_init(MicrovmMachineState *mms)
> x86ms->acpi_dev = HOTPLUG_HANDLER(dev);
> }
>
> + if (x86_machine_is_acpi_enabled(x86ms) && machine_usb(MACHINE(mms))) {
> + DeviceState *dev = qdev_new(TYPE_XHCI_SYSBUS);
> + qdev_prop_set_uint32(dev, "intrs", 1);
> + qdev_prop_set_uint32(dev, "slots", XHCI_MAXSLOTS);
> + qdev_prop_set_uint32(dev, "p2", 8);
> + qdev_prop_set_uint32(dev, "p3", 8);
> + sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal);
> + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, MICROVM_XHCI_BASE);
> + sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0,
> + x86ms->gsi[MICROVM_XHCI_IRQ]);
> + }
> +
> if (x86_machine_is_acpi_enabled(x86ms) && mms->pcie == ON_OFF_AUTO_ON) {
> /* use topmost 25% of the address space available */
> hwaddr phys_size = (hwaddr)1 << X86_CPU(first_cpu)->phys_bits;
next prev parent reply other threads:[~2020-10-06 10:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-01 8:28 [PATCH v2 0/9] microvm: add usb support Gerd Hoffmann
2020-10-01 8:28 ` [PATCH v2 1/9] acpi: add aml builder stubs Gerd Hoffmann
2020-10-01 8:28 ` [PATCH v2 2/9] usb/xhci: add include/hw/usb/xhci.h header file Gerd Hoffmann
2020-10-01 8:28 ` [PATCH v2 3/9] usb/xhci: add xhci_sysbus_build_aml() helper Gerd Hoffmann
2020-10-01 8:28 ` [PATCH v2 4/9] microvm: add usb support Gerd Hoffmann
2020-10-06 10:03 ` Igor Mammedov [this message]
2020-10-12 6:45 ` Gerd Hoffmann
2020-10-01 8:28 ` [PATCH v2 5/9] tests/acpi: allow updates for expected data files Gerd Hoffmann
2020-10-01 8:28 ` [PATCH v2 6/9] tests/acpi: add empty tests/data/acpi/microvm/DSDT.{usb, rtc} files Gerd Hoffmann
2020-10-01 8:28 ` [PATCH v2 7/9] tests/acpi: add microvm usb test Gerd Hoffmann
2020-10-01 8:28 ` [PATCH v2 8/9] tests/acpi: add microvm rtc test Gerd Hoffmann
2020-10-01 8:28 ` [PATCH v2 9/9] tests/acpi: update expected data files Gerd Hoffmann
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=20201006120326.765e4e61@redhat.com \
--to=imammedo@redhat.com \
--cc=ehabkost@redhat.com \
--cc=kraxel@redhat.com \
--cc=lvivier@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
--cc=sai.pavan.boddu@xilinx.com \
--cc=slp@redhat.com \
--cc=thuth@redhat.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).