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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5AB5BC433EF for ; Thu, 30 Sep 2021 09:18:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 372E3615A2 for ; Thu, 30 Sep 2021 09:18:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349302AbhI3JUV (ORCPT ); Thu, 30 Sep 2021 05:20:21 -0400 Received: from mail-eopbgr150049.outbound.protection.outlook.com ([40.107.15.49]:4318 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1349293AbhI3JUT (ORCPT ); Thu, 30 Sep 2021 05:20:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jbHdMatNyBsDyuk3SpOYd8aR1cIw6x96U2sANrsCPeg=; b=6SNf2Rcl1ytFc/pe30qBJ1/rOT+tvxTKOMGNHV5Sq2BTYFyLNG4Mp8WuPswyYuSdPUuySSwd2sd9u1BJjWwE4aTM5r1KdJN4DqXDJ0gLJo44SapO8jKNcFmMle+0CY4Hub542yPQ6LraOlznzaY24mKw4LBDhJV4JN2qySJ32lE= Received: from AM5PR1001CA0009.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:206:2::22) by VE1PR08MB4750.eurprd08.prod.outlook.com (2603:10a6:802:a2::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.14; Thu, 30 Sep 2021 09:18:31 +0000 Received: from AM5EUR03FT021.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:2:cafe::23) by AM5PR1001CA0009.outlook.office365.com (2603:10a6:206:2::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.16 via Frontend Transport; Thu, 30 Sep 2021 09:18:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; vger.kernel.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;vger.kernel.org; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT021.mail.protection.outlook.com (10.152.16.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 09:18:31 +0000 Received: ("Tessian outbound a492f2284909:v103"); Thu, 30 Sep 2021 09:18:29 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 3c90e2d815972e18 X-CR-MTA-TID: 64aa7808 Received: from 096e87c2e5d3.3 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 1D0532EA-16E5-47D9-89F3-09BEC99DAF15.1; Thu, 30 Sep 2021 09:18:18 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 096e87c2e5d3.3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 30 Sep 2021 09:18:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N8GLfQEjLhQRWGIYCFaZlYxwQXOaIscYChM+NG9xrdNr0wQuzOF63qQ52Og+DkYbwxX3KwyPqVB3na624Eu7rYoJbfTNZys/WwyHf/Dss2O1C5PYbtMAu8ZNXoVW9J2JDiIA7l72AI4twZo87JC1MFdB9JH6FM6cOxH+WaffWw54xyh/L9hQRzFwTQHrX1CjcvshXO+ds5u26tcH2tasJ+LCnDFTcxuFcAIdsG6tyU53tgGZ1WZXAHzzPpSOmkgr9GXbt6jQumngCLJf2Om8cyfZGwSStvR9KTbfdepzTLav4LXf23cZ29W7j2IXfFPBtY9P4Kwnz/iCXXMW/zCbQw== 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; bh=jbHdMatNyBsDyuk3SpOYd8aR1cIw6x96U2sANrsCPeg=; b=QEsEq5CCvuPSBPyhfyLhcRBRGTrUuvCzqqG7z0fyzspmB99eVW7AshcXMSQCPYRGQ452Wqwja4uLUpU8sdNC9Ut1yIiHBSzkN2dooTwkz91s4XPUi/mTI9NdR7XB91waHzgtx+kZpczTvZ7ml5ZC4yg0vYw7s4Ccp6j+0yQseZQ/NpvnxfXj2b5nx5iWNzDs5O7hWBqYezmNYiU9cNyt1Zz+SqGGUFVRu1d6ywqLPioNmKKeBB3Cb+3qdM6FltYN1wVK3xh3lZeVgJFVvWlvY1aC/jLhim6Tg8Go7W8ocDRIQYECeZndHSc5JUJnPKl3rNtEVZnyre8p0ke+8LUnvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jbHdMatNyBsDyuk3SpOYd8aR1cIw6x96U2sANrsCPeg=; b=6SNf2Rcl1ytFc/pe30qBJ1/rOT+tvxTKOMGNHV5Sq2BTYFyLNG4Mp8WuPswyYuSdPUuySSwd2sd9u1BJjWwE4aTM5r1KdJN4DqXDJ0gLJo44SapO8jKNcFmMle+0CY4Hub542yPQ6LraOlznzaY24mKw4LBDhJV4JN2qySJ32lE= Authentication-Results-Original: huawei.com; dkim=none (message not signed) header.d=none;huawei.com; dmarc=none action=none header.from=arm.com; Received: from DB6PR08MB2645.eurprd08.prod.outlook.com (2603:10a6:6:24::25) by DB6PR08MB2774.eurprd08.prod.outlook.com (2603:10a6:6:23::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14; Thu, 30 Sep 2021 09:18:14 +0000 Received: from DB6PR08MB2645.eurprd08.prod.outlook.com ([fe80::2cb2:fad6:c5f7:4501]) by DB6PR08MB2645.eurprd08.prod.outlook.com ([fe80::2cb2:fad6:c5f7:4501%6]) with mapi id 15.20.4544.021; Thu, 30 Sep 2021 09:18:14 +0000 Subject: Re: [PATCH RFC v1 02/11] iommu/virtio: Maintain a list of endpoints served by viommu_dev To: Jean-Philippe Brucker Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, virtualization@lists.linux-foundation.org, joro@8bytes.org, will.deacon@arm.com, mst@redhat.com, robin.murphy@arm.com, eric.auger@redhat.com, kevin.tian@intel.com, jacob.jun.pan@linux.intel.com, yi.l.liu@intel.com, Lorenzo.Pieralisi@arm.com, shameerali.kolothum.thodi@huawei.com References: <20210423095147.27922-1-vivek.gautam@arm.com> <20210423095147.27922-3-vivek.gautam@arm.com> From: Vivek Kumar Gautam Message-ID: <814df96d-8796-44f6-d5e5-09f36862c497@arm.com> Date: Thu, 30 Sep 2021 14:47:54 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: BMXPR01CA0035.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:c::21) To DB6PR08MB2645.eurprd08.prod.outlook.com (2603:10a6:6:24::25) MIME-Version: 1.0 Received: from [10.162.16.71] (217.140.105.56) by BMXPR01CA0035.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 09:17:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 170be635-137a-4803-4f8d-08d983f345aa X-MS-TrafficTypeDiagnostic: DB6PR08MB2774:|VE1PR08MB4750: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8273;OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: auCmK2m67cDDwfoW+87RP3OBY7q73LGruh0YPR6/m2CTjeaISBNQF/U6aAYvgoL8gLIYSkid5Hq1Bd6e7MKp7dFyfZ04k6xpKpKzO/sTIN858NDq4nPIo42hlOzi/NUW0JsWiaTilmw0AvfHUJ87BR1PrxwMfaVNIEbayRY+cOCcP3zCOICsQYUNul0mMc90B4J0mhKUY6phV3vLKj8BT+K/fczfg4L7EZB1gA7pkUl5GIpH9goXe5oSxSSXyEceKZEuQZMH4xiqTXr2t+dqM/tot3q/AIR+nMKrp6QYOPGL+ior7pecJR/4jkXYsEcSnIHaCTYA/PmrL85pQnnA+ZPhGKPk3yGrT1V5f6F11J/XCnoDIvcWiqaAyx9tEUloT8+LXCZv38nUQQK6CF3CVt0pS3So9M5a7bky8jmQc9Cp8B4Ylxv8gorNtDCKzWS0WYjYxt3O9sJVbf0M7cYKNQZP4S0vk/jMgjeuzHoNsNFK5X87DDzX1+mG4Sb3YBG4lpe4/9nhD4a7ofa22WTUnD6/qD/VYNX/PCeBa7C+1ttrkdJkPsaujWiyZMc89llU8Bwt9UbxOchCxXIMq4Q+YB96plxkmAN10V9MhxH1Z2X7vu9mnIxdlIq8+i57k+qo+Vfhou1mAbn80irMdjOcIxrf2b5Sb9sxx4TLXs9DWWZDZFmdAyv3eJk5b57vWbz3vHwASSK0MijyZwJNZZe/5m+88Aa2SstDNh7bSvrZv9GHJsNugGKH+It5Cb3asfOc0AjeDcWMeaz0psZCyaRqmw== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB6PR08MB2645.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(66556008)(66476007)(66946007)(956004)(316002)(16576012)(53546011)(2616005)(86362001)(8936002)(8676002)(508600001)(38100700002)(38350700002)(2906002)(26005)(5660300002)(186003)(6486002)(4326008)(83380400001)(6666004)(6916009)(31686004)(36756003)(52116002)(31696002)(7416002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR08MB2774 Original-Authentication-Results: huawei.com; dkim=none (message not signed) header.d=none;huawei.com; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT021.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: c7fe981e-174b-471a-a77b-08d983f333ab X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: d/VBgXCWQnghQj+smx0EmK/gAWgxqlmVTg20AbWDU6W8C8zCfWwTc/6PsrpWEEnDopu1gNxthOu3GLiEgFK/eP2r3Xn7ykS6KmBWJCsHhQ0ViBtgGPYP/WOFYB5SAy8oz+mAlnNuNQHay4M5QxCZgoqWXArMUd8+kL52PQ6kKyETxO4zcziTZpqHj09WCfCh/Cv8x6r+5aGIRAcU6Z7gEsfU5reSrWFJesYfg2JQz+EUIuim9N4t3mo0oT2wYW8DQjiA6c2ThOI8NIl8ySa2Ns1TYCHGoS6vjeo/kjuVVv+GPNom2kRzr20BZFD/NjDlB8x2PuOHzLb1gQ8QrsRbvSUDPy7v3fHbUwQnKUv7qwKucnejLBSALu1wD8QoxZAOnayzBuKb8xRpTW/PRiWsJgiMuap0gK+rPRYRg3MbyKsKluysePpgA1mPUwwLk5ZFBCmAU9br0jHPXIloIPW8RgWj8Vsz5Z4fHOLcKrD502mCCvnExZobSb0o5N1VzPG2IjTX1CP6nTNQBR8lhiRXkG/D/YupwI9RaVOIMpwVHPVwHXukuV8cfBTyynh/mYYRBEZ9Tq1GKN+boPMY7wHu3ok8EdNgXiznjlXusTN8llZx/XdmPkkdNm6zPSSNBRPVDu24hSdj33Y0HxuaLYMH+2DmvfhNBcI0BdoniryxJFJsbXKsYwNUhqvz+xj9GwYoPhDH/Lw1QDoUtsfOB9aLwOd4RoKSYO0R7ynVZLCGwRA= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(956004)(336012)(8936002)(83380400001)(6666004)(2906002)(31686004)(107886003)(2616005)(47076005)(186003)(26005)(316002)(81166007)(70206006)(82310400003)(36860700001)(4326008)(8676002)(53546011)(31696002)(356005)(16576012)(86362001)(70586007)(508600001)(6486002)(36756003)(5660300002)(6862004)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2021 09:18:31.8097 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 170be635-137a-4803-4f8d-08d983f345aa X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT021.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4750 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/21/21 9:29 PM, Jean-Philippe Brucker wrote: > On Fri, Apr 23, 2021 at 03:21:38PM +0530, Vivek Gautam wrote: >> Keeping a record of list of endpoints that are served by the virtio-iommu >> device would help in redirecting the requests of page faults to the >> correct endpoint device to handle such requests. >> >> Signed-off-by: Vivek Gautam >> --- >> drivers/iommu/virtio-iommu.c | 21 +++++++++++++++++++++ >> 1 file changed, 21 insertions(+) >> >> diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c >> index 50039070e2aa..c970f386f031 100644 >> --- a/drivers/iommu/virtio-iommu.c >> +++ b/drivers/iommu/virtio-iommu.c >> @@ -48,6 +48,7 @@ struct viommu_dev { >> spinlock_t request_lock; >> struct list_head requests; >> void *evts; >> + struct list_head endpoints; > > As we're going to search by ID, an xarray or rb_tree would be more > appropriate than a list Sure, I will update this with a rb_tree. > >> >> /* Device configuration */ >> struct iommu_domain_geometry geometry; >> @@ -115,6 +116,12 @@ struct viommu_endpoint { >> void *pgtf; >> }; >> >> +struct viommu_ep_entry { >> + u32 eid; >> + struct viommu_endpoint *vdev; >> + struct list_head list; >> +}; > > No need for a separate struct, I think you can just add the list head and > id into viommu_endpoint. Yea right. I will update it. > >> + >> struct viommu_request { >> struct list_head list; >> void *writeback; >> @@ -573,6 +580,7 @@ static int viommu_probe_endpoint(struct viommu_dev *viommu, struct device *dev) >> size_t probe_len; >> struct virtio_iommu_req_probe *probe; >> struct virtio_iommu_probe_property *prop; >> + struct viommu_ep_entry *ep; >> struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); >> struct viommu_endpoint *vdev = dev_iommu_priv_get(dev); >> >> @@ -640,6 +648,18 @@ static int viommu_probe_endpoint(struct viommu_dev *viommu, struct device *dev) >> prop = (void *)probe->properties + cur; >> type = le16_to_cpu(prop->type) & VIRTIO_IOMMU_PROBE_T_MASK; >> } >> + if (ret) >> + goto out_free; >> + >> + ep = kzalloc(sizeof(*ep), GFP_KERNEL); >> + if (!ep) { >> + ret = -ENOMEM; >> + goto out_free; >> + } >> + ep->eid = probe->endpoint; >> + ep->vdev = vdev; >> + >> + list_add(&ep->list, &viommu->endpoints); > > This should be in viommu_probe_device() (viommu_probe_endpoint() is only > called if F_PROBE is negotiated). I think we need a lock for this > list/xarray Sure, will fix this, and add the needed locking around. Thanks & regards Vivek > > Thanks, > Jean > >> >> out_free: >> kfree(probe); >> @@ -1649,6 +1669,7 @@ static int viommu_probe(struct virtio_device *vdev) >> viommu->dev = dev; >> viommu->vdev = vdev; >> INIT_LIST_HEAD(&viommu->requests); >> + INIT_LIST_HEAD(&viommu->endpoints); >> >> ret = viommu_init_vqs(viommu); >> if (ret) >> -- >> 2.17.1 >> 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 457DBC433FE for ; Thu, 30 Sep 2021 09:18:41 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (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 01875619BB for ; Thu, 30 Sep 2021 09:18:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 01875619BB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id C265884050; Thu, 30 Sep 2021 09:18:40 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tZ3zwLJ4bVh4; Thu, 30 Sep 2021 09:18:39 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 796218402F; Thu, 30 Sep 2021 09:18:39 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 48951C000F; Thu, 30 Sep 2021 09:18:39 +0000 (UTC) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id D74B5C000D; Thu, 30 Sep 2021 09:18:37 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id B92B84030A; Thu, 30 Sep 2021 09:18:37 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp4.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.b="6SNf2Rcl"; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.b="6SNf2Rcl" 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 l8ekeGf0gkHq; Thu, 30 Sep 2021 09:18:36 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20051.outbound.protection.outlook.com [40.107.2.51]) by smtp4.osuosl.org (Postfix) with ESMTPS id E2A504029E; Thu, 30 Sep 2021 09:18:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jbHdMatNyBsDyuk3SpOYd8aR1cIw6x96U2sANrsCPeg=; b=6SNf2Rcl1ytFc/pe30qBJ1/rOT+tvxTKOMGNHV5Sq2BTYFyLNG4Mp8WuPswyYuSdPUuySSwd2sd9u1BJjWwE4aTM5r1KdJN4DqXDJ0gLJo44SapO8jKNcFmMle+0CY4Hub542yPQ6LraOlznzaY24mKw4LBDhJV4JN2qySJ32lE= Received: from AM5PR1001CA0010.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:206:2::23) by VI1PR08MB5552.eurprd08.prod.outlook.com (2603:10a6:803:ff::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.14; Thu, 30 Sep 2021 09:18:30 +0000 Received: from AM5EUR03FT021.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:2:cafe::ea) by AM5PR1001CA0010.outlook.office365.com (2603:10a6:206:2::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 09:18:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.linux-foundation.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.linux-foundation.org; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT021.mail.protection.outlook.com (10.152.16.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 09:18:29 +0000 Received: ("Tessian outbound a492f2284909:v103"); Thu, 30 Sep 2021 09:18:29 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 3c90e2d815972e18 X-CR-MTA-TID: 64aa7808 Received: from 096e87c2e5d3.3 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 1D0532EA-16E5-47D9-89F3-09BEC99DAF15.1; Thu, 30 Sep 2021 09:18:18 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 096e87c2e5d3.3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 30 Sep 2021 09:18:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N8GLfQEjLhQRWGIYCFaZlYxwQXOaIscYChM+NG9xrdNr0wQuzOF63qQ52Og+DkYbwxX3KwyPqVB3na624Eu7rYoJbfTNZys/WwyHf/Dss2O1C5PYbtMAu8ZNXoVW9J2JDiIA7l72AI4twZo87JC1MFdB9JH6FM6cOxH+WaffWw54xyh/L9hQRzFwTQHrX1CjcvshXO+ds5u26tcH2tasJ+LCnDFTcxuFcAIdsG6tyU53tgGZ1WZXAHzzPpSOmkgr9GXbt6jQumngCLJf2Om8cyfZGwSStvR9KTbfdepzTLav4LXf23cZ29W7j2IXfFPBtY9P4Kwnz/iCXXMW/zCbQw== 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; bh=jbHdMatNyBsDyuk3SpOYd8aR1cIw6x96U2sANrsCPeg=; b=QEsEq5CCvuPSBPyhfyLhcRBRGTrUuvCzqqG7z0fyzspmB99eVW7AshcXMSQCPYRGQ452Wqwja4uLUpU8sdNC9Ut1yIiHBSzkN2dooTwkz91s4XPUi/mTI9NdR7XB91waHzgtx+kZpczTvZ7ml5ZC4yg0vYw7s4Ccp6j+0yQseZQ/NpvnxfXj2b5nx5iWNzDs5O7hWBqYezmNYiU9cNyt1Zz+SqGGUFVRu1d6ywqLPioNmKKeBB3Cb+3qdM6FltYN1wVK3xh3lZeVgJFVvWlvY1aC/jLhim6Tg8Go7W8ocDRIQYECeZndHSc5JUJnPKl3rNtEVZnyre8p0ke+8LUnvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jbHdMatNyBsDyuk3SpOYd8aR1cIw6x96U2sANrsCPeg=; b=6SNf2Rcl1ytFc/pe30qBJ1/rOT+tvxTKOMGNHV5Sq2BTYFyLNG4Mp8WuPswyYuSdPUuySSwd2sd9u1BJjWwE4aTM5r1KdJN4DqXDJ0gLJo44SapO8jKNcFmMle+0CY4Hub542yPQ6LraOlznzaY24mKw4LBDhJV4JN2qySJ32lE= Authentication-Results-Original: huawei.com; dkim=none (message not signed) header.d=none;huawei.com; dmarc=none action=none header.from=arm.com; Received: from DB6PR08MB2645.eurprd08.prod.outlook.com (2603:10a6:6:24::25) by DB6PR08MB2774.eurprd08.prod.outlook.com (2603:10a6:6:23::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14; Thu, 30 Sep 2021 09:18:14 +0000 Received: from DB6PR08MB2645.eurprd08.prod.outlook.com ([fe80::2cb2:fad6:c5f7:4501]) by DB6PR08MB2645.eurprd08.prod.outlook.com ([fe80::2cb2:fad6:c5f7:4501%6]) with mapi id 15.20.4544.021; Thu, 30 Sep 2021 09:18:14 +0000 Subject: Re: [PATCH RFC v1 02/11] iommu/virtio: Maintain a list of endpoints served by viommu_dev To: Jean-Philippe Brucker References: <20210423095147.27922-1-vivek.gautam@arm.com> <20210423095147.27922-3-vivek.gautam@arm.com> From: Vivek Kumar Gautam Message-ID: <814df96d-8796-44f6-d5e5-09f36862c497@arm.com> Date: Thu, 30 Sep 2021 14:47:54 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 In-Reply-To: Content-Language: en-US X-ClientProxiedBy: BMXPR01CA0035.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:c::21) To DB6PR08MB2645.eurprd08.prod.outlook.com (2603:10a6:6:24::25) MIME-Version: 1.0 Received: from [10.162.16.71] (217.140.105.56) by BMXPR01CA0035.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 09:17:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 74db5754-027b-47cd-5dab-08d983f34420 X-MS-TrafficTypeDiagnostic: DB6PR08MB2774:|VI1PR08MB5552: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8273;OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: auCmK2m67cDDwfoW+87RP3OBY7q73LGruh0YPR6/m2CTjeaISBNQF/U6aAYvgoL8gLIYSkid5Hq1Bd6e7MKp7dFyfZ04k6xpKpKzO/sTIN858NDq4nPIo42hlOzi/NUW0JsWiaTilmw0AvfHUJ87BR1PrxwMfaVNIEbayRY+cOCcP3zCOICsQYUNul0mMc90B4J0mhKUY6phV3vLKj8BT+K/fczfg4L7EZB1gA7pkUl5GIpH9goXe5oSxSSXyEceKZEuQZMH4xiqTXr2t+dqM/tot3q/AIR+nMKrp6QYOPGL+ior7pecJR/4jkXYsEcSnIHaCTYA/PmrL85pQnnA+ZPhGKPk3yGrT1V5f6F11J/XCnoDIvcWiqaAyx9tEUloT8+LXCZv38nUQQK6CF3CVt0pS3So9M5a7bky8jmQc9Cp8B4Ylxv8gorNtDCKzWS0WYjYxt3O9sJVbf0M7cYKNQZP4S0vk/jMgjeuzHoNsNFK5X87DDzX1+mG4Sb3YBG4lpe4/9nhD4a7ofa22WTUnD6/qD/VYNX/PCeBa7C+1ttrkdJkPsaujWiyZMc89llU8Bwt9UbxOchCxXIMq4Q+YB96plxkmAN10V9MhxH1Z2X7vu9mnIxdlIq8+i57k+qo+Vfhou1mAbn80irMdjOcIxrf2b5Sb9sxx4TLXs9DWWZDZFmdAyv3eJk5b57vWbz3vHwASSK0MijyZwJNZZe/5m+88Aa2SstDNh7bSvrZv9GHJsNugGKH+It5Cb3asfOc0AjeDcWMeaz0psZCyaRqmw== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB6PR08MB2645.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(66556008)(66476007)(66946007)(956004)(316002)(16576012)(53546011)(2616005)(86362001)(8936002)(8676002)(508600001)(38100700002)(38350700002)(2906002)(26005)(5660300002)(186003)(6486002)(4326008)(83380400001)(6666004)(6916009)(31686004)(36756003)(52116002)(31696002)(7416002)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR08MB2774 Original-Authentication-Results: huawei.com; dkim=none (message not signed) header.d=none;huawei.com; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT021.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: c7fe981e-174b-471a-a77b-08d983f333ab X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wx+0MrpywAuFGnu/Bh1HbhANYywZVZL6hI7Xi6933vt6c3rCBL0O+7G1jCp3vrZ8sNjmfXCSkeU2kViblL5f9y7MIFGjTyAVX/leydZNul+DD5n0H1aH79RwarzdCdyY6wowr0kw/gbL9im3tUa1iDxBhe+ZlVD+Ub1Efp//mBKLG5qLTSLD7XQHgYSCYZR8O1A8zo+tfWL01Re1J4oNcGlBTjzbFMQhAczOY9UBCam0eHwtc6PTCIOGVDsFWflnBj9N7LrR7oLY7lyOOf1AaoOjeMqMLRkfQIpFCJojPKJgovu0qecMYWQy7n+/P+TdngF5Gix0jLGEpmvRn1n1WA8Mkc38/o9Lzmt13+6G2WaCnNLF8fUaNpR45eZbzyd4PeYVm68h0etIixGr7levQPB9I5rpbMGEgNzH+X+572AY5DbhbdC9GEq36ejOsHIJFFNv8FLSlOeBBhXAxrbF9jTAQeX1Gr9EUywAcbiuWjDjtFpCMVNPEgdIxLJTytXpr3ZafO5rj/Y2qiB5Qz1u0HaDAjlO1deejA9UmNDilB3rTRwsof/HR/CrZOegcoGLES/MUswLa6DxLsuaBhfyoZgYnb+Ogvc+IE5f9vwYKxbVjCbGUYINN6FgZvXiMWWjcyIJZwBb/VVSpW6qBqLMSv+TrtYgeWcpY14BJFGJ9WaftV4WIndL9Uji/yF/gWin3CV+wopGpLWCJGaOTs0v/6gylYftfD7/U6yeaGw0TzY= X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(36756003)(5660300002)(336012)(8936002)(6862004)(31686004)(6486002)(4326008)(186003)(2616005)(26005)(450100002)(82310400003)(86362001)(956004)(31696002)(8676002)(2906002)(47076005)(83380400001)(6666004)(107886003)(53546011)(356005)(16576012)(508600001)(81166007)(70586007)(36860700001)(316002)(70206006)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2021 09:18:29.2069 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 74db5754-027b-47cd-5dab-08d983f34420 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT021.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5552 Cc: kevin.tian@intel.com, mst@redhat.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, iommu@lists.linux-foundation.org, robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org 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: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" On 9/21/21 9:29 PM, Jean-Philippe Brucker wrote: > On Fri, Apr 23, 2021 at 03:21:38PM +0530, Vivek Gautam wrote: >> Keeping a record of list of endpoints that are served by the virtio-iommu >> device would help in redirecting the requests of page faults to the >> correct endpoint device to handle such requests. >> >> Signed-off-by: Vivek Gautam >> --- >> drivers/iommu/virtio-iommu.c | 21 +++++++++++++++++++++ >> 1 file changed, 21 insertions(+) >> >> diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c >> index 50039070e2aa..c970f386f031 100644 >> --- a/drivers/iommu/virtio-iommu.c >> +++ b/drivers/iommu/virtio-iommu.c >> @@ -48,6 +48,7 @@ struct viommu_dev { >> spinlock_t request_lock; >> struct list_head requests; >> void *evts; >> + struct list_head endpoints; > > As we're going to search by ID, an xarray or rb_tree would be more > appropriate than a list Sure, I will update this with a rb_tree. > >> >> /* Device configuration */ >> struct iommu_domain_geometry geometry; >> @@ -115,6 +116,12 @@ struct viommu_endpoint { >> void *pgtf; >> }; >> >> +struct viommu_ep_entry { >> + u32 eid; >> + struct viommu_endpoint *vdev; >> + struct list_head list; >> +}; > > No need for a separate struct, I think you can just add the list head and > id into viommu_endpoint. Yea right. I will update it. > >> + >> struct viommu_request { >> struct list_head list; >> void *writeback; >> @@ -573,6 +580,7 @@ static int viommu_probe_endpoint(struct viommu_dev *viommu, struct device *dev) >> size_t probe_len; >> struct virtio_iommu_req_probe *probe; >> struct virtio_iommu_probe_property *prop; >> + struct viommu_ep_entry *ep; >> struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); >> struct viommu_endpoint *vdev = dev_iommu_priv_get(dev); >> >> @@ -640,6 +648,18 @@ static int viommu_probe_endpoint(struct viommu_dev *viommu, struct device *dev) >> prop = (void *)probe->properties + cur; >> type = le16_to_cpu(prop->type) & VIRTIO_IOMMU_PROBE_T_MASK; >> } >> + if (ret) >> + goto out_free; >> + >> + ep = kzalloc(sizeof(*ep), GFP_KERNEL); >> + if (!ep) { >> + ret = -ENOMEM; >> + goto out_free; >> + } >> + ep->eid = probe->endpoint; >> + ep->vdev = vdev; >> + >> + list_add(&ep->list, &viommu->endpoints); > > This should be in viommu_probe_device() (viommu_probe_endpoint() is only > called if F_PROBE is negotiated). I think we need a lock for this > list/xarray Sure, will fix this, and add the needed locking around. Thanks & regards Vivek > > Thanks, > Jean > >> >> out_free: >> kfree(probe); >> @@ -1649,6 +1669,7 @@ static int viommu_probe(struct virtio_device *vdev) >> viommu->dev = dev; >> viommu->vdev = vdev; >> INIT_LIST_HEAD(&viommu->requests); >> + INIT_LIST_HEAD(&viommu->endpoints); >> >> ret = viommu_init_vqs(viommu); >> if (ret) >> -- >> 2.17.1 >> _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B155BC433F5 for ; Thu, 30 Sep 2021 09:21:00 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 71AC86140F for ; Thu, 30 Sep 2021 09:21:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 71AC86140F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:Date:Message-ID:From: References:Cc:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VcWntSkuGdocUq9Ijt6jfoFWPHhJRhUUjUlC8W8Ytl0=; b=E3ibSJpQL6txbv7J4RATkuTKG8 xotchxvXKsv5tLCvr5mVrDjsvPJ8C+JJJo9G6f2GRIfsJPyb6ZMgXmMZE8No2hYAWXhCeBIY5b7yC QOAs8XprwCTNWkHMSNQ3WXBGC1rDaY76sbF9psClTD13er4e0djn+BUQgCJxe/Pe2oQXBi/8PTXG/ Z0B6gVejHMmaFvohyoZ58zU7h5u20hpBuMWGscfPR4xa8DvwvG9fL//4e+/UsrPW1BSXUuT2Huxjf y3eDcnxn8b4yTgkr/SkY0oh1HqiA+AdosBACoyuq45D5O83MVfnlGsHznHddTz6cc0xWKerMFbrz8 6MA+cUPA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVsDB-00DXf4-PD; Thu, 30 Sep 2021 09:18:42 +0000 Received: from mail-eopbgr70085.outbound.protection.outlook.com ([40.107.7.85] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVsD7-00DXea-EE for linux-arm-kernel@lists.infradead.org; Thu, 30 Sep 2021 09:18:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jbHdMatNyBsDyuk3SpOYd8aR1cIw6x96U2sANrsCPeg=; b=6SNf2Rcl1ytFc/pe30qBJ1/rOT+tvxTKOMGNHV5Sq2BTYFyLNG4Mp8WuPswyYuSdPUuySSwd2sd9u1BJjWwE4aTM5r1KdJN4DqXDJ0gLJo44SapO8jKNcFmMle+0CY4Hub542yPQ6LraOlznzaY24mKw4LBDhJV4JN2qySJ32lE= Received: from AM6P193CA0106.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:88::47) by DB9PR08MB7131.eurprd08.prod.outlook.com (2603:10a6:10:2c9::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14; Thu, 30 Sep 2021 09:18:31 +0000 Received: from VE1EUR03FT031.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:88:cafe::a3) by AM6P193CA0106.outlook.office365.com (2603:10a6:209:88::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.15 via Frontend Transport; Thu, 30 Sep 2021 09:18:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.infradead.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.infradead.org; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT031.mail.protection.outlook.com (10.152.18.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 09:18:31 +0000 Received: ("Tessian outbound a492f2284909:v103"); Thu, 30 Sep 2021 09:18:29 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 3c90e2d815972e18 X-CR-MTA-TID: 64aa7808 Received: from 096e87c2e5d3.3 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 1D0532EA-16E5-47D9-89F3-09BEC99DAF15.1; Thu, 30 Sep 2021 09:18:18 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 096e87c2e5d3.3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 30 Sep 2021 09:18:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N8GLfQEjLhQRWGIYCFaZlYxwQXOaIscYChM+NG9xrdNr0wQuzOF63qQ52Og+DkYbwxX3KwyPqVB3na624Eu7rYoJbfTNZys/WwyHf/Dss2O1C5PYbtMAu8ZNXoVW9J2JDiIA7l72AI4twZo87JC1MFdB9JH6FM6cOxH+WaffWw54xyh/L9hQRzFwTQHrX1CjcvshXO+ds5u26tcH2tasJ+LCnDFTcxuFcAIdsG6tyU53tgGZ1WZXAHzzPpSOmkgr9GXbt6jQumngCLJf2Om8cyfZGwSStvR9KTbfdepzTLav4LXf23cZ29W7j2IXfFPBtY9P4Kwnz/iCXXMW/zCbQw== 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; bh=jbHdMatNyBsDyuk3SpOYd8aR1cIw6x96U2sANrsCPeg=; b=QEsEq5CCvuPSBPyhfyLhcRBRGTrUuvCzqqG7z0fyzspmB99eVW7AshcXMSQCPYRGQ452Wqwja4uLUpU8sdNC9Ut1yIiHBSzkN2dooTwkz91s4XPUi/mTI9NdR7XB91waHzgtx+kZpczTvZ7ml5ZC4yg0vYw7s4Ccp6j+0yQseZQ/NpvnxfXj2b5nx5iWNzDs5O7hWBqYezmNYiU9cNyt1Zz+SqGGUFVRu1d6ywqLPioNmKKeBB3Cb+3qdM6FltYN1wVK3xh3lZeVgJFVvWlvY1aC/jLhim6Tg8Go7W8ocDRIQYECeZndHSc5JUJnPKl3rNtEVZnyre8p0ke+8LUnvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jbHdMatNyBsDyuk3SpOYd8aR1cIw6x96U2sANrsCPeg=; b=6SNf2Rcl1ytFc/pe30qBJ1/rOT+tvxTKOMGNHV5Sq2BTYFyLNG4Mp8WuPswyYuSdPUuySSwd2sd9u1BJjWwE4aTM5r1KdJN4DqXDJ0gLJo44SapO8jKNcFmMle+0CY4Hub542yPQ6LraOlznzaY24mKw4LBDhJV4JN2qySJ32lE= Authentication-Results-Original: huawei.com; dkim=none (message not signed) header.d=none;huawei.com; dmarc=none action=none header.from=arm.com; Received: from DB6PR08MB2645.eurprd08.prod.outlook.com (2603:10a6:6:24::25) by DB6PR08MB2774.eurprd08.prod.outlook.com (2603:10a6:6:23::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14; Thu, 30 Sep 2021 09:18:14 +0000 Received: from DB6PR08MB2645.eurprd08.prod.outlook.com ([fe80::2cb2:fad6:c5f7:4501]) by DB6PR08MB2645.eurprd08.prod.outlook.com ([fe80::2cb2:fad6:c5f7:4501%6]) with mapi id 15.20.4544.021; Thu, 30 Sep 2021 09:18:14 +0000 Subject: Re: [PATCH RFC v1 02/11] iommu/virtio: Maintain a list of endpoints served by viommu_dev To: Jean-Philippe Brucker Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, virtualization@lists.linux-foundation.org, joro@8bytes.org, will.deacon@arm.com, mst@redhat.com, robin.murphy@arm.com, eric.auger@redhat.com, kevin.tian@intel.com, jacob.jun.pan@linux.intel.com, yi.l.liu@intel.com, Lorenzo.Pieralisi@arm.com, shameerali.kolothum.thodi@huawei.com References: <20210423095147.27922-1-vivek.gautam@arm.com> <20210423095147.27922-3-vivek.gautam@arm.com> From: Vivek Kumar Gautam Message-ID: <814df96d-8796-44f6-d5e5-09f36862c497@arm.com> Date: Thu, 30 Sep 2021 14:47:54 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 In-Reply-To: Content-Language: en-US X-ClientProxiedBy: BMXPR01CA0035.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:c::21) To DB6PR08MB2645.eurprd08.prod.outlook.com (2603:10a6:6:24::25) MIME-Version: 1.0 Received: from [10.162.16.71] (217.140.105.56) by BMXPR01CA0035.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 09:17:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4ced8e6c-754b-46f6-3596-08d983f34584 X-MS-TrafficTypeDiagnostic: DB6PR08MB2774:|DB9PR08MB7131: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8273;OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: auCmK2m67cDDwfoW+87RP3OBY7q73LGruh0YPR6/m2CTjeaISBNQF/U6aAYvgoL8gLIYSkid5Hq1Bd6e7MKp7dFyfZ04k6xpKpKzO/sTIN858NDq4nPIo42hlOzi/NUW0JsWiaTilmw0AvfHUJ87BR1PrxwMfaVNIEbayRY+cOCcP3zCOICsQYUNul0mMc90B4J0mhKUY6phV3vLKj8BT+K/fczfg4L7EZB1gA7pkUl5GIpH9goXe5oSxSSXyEceKZEuQZMH4xiqTXr2t+dqM/tot3q/AIR+nMKrp6QYOPGL+ior7pecJR/4jkXYsEcSnIHaCTYA/PmrL85pQnnA+ZPhGKPk3yGrT1V5f6F11J/XCnoDIvcWiqaAyx9tEUloT8+LXCZv38nUQQK6CF3CVt0pS3So9M5a7bky8jmQc9Cp8B4Ylxv8gorNtDCKzWS0WYjYxt3O9sJVbf0M7cYKNQZP4S0vk/jMgjeuzHoNsNFK5X87DDzX1+mG4Sb3YBG4lpe4/9nhD4a7ofa22WTUnD6/qD/VYNX/PCeBa7C+1ttrkdJkPsaujWiyZMc89llU8Bwt9UbxOchCxXIMq4Q+YB96plxkmAN10V9MhxH1Z2X7vu9mnIxdlIq8+i57k+qo+Vfhou1mAbn80irMdjOcIxrf2b5Sb9sxx4TLXs9DWWZDZFmdAyv3eJk5b57vWbz3vHwASSK0MijyZwJNZZe/5m+88Aa2SstDNh7bSvrZv9GHJsNugGKH+It5Cb3asfOc0AjeDcWMeaz0psZCyaRqmw== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB6PR08MB2645.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(66556008)(66476007)(66946007)(956004)(316002)(16576012)(53546011)(2616005)(86362001)(8936002)(8676002)(508600001)(38100700002)(38350700002)(2906002)(26005)(5660300002)(186003)(6486002)(4326008)(83380400001)(6666004)(6916009)(31686004)(36756003)(52116002)(31696002)(7416002)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR08MB2774 Original-Authentication-Results: huawei.com; dkim=none (message not signed) header.d=none;huawei.com; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT031.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: c7fe981e-174b-471a-a77b-08d983f333ab X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SDngtNQTfQa6RMGrwIM/2vvxGzoJFUEJwPrjh2wlqprvG3uB30IJpnu1V9U3D9UQYpA3pNf2hh8NF0+v39GUIMwJX7f0elgoNizNhLjjTLzT6QODoaa5HPx0GQ8hoRuEkUgYfV3+CPsxsmn+z879Rr+JpA1KtYgACJlstHgTVnkbg3+A6ekl8qH5eS8vAFUVV31N1D8DkYPejXitX6BO8cH6fKpkuz+EKV4k5wZG9qQktYOFsvyG4QBcnxgporm1XbVinNaJldF90GkTeB27mMRuL/ndKGup6WY42hmIIqhSTwbXQOOelvtlxTW/ol3Mv68VDYO/oidrqiP6vf5y8D4EhVG1hjrWesQvvMB3dFioW16kzEbbIKaxJRDeHwpatidHgmhM4od2PH0pWtNy/eFQSUk2LyzlBH57J3ofus46QQGYVe7qaXsjq3XLjm2PCF7aeVGeYOsqGTzUvP3gpEb4+1mx3WsQOZCeD9xUeoJWDdQDAylnPc104etPpgcKVe6uHBbjTYJ0nOnXjO7WJLufXw/wNv1ubSZ+J1Oz0VJzzC4ibx2tTHPrkqWUtpMT5Q/EwqP81/+VOOgjtV/Cvb1zqrZ+0x5//lLD5j4ChNcJSTGXJ4q8dxtN5utM6QOL+LObX6FKSrA4YIg2dr1mqbcqBS30kwSVTx5lfm7tQENZ0YClNfRfcMuTOAbGRO8WNz+zOkNGV+GTR/g3B1PD1ZpeDEEVJA3oo9/oiLz+Tj8= X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(5660300002)(83380400001)(36860700001)(82310400003)(47076005)(86362001)(70586007)(31696002)(70206006)(81166007)(356005)(36756003)(8676002)(53546011)(956004)(6486002)(31686004)(6666004)(107886003)(6862004)(508600001)(26005)(2616005)(4326008)(336012)(8936002)(2906002)(16576012)(316002)(186003)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2021 09:18:31.5130 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4ced8e6c-754b-46f6-3596-08d983f34584 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT031.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB7131 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210930_021837_621807_38E2B1B8 X-CRM114-Status: GOOD ( 25.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 9/21/21 9:29 PM, Jean-Philippe Brucker wrote: > On Fri, Apr 23, 2021 at 03:21:38PM +0530, Vivek Gautam wrote: >> Keeping a record of list of endpoints that are served by the virtio-iommu >> device would help in redirecting the requests of page faults to the >> correct endpoint device to handle such requests. >> >> Signed-off-by: Vivek Gautam >> --- >> drivers/iommu/virtio-iommu.c | 21 +++++++++++++++++++++ >> 1 file changed, 21 insertions(+) >> >> diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c >> index 50039070e2aa..c970f386f031 100644 >> --- a/drivers/iommu/virtio-iommu.c >> +++ b/drivers/iommu/virtio-iommu.c >> @@ -48,6 +48,7 @@ struct viommu_dev { >> spinlock_t request_lock; >> struct list_head requests; >> void *evts; >> + struct list_head endpoints; > > As we're going to search by ID, an xarray or rb_tree would be more > appropriate than a list Sure, I will update this with a rb_tree. > >> >> /* Device configuration */ >> struct iommu_domain_geometry geometry; >> @@ -115,6 +116,12 @@ struct viommu_endpoint { >> void *pgtf; >> }; >> >> +struct viommu_ep_entry { >> + u32 eid; >> + struct viommu_endpoint *vdev; >> + struct list_head list; >> +}; > > No need for a separate struct, I think you can just add the list head and > id into viommu_endpoint. Yea right. I will update it. > >> + >> struct viommu_request { >> struct list_head list; >> void *writeback; >> @@ -573,6 +580,7 @@ static int viommu_probe_endpoint(struct viommu_dev *viommu, struct device *dev) >> size_t probe_len; >> struct virtio_iommu_req_probe *probe; >> struct virtio_iommu_probe_property *prop; >> + struct viommu_ep_entry *ep; >> struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); >> struct viommu_endpoint *vdev = dev_iommu_priv_get(dev); >> >> @@ -640,6 +648,18 @@ static int viommu_probe_endpoint(struct viommu_dev *viommu, struct device *dev) >> prop = (void *)probe->properties + cur; >> type = le16_to_cpu(prop->type) & VIRTIO_IOMMU_PROBE_T_MASK; >> } >> + if (ret) >> + goto out_free; >> + >> + ep = kzalloc(sizeof(*ep), GFP_KERNEL); >> + if (!ep) { >> + ret = -ENOMEM; >> + goto out_free; >> + } >> + ep->eid = probe->endpoint; >> + ep->vdev = vdev; >> + >> + list_add(&ep->list, &viommu->endpoints); > > This should be in viommu_probe_device() (viommu_probe_endpoint() is only > called if F_PROBE is negotiated). I think we need a lock for this > list/xarray Sure, will fix this, and add the needed locking around. Thanks & regards Vivek > > Thanks, > Jean > >> >> out_free: >> kfree(probe); >> @@ -1649,6 +1669,7 @@ static int viommu_probe(struct virtio_device *vdev) >> viommu->dev = dev; >> viommu->vdev = vdev; >> INIT_LIST_HEAD(&viommu->requests); >> + INIT_LIST_HEAD(&viommu->endpoints); >> >> ret = viommu_init_vqs(viommu); >> if (ret) >> -- >> 2.17.1 >> _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel