From nobody Wed Nov 27 17:32:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1697966913; cv=none; d=zohomail.com; s=zohoarc; b=WmwtrP3AUS61sOhycKHQDlwq10biv1nPJ9xF1y7dXKxbK2ZLhNq+NXZEALLzPGkluxkr/yw1TIaF1CILHLUZVjmn9vNBKWWb5kniNzUWmmLdc9VExcSisISy3AlpG3Z1xsS5s61TOY/eiz+cWlDzHZYnSBb3oMXz0vxDHB4IHuo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697966913; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NXZETaxS2RqyHqeZK3eUSLD+xTQl4eJ2LtfwIT3r2X0=; b=SKUEvchei8kGjviocF/ZCxOn3spcNh68S4g7ooQUap2GDrQuQt4Txg7h7oYkHEdBfIo8uO+WK8m5qKF+7aoN7AyRiwGrJlMZxUYij055CNKdu8F97F4vgTQoHwL6/8NUCVXd5Q3BSnmDCy5Ilmz2gncJijCd5uMLWyd85fLOD1o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1697966913729963.5087730846304; Sun, 22 Oct 2023 02:28:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1quUhC-0002Wr-Aa; Sun, 22 Oct 2023 05:24:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1quUh9-0002CZ-Tw for qemu-devel@nongnu.org; Sun, 22 Oct 2023 05:24:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1quUh8-0000Z5-48 for qemu-devel@nongnu.org; Sun, 22 Oct 2023 05:24:27 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-433-gsa2kWlqOm6_oEk9UoDxag-1; Sun, 22 Oct 2023 05:24:23 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-402cd372b8bso15846285e9.2 for ; Sun, 22 Oct 2023 02:24:23 -0700 (PDT) Received: from redhat.com ([2.52.1.53]) by smtp.gmail.com with ESMTPSA id fm12-20020a05600c0c0c00b004030e8ff964sm11368595wmb.34.2023.10.22.02.24.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Oct 2023 02:24:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697966665; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=NXZETaxS2RqyHqeZK3eUSLD+xTQl4eJ2LtfwIT3r2X0=; b=K47SgfNgfechzQwiwsI9vm75LIAFa/6EzlN1fuxo4ovZzc8SScnYhggWBloUZz4vm/rTxL 6Zy7qJMgJXxawzpiB0J0KgcA7dnX6+v2x/xwGdm/HLVCKYS+NSwu88M6n+BjRHkGI9oHNE lrpOXlee8SBJr2Vq83XeOUx7hA/21ec= X-MC-Unique: gsa2kWlqOm6_oEk9UoDxag-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697966662; x=1698571462; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=NXZETaxS2RqyHqeZK3eUSLD+xTQl4eJ2LtfwIT3r2X0=; b=R0DVIXsYDj9OeVK4wyz1AlfCY1WyrClw2oJS01OpZmsdta790cJ2PYvcwx/1oPVcNH mu9pBhC0M6RXf8PCl23eNN8FxVctkgzwx3bZKD77H4SIR8P3j1VTuWA8hZ9728lL6RX5 BQhDfFEQgTDsya5EA6bNVqIbl5J9GBOcThmDIxPMPiCigB1O5GpA8mSzd0sSulw5bXm1 ppViEihwwCJMmzKnMTQA7LSRfctyJpz3g0bzZfYpsxLgxB0TGHjCnpPfhuAbZTfeZIaG 6tKoSRMXV2rPymiDV85C9Q4lKMiNFwpIkGRYFHJnCyh3cvHFOOjRRO0zD+rWCWXl77M4 j75A== X-Gm-Message-State: AOJu0Yw9+bJKEDpGrQxwjqUGnToYn7kQuM7kkf0Dpig1RyYDRtd3kByC pW8wRSiIKs0Vxkl9llyCKXs8r9WqAhYU7ACjKJSwxbwN/+ZpZJB0yIHkgUzs8Ij7kKN1qHpiHTY 2Dw/6P0lqiwgQMEKv7Pj+V+b5JMGQ1hM6cMNIPe43+WxWVaW0E6qCW9PwBEXJ1rja6n8h X-Received: by 2002:a05:600c:3147:b0:405:3b92:2fed with SMTP id h7-20020a05600c314700b004053b922fedmr4576749wmo.26.1697966662143; Sun, 22 Oct 2023 02:24:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFbqjZY0XoTf/hRA51av0QbtdBW1Fz+gY9J5YM8P6yNEMrEhC55FP3hW3gs1NQ5QI7OFPmfTQ== X-Received: by 2002:a05:600c:3147:b0:405:3b92:2fed with SMTP id h7-20020a05600c314700b004053b922fedmr4576732wmo.26.1697966661885; Sun, 22 Oct 2023 02:24:21 -0700 (PDT) Date: Sun, 22 Oct 2023 05:24:16 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Aurelien Jarno , =?utf-8?B?SGVydsOp?= Poussineau Subject: [PULL v3 33/62] hw/isa/piix3: Create USB controller in host device Message-ID: <6fe4464c05f45e726fcfa4a7927f4ed27444a0ca.1697966402.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1697966915344100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Bernhard Beschow The USB controller is an integral part of PIIX3 (function 2). So create it as part of the south bridge. Note that the USB function is optional in QEMU. This is why it gets object_initialize_child()'ed in realize rather than in instance_init. Signed-off-by: Bernhard Beschow Reviewed-by: Michael S. Tsirkin Message-Id: <20231007123843.127151-13-shentey@gmail.com> Signed-off-by: Michael S. Tsirkin --- include/hw/southbridge/piix.h | 4 ++++ hw/i386/pc_piix.c | 7 ++----- hw/isa/piix3.c | 16 ++++++++++++++++ hw/isa/Kconfig | 1 + 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/include/hw/southbridge/piix.h b/include/hw/southbridge/piix.h index 1daeff397c..5cd866f1f2 100644 --- a/include/hw/southbridge/piix.h +++ b/include/hw/southbridge/piix.h @@ -15,6 +15,7 @@ #include "hw/pci/pci_device.h" #include "hw/ide/pci.h" #include "hw/rtc/mc146818rtc.h" +#include "hw/usb/hcd-uhci.h" =20 /* PIRQRC[A:D]: PIRQx Route Control Registers */ #define PIIX_PIRQCA 0x60 @@ -54,12 +55,15 @@ struct PIIXState { =20 MC146818RtcState rtc; PCIIDEState ide; + UHCIState uhci; =20 /* Reset Control Register contents */ uint8_t rcr; =20 /* IO memory region for Reset Control Register (PIIX_RCR_IOPORT) */ MemoryRegion rcr_mem; + + bool has_usb; }; typedef struct PIIXState PIIX3State; =20 diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index c98a997482..8dcd6851d0 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -51,7 +51,6 @@ #include "exec/memory.h" #include "hw/acpi/acpi.h" #include "hw/acpi/piix4.h" -#include "hw/usb/hcd-uhci.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "sysemu/xen.h" @@ -265,6 +264,8 @@ static void pc_init1(MachineState *machine, size_t i; =20 pci_dev =3D pci_new_multifunction(-1, TYPE_PIIX3_DEVICE); + object_property_set_bool(OBJECT(pci_dev), "has-usb", + machine_usb(machine), &error_abort); dev =3D DEVICE(pci_dev); for (i =3D 0; i < ISA_NUM_IRQS; i++) { qdev_connect_gpio_out_named(dev, "isa-irqs", i, x86ms->gsi[i]); @@ -359,10 +360,6 @@ static void pc_init1(MachineState *machine, } #endif =20 - if (pcmc->pci_enabled && machine_usb(machine)) { - pci_create_simple(pci_bus, piix3_devfn + 2, TYPE_PIIX3_USB_UHCI); - } - if (pcmc->pci_enabled && x86_machine_is_acpi_enabled(X86_MACHINE(pcms)= )) { PCIDevice *piix4_pm; =20 diff --git a/hw/isa/piix3.c b/hw/isa/piix3.c index 3f1dabade0..aebc0da23b 100644 --- a/hw/isa/piix3.c +++ b/hw/isa/piix3.c @@ -298,6 +298,16 @@ static void pci_piix3_realize(PCIDevice *dev, Error **= errp) if (!qdev_realize(DEVICE(&d->ide), BUS(pci_bus), errp)) { return; } + + /* USB */ + if (d->has_usb) { + object_initialize_child(OBJECT(dev), "uhci", &d->uhci, + TYPE_PIIX3_USB_UHCI); + qdev_prop_set_int32(DEVICE(&d->uhci), "addr", dev->devfn + 2); + if (!qdev_realize(DEVICE(&d->uhci), BUS(pci_bus), errp)) { + return; + } + } } =20 static void build_pci_isa_aml(AcpiDevAmlIf *adev, Aml *scope) @@ -332,6 +342,11 @@ static void pci_piix3_init(Object *obj) object_initialize_child(obj, "ide", &d->ide, TYPE_PIIX3_IDE); } =20 +static Property pci_piix3_props[] =3D { + DEFINE_PROP_BOOL("has-usb", PIIX3State, has_usb, true), + DEFINE_PROP_END_OF_LIST(), +}; + static void pci_piix3_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -352,6 +367,7 @@ static void pci_piix3_class_init(ObjectClass *klass, vo= id *data) * pc_piix.c's pc_init1() */ dc->user_creatable =3D false; + device_class_set_props(dc, pci_piix3_props); adevc->build_dev_aml =3D build_pci_isa_aml; } =20 diff --git a/hw/isa/Kconfig b/hw/isa/Kconfig index 28345edbb3..1076df69ca 100644 --- a/hw/isa/Kconfig +++ b/hw/isa/Kconfig @@ -37,6 +37,7 @@ config PIIX3 select IDE_PIIX select ISA_BUS select MC146818RTC + select USB_UHCI =20 config PIIX4 bool --=20 MST