From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0084EC433F5 for ; Mon, 4 Apr 2022 10:02:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id A3A17607F7; Mon, 4 Apr 2022 10:02:26 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UppzbRKoAEMT; Mon, 4 Apr 2022 10:02:25 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 834C260C1C; Mon, 4 Apr 2022 10:02:25 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5F431C002C; Mon, 4 Apr 2022 10:02:25 +0000 (UTC) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 650A2C0012 for ; Mon, 4 Apr 2022 10:02:24 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 524D0410E5 for ; Mon, 4 Apr 2022 10:02:24 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp4.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=amd.com Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EhjOJm-y5OI5 for ; Mon, 4 Apr 2022 10:02:23 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on20630.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8a::630]) by smtp4.osuosl.org (Postfix) with ESMTPS id 49993414CB for ; Mon, 4 Apr 2022 10:02:23 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NVrc9lLGGPMRTw595c1yI23Uu7tXbEkGyN3nY1u2rGEY7iZN774IAzXrYvpfLCTtkLcD2PeT9jpR87frTDMIDVFjoOXWFCebHPcv7Kc2RFqXDE2Mm8Ui6CIngGKuQ5v6E2J9Q6zjzJi+ZUaCjzhCNheG2AWWz+rh/fy5ItY/U4Qkt2MaBj80QSoi8BLPGDWXE633GwZfKuNVwtvojKbdIiSJ0Pltn/nlmcwaBrFDggqaqCpGpiT4hINdPMAkuSk5tQS/OojN3E4mfqSboiI+VLq9n93/pYMUr5i4cBwVtVYI0xl92MDyu2m78LSPWczunU3fr8o+mHYQk2qXxmOfYQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+yxUfGvZScc85o3KvRMacIDzekVO6qudJBGtuPWvQ/Q=; b=YP5RvIzOhJDtOerpVDiDaIW70cFRLDJggGWpf+M3tkibxFIEHFLt+q2Acq0dqMswPjAGphjruSvrp1GuXNnPRT9wl1NPkc+Vv0OAmao9f/YJhdOZYRJgcuYvWQgUZujCyQU+8dgc/6kAM7eSajlrOimC+Q+Q22gMIKlU6Rskt6JgyDk7Pdc/7c8JQ54exHwgug9uDCeBRSpIBPDxtFFCTB3p8orJ+ylmYqZTcWjfelVD9ujdkGfYE3TRwz5aiH/0ZlP+TnepqbvLrq1Ycy/GEjBTqGXJU1EcyGjTHVzLPEZULXud9s6/lVI5tha2r39q17XuuMXqLjBaQqHzj0tW5g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.linux-foundation.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+yxUfGvZScc85o3KvRMacIDzekVO6qudJBGtuPWvQ/Q=; b=XhZcbCZCJ8rQ6jxn1u0AV0BFpZ0cqyHWP1waCV+1lEbpNo+VdFns3z+vzgVRp28TaMLO+y/hNMhzTfcgT2IOX2WEfjUS4KvpghAHXN9b6U653s/Sixx8hS9Wmid6ZVgY5kKjwp/qU2O+UXfwaALlv3Yh9VvL6eSiQt7ZHkwdKk4= Received: from BN0PR04CA0020.namprd04.prod.outlook.com (2603:10b6:408:ee::25) by BL1PR12MB5221.namprd12.prod.outlook.com (2603:10b6:208:30b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.31; Mon, 4 Apr 2022 10:02:20 +0000 Received: from BN8NAM11FT025.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ee:cafe::a8) by BN0PR04CA0020.outlook.office365.com (2603:10b6:408:ee::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.31 via Frontend Transport; Mon, 4 Apr 2022 10:02:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT025.mail.protection.outlook.com (10.13.177.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5123.19 via Frontend Transport; Mon, 4 Apr 2022 10:02:19 +0000 Received: from kali.amdval.net (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 4 Apr 2022 05:02:17 -0500 To: , Subject: [RESEND PATCH v1 06/37] iommu/amd: Introduce per PCI segment dev_data_list Date: Mon, 4 Apr 2022 15:29:52 +0530 Message-ID: <20220404100023.324645-7-vasant.hegde@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220404100023.324645-1-vasant.hegde@amd.com> References: <20220404100023.324645-1-vasant.hegde@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 485c1e3f-93e4-4520-9247-08da16223500 X-MS-TrafficTypeDiagnostic: BL1PR12MB5221:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9rTPObVJVeczkVYQG6NhP2uf3iBoW05+8In6nCVCZ8cGQagf/2yfwZDiZ75A7I7/2Xekrg93/bOdGXYaoLBmsJPF9rFLVwqkTNGBUA0mTozA984RKrzaOTUbzhaqlv9N3ulavgv2PMqGiFTrlLYJE4wzhR/u4pz8vso05Nn+1a+u38GJmQi+wpjkchCXZ/YZsToxaByfO1TzDN40ceLBMkH2PC32qEMFM97hXee2UcBixxT5xfEYWa1uBUdTFENGLqTfMsyNrd0/ZtvQsh1MA+NzcpmJugwJpCthF9IqtLSsBYr6jd6Z9pv+D6zOj5iDYBXaMd+jCvEUjUcmJ+QL0uYjNpt1OZ4Ia+8M8u+sOx4QhUluiIkcj5Nr651+/NM8oN5UsYRZA7osulKzZ5CphuVLlhmhOgPwfsUxQuiIjfcQ3rTgWGLQ5dDIKgBf+BmtBak5h70AYFkgRqhCFJe5yARdGM+l2HCaR9K2Gk7ce7cXDi0v9nbLRua6V6m/XBbgTTDi/rcdpxyYJjWpf8j/j79HrpDNKml3PweTxulVs69+27PDArxysZVUjcMF9BUzFiGuLWP7o5WyRuo6FC5I55spfCFGl4GOz43dsEVONxRLO6D1qB6a3frswAnZKu1w7a5s7LkiyE24k2gaGCHFkiUryjnJ28BlpBJZuaKhMcgkzC9Kn0H1sILp0yO/rDaWRi6DMhlVIdH4Cnu9h21D3A== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(508600001)(8676002)(70586007)(70206006)(36756003)(44832011)(83380400001)(4326008)(86362001)(6666004)(8936002)(54906003)(5660300002)(40460700003)(26005)(336012)(186003)(426003)(1076003)(2616005)(16526019)(82310400004)(47076005)(2906002)(110136005)(356005)(81166007)(36860700001)(316002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Apr 2022 10:02:19.9650 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 485c1e3f-93e4-4520-9247-08da16223500 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT025.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5221 Cc: Vasant Hegde X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Vasant Hegde via iommu Reply-To: Vasant Hegde Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" This will replace global dev_data_list. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu_types.h | 3 +++ drivers/iommu/amd/init.c | 1 + drivers/iommu/amd/iommu.c | 21 ++++++++++----------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/iommu/amd/amd_iommu_types.h b/drivers/iommu/amd/amd_iommu_types.h index d507c96598a7..7bf35e3a1ed6 100644 --- a/drivers/iommu/amd/amd_iommu_types.h +++ b/drivers/iommu/amd/amd_iommu_types.h @@ -538,6 +538,9 @@ struct protection_domain { struct amd_iommu_pci_seg { struct list_head list; + /* List of all available dev_data structures */ + struct llist_head dev_data_list; + /* PCI segment number */ u16 id; diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c index 48db6c3164aa..27785a558d9c 100644 --- a/drivers/iommu/amd/init.c +++ b/drivers/iommu/amd/init.c @@ -1525,6 +1525,7 @@ static struct amd_iommu_pci_seg *__init alloc_pci_segment(u16 id) return NULL; pci_seg->id = id; + init_llist_head(&pci_seg->dev_data_list); list_add_tail(&pci_seg->list, &amd_iommu_pci_seg_list); if (alloc_dev_table(pci_seg)) diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index a8baa64c8f9c..2bea72f388b2 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -62,9 +62,6 @@ static DEFINE_SPINLOCK(pd_bitmap_lock); -/* List of all available dev_data structures */ -static LLIST_HEAD(dev_data_list); - LIST_HEAD(ioapic_map); LIST_HEAD(hpet_map); LIST_HEAD(acpihid_map); @@ -195,9 +192,10 @@ static struct protection_domain *to_pdomain(struct iommu_domain *dom) return container_of(dom, struct protection_domain, domain); } -static struct iommu_dev_data *alloc_dev_data(u16 devid) +static struct iommu_dev_data *alloc_dev_data(struct amd_iommu *iommu, u16 devid) { struct iommu_dev_data *dev_data; + struct amd_iommu_pci_seg *pci_seg = iommu->pci_seg; dev_data = kzalloc(sizeof(*dev_data), GFP_KERNEL); if (!dev_data) @@ -207,19 +205,20 @@ static struct iommu_dev_data *alloc_dev_data(u16 devid) dev_data->devid = devid; ratelimit_default_init(&dev_data->rs); - llist_add(&dev_data->dev_data_list, &dev_data_list); + llist_add(&dev_data->dev_data_list, &pci_seg->dev_data_list); return dev_data; } -static struct iommu_dev_data *search_dev_data(u16 devid) +static struct iommu_dev_data *search_dev_data(struct amd_iommu *iommu, u16 devid) { struct iommu_dev_data *dev_data; struct llist_node *node; + struct amd_iommu_pci_seg *pci_seg = iommu->pci_seg; - if (llist_empty(&dev_data_list)) + if (llist_empty(&pci_seg->dev_data_list)) return NULL; - node = dev_data_list.first; + node = pci_seg->dev_data_list.first; llist_for_each_entry(dev_data, node, dev_data_list) { if (dev_data->devid == devid) return dev_data; @@ -287,10 +286,10 @@ static struct iommu_dev_data *find_dev_data(u16 devid) struct iommu_dev_data *dev_data; struct amd_iommu *iommu = amd_iommu_rlookup_table[devid]; - dev_data = search_dev_data(devid); + dev_data = search_dev_data(iommu, devid); if (dev_data == NULL) { - dev_data = alloc_dev_data(devid); + dev_data = alloc_dev_data(iommu, devid); if (!dev_data) return NULL; @@ -3461,7 +3460,7 @@ static int amd_ir_set_vcpu_affinity(struct irq_data *data, void *vcpu_info) struct vcpu_data *vcpu_pi_info = pi_data->vcpu_data; struct amd_ir_data *ir_data = data->chip_data; struct irq_2_irte *irte_info = &ir_data->irq_2_irte; - struct iommu_dev_data *dev_data = search_dev_data(irte_info->devid); + struct iommu_dev_data *dev_data = search_dev_data(NULL, irte_info->devid); /* Note: * This device has never been set up for guest mode. -- 2.27.0 _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu