From patchwork Wed Sep 16 11:41:03 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: 1365192 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-xilinx-onmicrosoft-com header.b=cI5S33xS; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4Bryn86fX8z9sTK for ; Wed, 16 Sep 2020 21:39:39 +1000 (AEST) Received: from localhost ([::1]:36774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kIVmi-0006OH-UR for incoming@patchwork.ozlabs.org; Wed, 16 Sep 2020 07:39:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52140) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kIVmE-0006Km-0Y for qemu-devel@nongnu.org; Wed, 16 Sep 2020 07:39:06 -0400 Received: from mail-dm6nam11on2083.outbound.protection.outlook.com ([40.107.223.83]:45472 helo=NAM11-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 1kIVmB-0006p6-Jr for qemu-devel@nongnu.org; Wed, 16 Sep 2020 07:39:05 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CbQG7IxDTVvWFpEFCjYmtPo20ZhVxtdQsaI9LkMVkAr4N5GgJ04nm5CGCCWJ2fybl2zETpvwUW8KfGitiStZan+6NqxVGw9GX2oeUA4cC7U5i0d1+Ha8WZgzHAg2SwMrDyM8Ru8Sz2MtP/t+jgQIHjerXYPDFSW13H2+ocWfjxScejiG4wWJeug0QwLI3m8q+Tux+DI1qK8E5grvgMQHj7NuxbQxrIR/wUNVa0j7nx4h5XBEMEC2VjOf7pHI2019rUikFJoDejvXQc7FCaxR2poHL+ZopXKD7yy9Y8N9w8ATtbgGkgwp9Sca2jSVD7/0FHNGAtb4BTEXNeZeVKGYCA== 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=PGY80Zrn4ZKsD7lZfV9kljP5vX0JAfYy1pIBgt1vsug=; b=Oqhg2LpO99Ibs7LDB0wO+Kd606sh4lXcSMYNs3a9ziSK8DcVIb6b2n7knZuzPLOasobNyp7q62XZ6kYxNLbECfaAAFPSFKkwjbwmPdevvYeA7mdHJu49WZkvwBSWgzSaqzIT4UGRILqxadS3DpHtG47saFBlQBmbFffRrW5v/89XE+e06EzKNkD+82RXhmPTKLn1u19ouxlKTLTM9673MrkkPEZgtGTH8t2H1bX09TZ3Dl4lgKPvGhsqotXHcCYkmmTFgCmCjaWsDzoPOGiWsVb2gsj95YOJ6Wuuq1p6hMsWYnnvtVWAnx5OI8nGvlwvHg8OCN3CzJKwKUI8LVwoVw== 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=PGY80Zrn4ZKsD7lZfV9kljP5vX0JAfYy1pIBgt1vsug=; b=cI5S33xS4ySZMyk15o1mXbZoVwRUgxK8MbJCdoLg5rKrx109OjijhVqT1vNc8n/F6VdTsA1+OUHxykZfXHjK3jIJmQ5yPAjxM4ollG3/3vC3m+tjSJd3o8M4Q1f6wtJKDExLv48M3MxHCgJJzS6ueh/ggYjvJZ8cdeAdKkurauc= Received: from MN2PR05CA0048.namprd05.prod.outlook.com (2603:10b6:208:236::17) by DM6PR02MB6443.namprd02.prod.outlook.com (2603:10b6:5:17a::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11; Wed, 16 Sep 2020 11:39:00 +0000 Received: from BL2NAM02FT027.eop-nam02.prod.protection.outlook.com (2603:10b6:208:236:cafe::60) by MN2PR05CA0048.outlook.office365.com (2603:10b6:208:236::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11 via Frontend Transport; Wed, 16 Sep 2020 11:39:00 +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 BL2NAM02FT027.mail.protection.outlook.com (10.152.77.160) with Microsoft SMTP Server id 15.20.3370.16 via Frontend Transport; Wed, 16 Sep 2020 11:39:00 +0000 Received: from [149.199.38.66] (port=45657 helo=smtp.xilinx.com) by xsj-pvapsmtpgw01 with esmtp (Exim 4.90) (envelope-from ) id 1kIVm1-0001bi-Gp; Wed, 16 Sep 2020 04:38:53 -0700 Received: from [127.0.0.1] (helo=xsj-smtp-dlp2.xlnx.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.63) (envelope-from ) id 1kIVm8-0007Nd-1s; Wed, 16 Sep 2020 04:39:00 -0700 Received: from xsj-pvapsmtp01 (mailman.xilinx.com [149.199.38.66]) by xsj-smtp-dlp2.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id 08GBcwPo028181; Wed, 16 Sep 2020 04:38:59 -0700 Received: from [10.140.6.35] (helo=xhdsaipava40.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1kIVm6-0007NL-FJ; Wed, 16 Sep 2020 04:38:58 -0700 Received: by xhdsaipava40.xilinx.com (Postfix, from userid 14131) id EB50C13C0567; Wed, 16 Sep 2020 17:12:41 +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 v6 2/7] usb/hcd-xhci: Move qemu-xhci device to hcd-xhci-pci.c Date: Wed, 16 Sep 2020 17:11:03 +0530 Message-Id: <1600256469-13130-3-git-send-email-sai.pavan.boddu@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1600256469-13130-1-git-send-email-sai.pavan.boddu@xilinx.com> References: <1600256469-13130-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: 0afa5eab-781c-4a70-01da-08d85a351b05 X-MS-TrafficTypeDiagnostic: DM6PR02MB6443: 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: CLUNMPoK/P1uByjNqRErcO+w0CkXlFDseu8My/1xH2YdqboUd6WapCBPtRNBBYfCurHd7nI0d1mJ9VIQP5U7u7iI1UbR0TO00qEqLzl2ApebW+JOGj6SmVPNXd88zCJ1AwCYzPdYc7thtHNyfPd03eJznHQKkEt/iuc+7ccTJhm0mZzEupxz51OC5XfuVZu6vPHwBISIOckaaYW2fwc6ZHWu3fL3LxwPmbcFHFttlhfGOyra5KroZysXYXZ5amWXoxBmMoX//5NHSY6+mduKP4ywN/i8ipMEYRcJhMqANRYiIupmt8Ed8Wtj8OyY4tUmknhc0qpKBZWqiV4N0hd7mJurl52B7Q2OO1D/RsVGku2PJLAGUujDlGe7dw7X9BkZSubiyUtwOUBz5b6VojCTOaFSxCY+5Mfp7NvG2ShvbYLyjwMSe1TLPECVf3NeWEIYQHmiBnsZbYLOOULzgwuMBsMHTVy+qH8bSTtAtGdXORcX3DqjMwTP/+LZCIlc6LGk 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:(136003)(396003)(376002)(346002)(39860400002)(46966005)(6636002)(82310400003)(8676002)(110136005)(54906003)(2906002)(7416002)(36756003)(70586007)(47076004)(82740400003)(5660300002)(70206006)(356005)(81166007)(83380400001)(2616005)(107886003)(4326008)(478600001)(316002)(26005)(186003)(426003)(6266002)(42186006)(336012)(6666004)(8936002)(2004002); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2020 11:39:00.5864 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0afa5eab-781c-4a70-01da-08d85a351b05 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: BL2NAM02FT027.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR02MB6443 Received-SPF: pass client-ip=40.107.223.83; envelope-from=saipava@xilinx.com; helo=NAM11-DM6-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/16 07:39:02 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_PASS=-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 , qemu-devel@nongnu.org, Paul Zimmerman , Sai Pavan Boddu , Alistair Francis , Ying Fang , =?utf-8?q?=27Philippe_Mathieu-Daud=C3=A9?= =?utf-8?q?=27?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.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 2570937..dab3424 100644 --- a/hw/usb/hcd-xhci.h +++ b/hw/usb/hcd-xhci.h @@ -23,6 +23,8 @@ #define HW_USB_HCD_XHCI_H #include "qom/object.h" +#include "hw/usb.h" + #define TYPE_XHCI "base-xhci" #define TYPE_NEC_XHCI "nec-usb-xhci" #define TYPE_QEMU_XHCI "qemu-xhci" @@ -231,4 +233,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'))