From patchwork Thu Sep 10 06:31:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sai Pavan Boddu X-Patchwork-Id: 11766713 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D4551698 for ; Thu, 10 Sep 2020 06:29:17 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 50AE5207EA for ; Thu, 10 Sep 2020 06:29:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.b="Yenx4zbo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 50AE5207EA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:41012 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kGG56-0006bE-6a for patchwork-qemu-devel@patchwork.kernel.org; Thu, 10 Sep 2020 02:29:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53758) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kGG3Z-0004uc-1D for qemu-devel@nongnu.org; Thu, 10 Sep 2020 02:27:41 -0400 Received: from mail-dm6nam08on2049.outbound.protection.outlook.com ([40.107.102.49]:8961 helo=NAM04-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kGG3W-0006CN-RM for qemu-devel@nongnu.org; Thu, 10 Sep 2020 02:27:40 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GRmSTTVa2e9bJMVlcGcQuwiFPczOpUd24+xkRJ5Bba4LyWErgUbR9GWRdmJUONCDRn0y1awJGciDfrNaa6h6cSKe/kksbua1AAfmQdm7fn0YhTJVluLFlodkwW6Ni405t5kijSV1ajRtYxUeA3dizXPkTYNbccGtf7nkchqNna60k7/bRh/JJrtlfNw1QxgHawKBjY8iu6QzU8LfDEynWxFbYGJ/us//jYXmYlfLTlUALp0o0XogEyinS1jXHBnVgLeunQZE5n17K+joCQnCIiTZirfdJOPOltJjieCg48+dQZm5TemWy+a807DNejRoUc4hnBAa0U258g7bwtWA9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wrtb83AeBeQOiLVRaElioTxz2aYNeujZs44smziryV8=; b=h/sOKsfrNypdW7r6TXF2vhVNdVtkoidZJvjzAFFx0LfRnVqSHchBabt4zVM5+iB/1PPRyXK7bEjEJ96MZWE8u+DKLhHYeKi7UcaSH7eK2me0BaYYsbAMlCM2X5C61gEppv0gxvwrHKFfH31H3LSPBln3nPhIb7lh7X9DisL1pD+qLM9EW0SPQhTM3LkOYhp+ysOlQRRFoK7n1Uzl9FyXTeydXCrLHenkoznIm/D3PIWQzNHKbXy1MaFG4oMqNQdka6J/a5Fp6TC8MGLuVfQWUo1OAXpgo7wJA5aYI5QJVl0gUo9rce6aKbONrIEWvkH2sX3oYS7gz1Z7oLa0IP5q7A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.60.83) smtp.rcpttodomain=wdc.com smtp.mailfrom=xilinx.com; dmarc=bestguesspass action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wrtb83AeBeQOiLVRaElioTxz2aYNeujZs44smziryV8=; b=Yenx4zboepvuLIh1Iu7++HrMgU52SMdopjxzXQfS0zb8oFgZAUvsbgqoE2wjXovfLw21Ad+oQ9X2suNoIWyoXNsRz0DLx1Ka9xmw8Sz8G6YdBwHGDN83F8HNpY8/PymQNhh0JgQpkur85AvUuikzwG30LG4j6nr+Uh8vaUfXinA= Received: from MN2PR16CA0038.namprd16.prod.outlook.com (2603:10b6:208:234::7) by MN2PR02MB6720.namprd02.prod.outlook.com (2603:10b6:208:1db::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3348.15; Thu, 10 Sep 2020 06:27:35 +0000 Received: from BL2NAM02FT013.eop-nam02.prod.protection.outlook.com (2603:10b6:208:234:cafe::d8) by MN2PR16CA0038.outlook.office365.com (2603:10b6:208:234::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16 via Frontend Transport; Thu, 10 Sep 2020 06:27:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.83 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.83; helo=xsj-pvapsmtpgw01; Received: from xsj-pvapsmtpgw01 (149.199.60.83) by BL2NAM02FT013.mail.protection.outlook.com (10.152.77.19) with Microsoft SMTP Server id 15.20.3370.16 via Frontend Transport; Thu, 10 Sep 2020 06:27:35 +0000 Received: from [149.199.38.66] (port=57244 helo=smtp.xilinx.com) by xsj-pvapsmtpgw01 with esmtp (Exim 4.90) (envelope-from ) id 1kGG3B-0000JC-T5; Wed, 09 Sep 2020 23:27:17 -0700 Received: from [127.0.0.1] (helo=xsj-smtp-dlp1.xlnx.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.63) (envelope-from ) id 1kGG3S-0001VR-Bk; Wed, 09 Sep 2020 23:27:34 -0700 Received: from xsj-pvapsmtp01 (mailhub.xilinx.com [149.199.38.66]) by xsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id 08A6RXme029631; Wed, 9 Sep 2020 23:27:33 -0700 Received: from [10.140.6.35] (helo=xhdsaipava40.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1kGG3Q-0001V6-Oy; Wed, 09 Sep 2020 23:27:33 -0700 Received: by xhdsaipava40.xilinx.com (Postfix, from userid 14131) id 3106213C0567; Thu, 10 Sep 2020 12:01:33 +0530 (IST) From: Sai Pavan Boddu To: Peter Maydell , Markus Armbruster , =?utf-8?q?=27Marc-Andr=C3=A9_Lureau?= =?utf-8?q?=27?= , Paolo Bonzini , Gerd Hoffmann , Edgar Iglesias , Francisco Eduardo Iglesias Subject: [PATCH v5 2/7] usb/hcd-xhci: Move qemu-xhci device to hcd-xhci-pci.c Date: Thu, 10 Sep 2020 12:01:04 +0530 Message-Id: <1599719469-24062-3-git-send-email-sai.pavan.boddu@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1599719469-24062-1-git-send-email-sai.pavan.boddu@xilinx.com> References: <1599719469-24062-1-git-send-email-sai.pavan.boddu@xilinx.com> X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.2.0.1013-23620.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: e5e9cfe3-f89f-4860-7661-08d855529b19 X-MS-TrafficTypeDiagnostic: MN2PR02MB6720: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6lag7HSA9ALxAlbEaTZzn3xW2grskDLP9WeQLJkV9Hd97EYX+vjTJUeUD6jkB2hirgUvFT+Q6FK578vWK6uVQ0x9PiIEzbt9kK6H1op86IyUBhseendr4vynGRHk5p8CySoG148Gx0nc5+9Z83n8s4PqWE41ZRwJr1ng58p6sCtY3myNa7/Z0xGSRNKDpU7lmQA1gVjHrQuUnSD/hIjKch0tHs1XBNkvSD38os0j3+TJIgayxtkgH6/I54/vBBVwsANDp/pd/uGXNitTqG1ztDNzCA9K8KVSQN4ASZOODzkxxl4AukLuc+lBqM+SRMI9SbZiHvWejqOvh/F/HpOsf6T4Fnna4HNjmZD8r2wc8LZM05oxiRDWJrZfI2ZyDzNZyib5Oo/8VaCGBY4RC2yLpA+UuspX8X+Kato3WO30b2ksBPMDjLkcNw+sScDvunR28uIXx8W1odF+LXkKIHuptIxD+4XSRSUSI9yyKoIoWVowv+3eGkjq7xgofcluRuU8 X-Forefront-Antispam-Report: CIP:149.199.60.83; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:xsj-pvapsmtpgw01; PTR:unknown-60-83.xilinx.com; CAT:NONE; SFS:(346002)(396003)(376002)(136003)(39860400002)(46966005)(6636002)(7416002)(110136005)(107886003)(4326008)(8936002)(478600001)(6266002)(42186006)(8676002)(316002)(2906002)(54906003)(5660300002)(336012)(186003)(6666004)(82740400003)(70586007)(70206006)(2616005)(82310400003)(356005)(26005)(426003)(83380400001)(36756003)(81166007)(47076004)(2004002); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2020 06:27:35.0601 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e5e9cfe3-f89f-4860-7661-08d855529b19 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.83]; Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-AuthSource: BL2NAM02FT013.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR02MB6720 Received-SPF: pass client-ip=40.107.102.49; envelope-from=saipava@xilinx.com; helo=NAM04-DM6-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/10 02:27:37 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Vikram Garhwal , sai.pavan.boddu@xilinx.com, qemu-devel@nongnu.org, Paul Zimmerman , Alistair Francis , Ying Fang , =?utf-8?q?=27Philippe_Mathieu-Daud=C3=A9?= =?utf-8?q?=27?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Move pci specific devices to new file. This set the environment to move all pci specific hooks in hcd-xhci.c to hcd-xhci-pci.c. Signed-off-by: Sai Pavan Boddu --- hw/usb/Kconfig | 6 +++++ hw/usb/hcd-xhci-pci.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++ hw/usb/hcd-xhci.c | 33 ++------------------------ hw/usb/hcd-xhci.h | 4 ++++ hw/usb/meson.build | 1 + 5 files changed, 79 insertions(+), 31 deletions(-) create mode 100644 hw/usb/hcd-xhci-pci.c diff --git a/hw/usb/Kconfig b/hw/usb/Kconfig index 3fc8fbe..bab582f 100644 --- a/hw/usb/Kconfig +++ b/hw/usb/Kconfig @@ -36,6 +36,12 @@ config USB_XHCI depends on PCI select USB +config USB_XHCI_PCI + bool + default y if PCI_DEVICES + depends on PCI + select USB_XHCI + config USB_XHCI_NEC bool default y if PCI_DEVICES diff --git a/hw/usb/hcd-xhci-pci.c b/hw/usb/hcd-xhci-pci.c new file mode 100644 index 0000000..1562757 --- /dev/null +++ b/hw/usb/hcd-xhci-pci.c @@ -0,0 +1,66 @@ +/* + * USB xHCI controller with PCI bus emulation + * + * SPDX-FileCopyrightText: 2011 Securiforest + * SPDX-FileContributor: Hector Martin + * SPDX-sourceInfo: Based on usb-ohci.c, emulates Renesas NEC USB 3.0 + * SPDX-FileCopyrightText: 2020 Xilinx + * SPDX-FileContributor: Sai Pavan Boddu + * SPDX-sourceInfo: Moved the pci specific content for hcd-xhci.c to + * hcd-xhci-pci.c + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ +#include "qemu/osdep.h" +#include "hw/pci/pci.h" +#include "hw/qdev-properties.h" +#include "hw/pci/msi.h" +#include "hw/pci/msix.h" +#include "hcd-xhci.h" +#include "trace.h" +#include "qapi/error.h" + +static void qemu_xhci_class_init(ObjectClass *klass, void *data) +{ + PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); + + k->vendor_id = PCI_VENDOR_ID_REDHAT; + k->device_id = PCI_DEVICE_ID_REDHAT_XHCI; + k->revision = 0x01; +} + +static void qemu_xhci_instance_init(Object *obj) +{ + XHCIState *xhci = XHCI(obj); + + xhci->msi = ON_OFF_AUTO_OFF; + xhci->msix = ON_OFF_AUTO_AUTO; + xhci->numintrs = MAXINTRS; + xhci->numslots = MAXSLOTS; + xhci_set_flag(xhci, XHCI_FLAG_SS_FIRST); +} + +static const TypeInfo qemu_xhci_info = { + .name = TYPE_QEMU_XHCI, + .parent = TYPE_XHCI, + .class_init = qemu_xhci_class_init, + .instance_init = qemu_xhci_instance_init, +}; + +static void xhci_register_types(void) +{ + type_register_static(&qemu_xhci_info); +} + +type_init(xhci_register_types) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 254cf1e..f927567 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -23,7 +23,6 @@ #include "qemu/timer.h" #include "qemu/module.h" #include "qemu/queue.h" -#include "hw/usb.h" #include "migration/vmstate.h" #include "hw/pci/pci.h" #include "hw/qdev-properties.h" @@ -429,12 +428,12 @@ static const char *ep_state_name(uint32_t state) ARRAY_SIZE(ep_state_names)); } -static bool xhci_get_flag(XHCIState *xhci, enum xhci_flags bit) +bool xhci_get_flag(XHCIState *xhci, enum xhci_flags bit) { return xhci->flags & (1 << bit); } -static void xhci_set_flag(XHCIState *xhci, enum xhci_flags bit) +void xhci_set_flag(XHCIState *xhci, enum xhci_flags bit) { xhci->flags |= (1 << bit); } @@ -3730,37 +3729,9 @@ static const TypeInfo xhci_info = { }, }; -static void qemu_xhci_class_init(ObjectClass *klass, void *data) -{ - PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); - - k->vendor_id = PCI_VENDOR_ID_REDHAT; - k->device_id = PCI_DEVICE_ID_REDHAT_XHCI; - k->revision = 0x01; -} - -static void qemu_xhci_instance_init(Object *obj) -{ - XHCIState *xhci = XHCI(obj); - - xhci->msi = ON_OFF_AUTO_OFF; - xhci->msix = ON_OFF_AUTO_AUTO; - xhci->numintrs = MAXINTRS; - xhci->numslots = MAXSLOTS; - xhci_set_flag(xhci, XHCI_FLAG_SS_FIRST); -} - -static const TypeInfo qemu_xhci_info = { - .name = TYPE_QEMU_XHCI, - .parent = TYPE_XHCI, - .class_init = qemu_xhci_class_init, - .instance_init = qemu_xhci_instance_init, -}; - static void xhci_register_types(void) { type_register_static(&xhci_info); - type_register_static(&qemu_xhci_info); } type_init(xhci_register_types) diff --git a/hw/usb/hcd-xhci.h b/hw/usb/hcd-xhci.h index 2cd4f70..14b3ee9 100644 --- a/hw/usb/hcd-xhci.h +++ b/hw/usb/hcd-xhci.h @@ -22,6 +22,8 @@ #ifndef HW_USB_HCD_XHCI_H #define HW_USB_HCD_XHCI_H +#include "hw/usb.h" + #define TYPE_XHCI "base-xhci" #define TYPE_NEC_XHCI "nec-usb-xhci" #define TYPE_QEMU_XHCI "qemu-xhci" @@ -230,4 +232,6 @@ struct XHCIState { bool nec_quirks; }; +bool xhci_get_flag(XHCIState *xhci, enum xhci_flags bit); +void xhci_set_flag(XHCIState *xhci, enum xhci_flags bit); #endif diff --git a/hw/usb/meson.build b/hw/usb/meson.build index b7c7ff2..90dc54f 100644 --- a/hw/usb/meson.build +++ b/hw/usb/meson.build @@ -21,6 +21,7 @@ softmmu_ss.add(when: 'CONFIG_USB_EHCI', if_true: files('hcd-ehci.c')) softmmu_ss.add(when: 'CONFIG_USB_EHCI_PCI', if_true: files('hcd-ehci-pci.c')) softmmu_ss.add(when: 'CONFIG_USB_EHCI_SYSBUS', if_true: files('hcd-ehci.c', 'hcd-ehci-sysbus.c')) softmmu_ss.add(when: 'CONFIG_USB_XHCI', if_true: files('hcd-xhci.c')) +softmmu_ss.add(when: 'CONFIG_USB_XHCI_PCI', if_true: files('hcd-xhci-pci.c')) softmmu_ss.add(when: 'CONFIG_USB_XHCI_NEC', if_true: files('hcd-xhci-nec.c')) softmmu_ss.add(when: 'CONFIG_USB_MUSB', if_true: files('hcd-musb.c')) softmmu_ss.add(when: 'CONFIG_USB_DWC2', if_true: files('hcd-dwc2.c'))