Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp483566pxb; Wed, 22 Sep 2021 06:36:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEbno2pWitezRWMh3O8uZGZWLzCUqOKyLQaqhFRYYBok04V5phn5MGNTcgfy+JAQ1egjCs X-Received: by 2002:a05:6402:134d:: with SMTP id y13mr41152166edw.264.1632317799108; Wed, 22 Sep 2021 06:36:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1632317799; cv=pass; d=google.com; s=arc-20160816; b=0BUd7CTA2p3mtTa4DKg0yPrzozgM7WngCEL472CFmaE7yonPfM8asCHMjDhku8cDGk MalsNPWSvfcjQh01hq+GqEmwMj5uQRaJpbohVBkPR4CxJfVKWknfCi12KGOszlrTwFCL wGr8c/gUn2JfjNuuHDwwZUr+sDLMt/hiogR3v0WqTibbN4ALGVhEObf99nPXX0tIDsC4 er0gNUtRPqDRrvZnA+fEFPck7WPnIHFBC1wW3rOGh2+jNsQUseJUDzvAVkz1lhva6QsJ o0zYbrYNc4fe76E0WF0D00SV08Q/5ZiSS7KIOFHsjnGDx4BkIdpe/GKPwPse0xrWeWoE xZPw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to:content-disposition :references:message-id:subject:cc:to:from:date:dkim-signature; bh=06IUb/I68YfTxGmU/HtvuXAJWL7SnefPNfvhPrvKBEg=; b=JDfZDIxKO9mPeov0o6yQJtiAlRcQd1umDu1UWromk5eXpl5LYGG3uyiTIIo1MO5aRZ mcfJJzl5AdLIhOVSmZib1VwnjamBcSZSHAemKDUD3pwgdJgCFQFsDs2UDAw+UmZHZo5A CQEpak8G0zzjPBoMbSXp/yb1choUrvvACni189u9EmMR/fTJSsEult3LIGLSy6M5UGdd jVtnQ/wiA8JfcawmHLO6EUiuMkjIhKvDpBs8vs8P+r58AnNR+KutkmjMmFHXUaUu0gHN iXJtlI9u3ZkAvkmYvXzFWWISd/RXIUiL/KcjTi3qS1B6YEgKRERnjkxr9BypgadC1ur5 z3qw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=beJjvVk2; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qo3si2640837ejb.15.2021.09.22.06.36.15; Wed, 22 Sep 2021 06:36:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=beJjvVk2; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232087AbhIVNdw (ORCPT + 99 others); Wed, 22 Sep 2021 09:33:52 -0400 Received: from mail-mw2nam12on2046.outbound.protection.outlook.com ([40.107.244.46]:35616 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231758AbhIVNdu (ORCPT ); Wed, 22 Sep 2021 09:33:50 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SaiI4/c1WrvBIk08E3nhshNGgq/ejoYF+/m3O0zMZJjqPPvlr9llouCPZrEVxQooug6OPFW84CN424FIiGtpRTYAO3Saj3sOZovDMLUXra3TbHR5gAAjDryj1D/q6SFcMzrzA/jXIh/QY8gJA7CvNzHwBTuwG5T7rYyUl5WFK48FyNlcGQQUcl0Th9woRslH9+Vv9Ddd/Jv39DVGcIE1ZD7IXybbLKGs3ulwtKRhCpH0fnQqo82kP8QBHnySyK/9WevTBVoGg7qt0rNgBDXlXeAKloZhX6FftljiR1kQ5Hu4kXsNgJWnB+W0tOrf0LDDY5XLLiVY2DKWUBDHxuQEIA== 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=06IUb/I68YfTxGmU/HtvuXAJWL7SnefPNfvhPrvKBEg=; b=GfHQJYgMhIP1coBfww4byd788142fEtE36csehUCjp6ctoJJEQ/S07H3JbMcNT3Wlyj4pihQGrs0gMU34aCpIoi6rSPtzV58P/ruWgrYiKIakBI3UN6VF1V9W06/7QzmZZIMSq/45592CglzsiQLtndv0UCF78ED1X8IzDTtMeViehrALPsHSuCUAXpkqSyGNdUt0ekHu9IS2l9H15PvHGp/iMTOtyoCZfYzmpICkvqmiwB1Ecgd28TwB12MtMUhOXf+7vPz5FxHiL9q8Jh8RidenvCAfvTsLpORhUinH7rCb8c/eja8Reg8Qzk4tfB/G3CEyXP67Wf+bt58JPU3Gg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=06IUb/I68YfTxGmU/HtvuXAJWL7SnefPNfvhPrvKBEg=; b=beJjvVk2gnNqUAj3kLHEToO8X5z74sGBwiU36LhtWdOhUZF3kW3hSIcJ2XaSOhH9l6IPPcK598HghXBoD8pXLUhuByzfn9xwsx0kKhWVei2IiYRvsR2Hwyct/3GVRLG548lcbAScYyYtQs/E5mk1bsSjhO86W461pL8ek39Zvg4qHwM/3ALfLkmMznvetO4t4m94cozG40XObQEQSqGtWeCCxRuiJSfFcWF0OwHK8o4LsnaSRDy94hzHXUjShbBqgdRCX9AxWEIi16ynqlOTpTAE1kBjlHE/MzYj3i43pW9nJtxVz39TWh7BoDKGqNFex2VxhfMFaYLmHhJZj+RONw== Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=nvidia.com; Received: from BL0PR12MB5506.namprd12.prod.outlook.com (2603:10b6:208:1cb::22) by BL1PR12MB5031.namprd12.prod.outlook.com (2603:10b6:208:31a::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Wed, 22 Sep 2021 13:32:18 +0000 Received: from BL0PR12MB5506.namprd12.prod.outlook.com ([fe80::e8af:232:915e:2f95]) by BL0PR12MB5506.namprd12.prod.outlook.com ([fe80::e8af:232:915e:2f95%8]) with mapi id 15.20.4544.013; Wed, 22 Sep 2021 13:32:18 +0000 Date: Wed, 22 Sep 2021 10:32:17 -0300 From: Jason Gunthorpe To: "Liu, Yi L" Cc: "alex.williamson@redhat.com" , "hch@lst.de" , "jasowang@redhat.com" , "joro@8bytes.org" , "jean-philippe@linaro.org" , "Tian, Kevin" , "parav@mellanox.com" , "lkml@metux.net" , "pbonzini@redhat.com" , "lushenming@huawei.com" , "eric.auger@redhat.com" , "corbet@lwn.net" , "Raj, Ashok" , "yi.l.liu@linux.intel.com" , "Tian, Jun J" , "Wu, Hao" , "Jiang, Dave" , "jacob.jun.pan@linux.intel.com" , "kwankhede@nvidia.com" , "robin.murphy@arm.com" , "kvm@vger.kernel.org" , "iommu@lists.linux-foundation.org" , "dwmw2@infradead.org" , "linux-kernel@vger.kernel.org" , "baolu.lu@linux.intel.com" , "david@gibson.dropbear.id.au" , "nicolinc@nvidia.com" Subject: Re: [RFC 11/20] iommu/iommufd: Add IOMMU_IOASID_ALLOC/FREE Message-ID: <20210922133217.GR327412@nvidia.com> References: <20210919063848.1476776-1-yi.l.liu@intel.com> <20210919063848.1476776-12-yi.l.liu@intel.com> <20210921174438.GW327412@nvidia.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: BL1PR13CA0270.namprd13.prod.outlook.com (2603:10b6:208:2ba::35) To BL0PR12MB5506.namprd12.prod.outlook.com (2603:10b6:208:1cb::22) MIME-Version: 1.0 Received: from mlx.ziepe.ca (142.162.113.129) by BL1PR13CA0270.namprd13.prod.outlook.com (2603:10b6:208:2ba::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.7 via Frontend Transport; Wed, 22 Sep 2021 13:32:18 +0000 Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1mT2MD-003xrX-DJ; Wed, 22 Sep 2021 10:32:17 -0300 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b6d4ff1c-0587-44ad-8031-08d97dcd65f3 X-MS-TrafficTypeDiagnostic: BL1PR12MB5031: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DJt5SCSluI7uWtpHCiXbCPLiABUAm+YsW06nSL9an2BePAirsHtq837NiKnUxoqA7VYokqjzQC2Gopc2Lkuy46wVKCq5CpgZFQpsYcHAvsvrC5WvCCiMUtxP7unMt7tCLwdvWDCj1omgFXk/u2dXK3sJqUkxoywBbrakWTEbSk4qw6b/AxZI5bb+r/biYiOkYAtlysvlh1dQvH9y6mxg2A7qkqQoy5k37HOzxi6YizSjLKon862uZ1TuSyR7WxhiQFD8cWqZyjEWjN89/K9RGXuSNfdCsbE9MP0TN0Xy5VS4Nh16xks3DTr0RrT/I2aK6FPgRYoeuRBdQVO/MD9enariVDn9t15+4lPtCgYhIkO1ocpUN/eTI6t4B+HprZuCnh+ZMGg+DJL65wgfHwfb9eqlbxk/A6fA17md//o26cPhF6JI/nTUtAU1fN942l97xbjDP/5vPoBnAWZYPli/x4K0nRajljyY/9LnOLPdg7vGp+hz4EsMqFiXRrqkwYxdGdvibMXHs1pLsThYGDRYZK0s0sTf4ovA9e8/B/7eBykuYJQSwQnjcwEUZVd4JBW/EiSnNROkkaA39bM6DkI3LqPxXejd1249Ygy8tFp1I2MsKCL9IhVFMup3xrigiWS11FRN9P5JeLi5PS+uypynDM4gFFvoBpMrsqhFIHu4CtGExHgIi3dOtCLPmzD1na9qYfx8LPluBQXgD9jw+2GfAg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL0PR12MB5506.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(2616005)(66476007)(83380400001)(508600001)(426003)(316002)(66556008)(66946007)(1076003)(186003)(33656002)(8676002)(9786002)(54906003)(6916009)(5660300002)(26005)(7416002)(86362001)(36756003)(4326008)(2906002)(8936002)(9746002)(38100700002)(107886003)(27376004)(84603001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?SAQORveg4HhQAcjCr4sl/yQN6kZ9AWFmjdXJu7Q+d6RvfWrhUJwiz6HnnOZk?= =?us-ascii?Q?NkyoQQvC2W8yUbPLgU2cR3q8a6eUjFht0yWRjz6wy2bnm+oHkNSvFtlh8UR0?= =?us-ascii?Q?NWpOhZMcyfIqRMUUzSUL46nYiXO1NxWCpYc85RzZMKyw50FewbOgq1ATKbkA?= =?us-ascii?Q?khTp1Kjs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?= =?us-ascii?Q?wQmNTTLJZN2wSDlY1vUVFAHRTPCfGgVTVBQKJdObYsgl1ivXT3TI7TNCR4HN?= =?us-ascii?Q?V4Rn4DInTfwf4jCRBbWT+W003UVJLxewSaQUQ4vW6gDBN+Oy1AsakYKiP+Du?= =?us-ascii?Q?SrnRTUy4c3ew/bEdHgmFPptekqfh6SANgpfic8oAzEoYTw0o5pLvPCznbk34?= =?us-ascii?Q?VQA1nMiXxu8Uk/WVytp+Oc5xUdrdLCX+ypnzHL92lgjE4yuah5Xs5X/ygo1e?= =?us-ascii?Q?N137yLHjxAtzfWzxn3ZGeGxc?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: b6d4ff1c-0587-44ad-8031-08d97dcd65f3 X-MS-Exchange-CrossTenant-AuthSource: BL0PR12MB5506.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2021 13:32:18.4628 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jUJeGSaXaRlVYIgCWoL5whynKMPbvcMpjg++Aqi76WZJxTNR2EZTq+z7A+stVVms X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5031 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 22, 2021 at 12:51:38PM +0000, Liu, Yi L wrote: > > From: Jason Gunthorpe > > Sent: Wednesday, September 22, 2021 1:45 AM > > > [...] > > > diff --git a/drivers/iommu/iommufd/iommufd.c > > b/drivers/iommu/iommufd/iommufd.c > > > index 641f199f2d41..4839f128b24a 100644 > > > +++ b/drivers/iommu/iommufd/iommufd.c > > > @@ -24,6 +24,7 @@ > > > struct iommufd_ctx { > > > refcount_t refs; > > > struct mutex lock; > > > + struct xarray ioasid_xa; /* xarray of ioasids */ > > > struct xarray device_xa; /* xarray of bound devices */ > > > }; > > > > > > @@ -42,6 +43,16 @@ struct iommufd_device { > > > u64 dev_cookie; > > > }; > > > > > > +/* Represent an I/O address space */ > > > +struct iommufd_ioas { > > > + int ioasid; > > > > xarray id's should consistently be u32s everywhere. > > sure. just one more check, this id is supposed to be returned to > userspace as the return value of ioctl(IOASID_ALLOC). That's why > I chose to use "int" as its prototype to make it aligned with the > return type of ioctl(). Based on this, do you think it's still better > to use "u32" here? I suggest not using the return code from ioctl to exchange data.. The rest of the uAPI uses an in/out struct, everything should do that consistently. Jason