From nobody Wed Nov 27 20:39:01 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=1697645631; cv=none; d=zohomail.com; s=zohoarc; b=LHj07b3zOKq7LXjjWSBBBBbchvTjKebeaHK9s1Lvw8+vgieJdwsmDipk+Li6dC9vLBjRXKa+IB0Uq1Y83i6j5Rq1bzvVSSbjaT0pcUHViNhfshfyuweyBv++nuRhnTyxy9z08dP40Gyo7hWYljyk5ryh228ORdxpvjcPoJNnceM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697645631; 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=JtV72scEZ0aIgIJr2M3UsprMuFpQzxyn4159zsyAAhOXmzOQeQhBKG3Azg4UNQ3tduZT+Eo0FvGqrXLWWM3fH3Q/xxS33M4NG/olkvFLKyIn3SPdqx92N1OGHYM5gGr8B7teEAWFwBOvxE+MPrNnu7UxJCoXUVyVk/y999t9sH8= 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 1697645631730410.1694555774852; Wed, 18 Oct 2023 09:13:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qt8wX-00010W-TB; Wed, 18 Oct 2023 11:58:46 -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 1qt8vZ-0007lk-Fw for qemu-devel@nongnu.org; Wed, 18 Oct 2023 11:57:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qt8vX-0007LG-20 for qemu-devel@nongnu.org; Wed, 18 Oct 2023 11:57:45 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-70-G7g8suwWPfmJhu9CMMy05w-1; Wed, 18 Oct 2023 11:57:35 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-32cbe54ee03so4138603f8f.1 for ; Wed, 18 Oct 2023 08:57:34 -0700 (PDT) Received: from redhat.com ([2a02:14f:1f2:2037:f34:d61b:7da0:a7be]) by smtp.gmail.com with ESMTPSA id q1-20020adffec1000000b00326b8a0e817sm2390420wrs.84.2023.10.18.08.57.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 08:57:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697644661; 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=M4yNgL2VUbsndl3p2MfjAddbOmyhbc1UHBsubgAsK1stgyKt68hRvla8dgrMMaVO/CV84U ZOeneTXwgvF+OVCyCuvzh9n3mKhJoQirIjp8N+nqHNy0yKrslyP7H1pgZfuvRmtM25OfQa l6S5lTIU0dmc18pC8A7b53xKbWTUZj8= X-MC-Unique: G7g8suwWPfmJhu9CMMy05w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697644653; x=1698249453; 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=uoxfrneY1Iks+c9oRDNBJwwtGBtqxCuUpOyvvgFmpUNIbqv0lFTdV0Y2sxQb3nVjjD Y8MDPVGC092PiDVvEmN5eo6yIO+EsOE2FsihZhfC2OxtXNdMJLT1gfgfbnEOaW2Gmapq NTMn31/q5B7ThgtwjeB6wasQMIXBY0vjgsBnnhsGavVyiR2JVUEx81JLlSRzMftgKAN/ r2enbcGLXHNVtfxQi1G7DpaSw5vB8VOGfEweUu9RWDnaf0jEVkvQ3o6z0TB/rMIQKish /DyTj1fRV9GG4ciS2ltDHCoCnkNGYgifmYzrbKICoEJageYCEgKm+8IbrOT+FHmbxQYS HMAg== X-Gm-Message-State: AOJu0YxCVjkmgk5EYI4ysjxFkA5DUWFXBs3qOTiAW/LmgC/MalFHZGm5 EKK+nFFPrYOr1hvfDPUOhX0HxB13sfDIH/qSqITL7VXxp7t46jJzZfijuxr+axXPLUsHruGUdkG YFzirMIFY2bp7hILtzxXQMcicd7nZqXmrGzkFNRdCn5vBoOViL62t1xp9+IRm/sNbaYMAqjQ= X-Received: by 2002:a5d:490b:0:b0:32d:ae31:458f with SMTP id x11-20020a5d490b000000b0032dae31458fmr4423380wrq.30.1697644653449; Wed, 18 Oct 2023 08:57:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEdG3HREpZJ9H3ywi/AFPe0m0pBl79Wa5vrkvXCUvHHirNFuC0J3vyJZ7ebXEBLRkQVGwZE1w== X-Received: by 2002:a5d:490b:0:b0:32d:ae31:458f with SMTP id x11-20020a5d490b000000b0032dae31458fmr4423359wrq.30.1697644653073; Wed, 18 Oct 2023 08:57:33 -0700 (PDT) Date: Wed, 18 Oct 2023 11:57:28 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum , =?utf-8?B?SGVydsOp?= Poussineau , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Aurelien Jarno Subject: [PULL 54/83] hw/isa/piix3: Create USB controller in host device Message-ID: <3dc892613e32f09b6830fcbe3a3247e9cec88aaf.1697644299.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.133.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_H3=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: 1697645632923100017 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