From nobody Mon Apr 29 14:42:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1543614388091659.3297426204385; Fri, 30 Nov 2018 13:46:28 -0800 (PST) Received: from localhost ([::1]:34714 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSqc4-0004lU-4w for importer@patchew.org; Fri, 30 Nov 2018 16:46:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50891) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSqb9-0004So-OZ for qemu-devel@nongnu.org; Fri, 30 Nov 2018 16:45:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSqb6-0003Vk-J7 for qemu-devel@nongnu.org; Fri, 30 Nov 2018 16:45:19 -0500 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:35513) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gSqb6-0003Sa-Ch for qemu-devel@nongnu.org; Fri, 30 Nov 2018 16:45:16 -0500 Received: by mail-wm1-x344.google.com with SMTP id c126so354390wmh.0 for ; Fri, 30 Nov 2018 13:45:16 -0800 (PST) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id y138sm263039wmc.16.2018.11.30.13.45.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Nov 2018 13:45:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=kqWJSpoH/gtgAIbWtEMDqJ6yfBmz5D6JUjZKVqfG13s=; b=QWo01WfaODguBT2tfeZHYUMyRiIuJWUM9qzOq/btWTOBUEO3CIZJRhdorYvzxrKQGP nAa7o4rvgS5df7BcLp3kChUpHnBwQs4CEkyq0NY8WtnLy0ov8xVUDOdPPZ3fpuzT4WDJ TL2LQzjIhS0PbXo+YXJtFbKGFR7dj83kpdy49pxV0e9SIs47C212DMrb5CBW97Qhcucj 6r59Z+HZa+eggXkjFjrNrgR8T3Bc8QnUKZzbx3U+4NPSHJUrpxcnvuRGTPLioEhHkw+z 7HkYSe7rQKUTRRP8kkGf/5hH67ts9fcXtVDAW3eR6DnwwVmWG1BUHShDCF0EUF5XIYjs FkpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=kqWJSpoH/gtgAIbWtEMDqJ6yfBmz5D6JUjZKVqfG13s=; b=qty513SfTG51Q8hlokNsvEXogCvjvEqdzjWoKa8aK6rBcxFkvnI7+nU4czivEu96ca R92ie3auhf9FKor1xu+dSyezCb4mBleut6/Q5XiweUSxKMJXXEto2XhGKmvFW8TQC5xi mED8h3YcgOKotZfL1yFwEontsuTYcSRJxulMqIEX+ZZ+ls79QM0zmHLzSQKUYrpdptyH SI/rT8lEGpGh7MNqMZvRbwEEz/mmkfRasHMhMeicaRKCCT1IXlKsYMqC3sdLtBirNOGV NvllDv7iHZY9L9jUUxP0+asqqEAj9MtjFkWN23wRoZQ5sd8EGgmkhDw/URzdjGgx6ESD svZA== X-Gm-Message-State: AA+aEWYmSuvAH3YkTCNBkAe9KQU5aFKqyuJYALqc4wMKbdc7B0RGmD9P qMTJSZc/8oQphS2wnPkUxO/xVC83 X-Google-Smtp-Source: AFSGD/VdteFF3bR/yL8FUZOW4hb0rN7TZcEvrYVU5fRPIn3574b8NJI7I97gYU0x6O0ZgbjlfaODlA== X-Received: by 2002:a1c:5dd1:: with SMTP id r200mr357910wmb.93.1543614314710; Fri, 30 Nov 2018 13:45:14 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 30 Nov 2018 22:45:12 +0100 Message-Id: <1543614312-54253-1-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 Subject: [Qemu-devel] [PATCH for-4.0] usb: move ehci_create_ich9_with_companions to hw/i386 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kraxel@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This function is only needed when Q35 is in use. Moving it to the same file that uses it lets you disable the entire USB subsystem in x86_64-softmmu.mak; of course doing that will cause -usb to break horribly, but one thing at a time. Signed-off-by: Paolo Bonzini --- hw/i386/pc_q35.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++= +++- hw/usb/hcd-ehci-pci.c | 53 -----------------------------------------------= -- include/hw/usb.h | 2 -- 3 files changed, 54 insertions(+), 56 deletions(-) diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index ce38129..d2c80c9 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -58,6 +58,59 @@ /* ICH9 AHCI has 6 ports */ #define MAX_SATA_PORTS 6 =20 +struct ehci_companions { + const char *name; + int func; + int port; +}; + +static const struct ehci_companions ich9_1d[] =3D { + { .name =3D "ich9-usb-uhci1", .func =3D 0, .port =3D 0 }, + { .name =3D "ich9-usb-uhci2", .func =3D 1, .port =3D 2 }, + { .name =3D "ich9-usb-uhci3", .func =3D 2, .port =3D 4 }, +}; + +static const struct ehci_companions ich9_1a[] =3D { + { .name =3D "ich9-usb-uhci4", .func =3D 0, .port =3D 0 }, + { .name =3D "ich9-usb-uhci5", .func =3D 1, .port =3D 2 }, + { .name =3D "ich9-usb-uhci6", .func =3D 2, .port =3D 4 }, +}; + +static int ehci_create_ich9_with_companions(PCIBus *bus, int slot) +{ + const struct ehci_companions *comp; + PCIDevice *ehci, *uhci; + BusState *usbbus; + const char *name; + int i; + + switch (slot) { + case 0x1d: + name =3D "ich9-usb-ehci1"; + comp =3D ich9_1d; + break; + case 0x1a: + name =3D "ich9-usb-ehci2"; + comp =3D ich9_1a; + break; + default: + return -1; + } + + ehci =3D pci_create_multifunction(bus, PCI_DEVFN(slot, 7), true, name); + qdev_init_nofail(&ehci->qdev); + usbbus =3D QLIST_FIRST(&ehci->qdev.child_bus); + + for (i =3D 0; i < 3; i++) { + uhci =3D pci_create_multifunction(bus, PCI_DEVFN(slot, comp[i].fun= c), + true, comp[i].name); + qdev_prop_set_string(&uhci->qdev, "masterbus", usbbus->name); + qdev_prop_set_uint32(&uhci->qdev, "firstport", comp[i].port); + qdev_init_nofail(&uhci->qdev); + } + return 0; +} + /* PC hardware initialisation */ static void pc_q35_init(MachineState *machine) { @@ -257,7 +310,7 @@ static void pc_q35_init(MachineState *machine) idebus[0] =3D idebus[1] =3D NULL; } =20 - if (0 && machine_usb(machine)) { + if (machine_usb(machine)) { /* Should we create 6 UHCI according to ich9 spec? */ ehci_create_ich9_with_companions(host_bus, 0x1d); } diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c index 8c0fc53..69abbf7 100644 --- a/hw/usb/hcd-ehci-pci.c +++ b/hw/usb/hcd-ehci-pci.c @@ -230,56 +230,3 @@ static void ehci_pci_register_types(void) } =20 type_init(ehci_pci_register_types) - -struct ehci_companions { - const char *name; - int func; - int port; -}; - -static const struct ehci_companions ich9_1d[] =3D { - { .name =3D "ich9-usb-uhci1", .func =3D 0, .port =3D 0 }, - { .name =3D "ich9-usb-uhci2", .func =3D 1, .port =3D 2 }, - { .name =3D "ich9-usb-uhci3", .func =3D 2, .port =3D 4 }, -}; - -static const struct ehci_companions ich9_1a[] =3D { - { .name =3D "ich9-usb-uhci4", .func =3D 0, .port =3D 0 }, - { .name =3D "ich9-usb-uhci5", .func =3D 1, .port =3D 2 }, - { .name =3D "ich9-usb-uhci6", .func =3D 2, .port =3D 4 }, -}; - -int ehci_create_ich9_with_companions(PCIBus *bus, int slot) -{ - const struct ehci_companions *comp; - PCIDevice *ehci, *uhci; - BusState *usbbus; - const char *name; - int i; - - switch (slot) { - case 0x1d: - name =3D "ich9-usb-ehci1"; - comp =3D ich9_1d; - break; - case 0x1a: - name =3D "ich9-usb-ehci2"; - comp =3D ich9_1a; - break; - default: - return -1; - } - - ehci =3D pci_create_multifunction(bus, PCI_DEVFN(slot, 7), true, name); - qdev_init_nofail(&ehci->qdev); - usbbus =3D QLIST_FIRST(&ehci->qdev.child_bus); - - for (i =3D 0; i < 3; i++) { - uhci =3D pci_create_multifunction(bus, PCI_DEVFN(slot, comp[i].fun= c), - true, comp[i].name); - qdev_prop_set_string(&uhci->qdev, "masterbus", usbbus->name); - qdev_prop_set_uint32(&uhci->qdev, "firstport", comp[i].port); - qdev_init_nofail(&uhci->qdev); - } - return 0; -} diff --git a/include/hw/usb.h b/include/hw/usb.h index a5080ad..4961405 100644 --- a/include/hw/usb.h +++ b/include/hw/usb.h @@ -593,8 +593,6 @@ const char *usb_device_get_product_desc(USBDevice *dev); =20 const USBDesc *usb_device_get_usb_desc(USBDevice *dev); =20 -int ehci_create_ich9_with_companions(PCIBus *bus, int slot); - /* quirks.c */ =20 /* In bulk endpoints are streaming data sources (iow behave like isoc eps)= */ --=20 1.8.3.1