Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1369057lqh; Mon, 6 May 2024 06:00:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVWcXjcc5CLJsgeotc/xWZ7U3Jv75qSi+5NHXZ40DbTr5iqV9BP/z7GF/rRDPNNxwjOfIXVriRkdIzTZKE6muqsu13HYTeJPK/ekumFzQ== X-Google-Smtp-Source: AGHT+IFXHRt+vKopjhLCqLBGKcgh+S+hw5niSu2tQ0gt6/YFzI6ZhCUv/FsWz5oV+IEKT3OiATBR X-Received: by 2002:a50:9517:0:b0:572:7014:230a with SMTP id u23-20020a509517000000b005727014230amr10799620eda.14.1715000420045; Mon, 06 May 2024 06:00:20 -0700 (PDT) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id q11-20020a056402032b00b0057225514726si4661026edw.223.2024.05.06.06.00.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 06:00:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169859-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=BLv4nt7h; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-169859-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169859-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 652AC1F23E4D for ; Mon, 6 May 2024 13:00:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D6A3A4D58E; Mon, 6 May 2024 13:00:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="BLv4nt7h" Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2054.outbound.protection.outlook.com [40.107.243.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C025F44C66; Mon, 6 May 2024 13:00:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.54 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715000413; cv=fail; b=iq3pbXMobkePVrqmeH8XQALfmY5BxNwkXwYdiiBj7hYXBCqb02kt9uz44kSYdeAz65UoRcqYbiS/h7mht5Kc8vACmPZsQYl11X2BOE9WrYMhe6PjlH6T7i8nohzA2m1OxnZIHR7hGUkqeQmNLuPMxOjBOMrMZUb9UyVAzE2suB4= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715000413; c=relaxed/simple; bh=heC1igBTjKz46SC6mCkgssV9nkRBT0o8Gi6qAZaJ8og=; h=Date:From:To:Cc:Subject:Message-ID:References:Content-Type: Content-Disposition:In-Reply-To:MIME-Version; b=EopztKw7nvL4Y16EDRjZ4EKyXWgyAZRyVSIz/SGOcmvW9pnnFe1hE3semcZMMnvkrzueg43Q9w5HPMU02f0KTvUVt9vBBzF3JK2gNmujXUsy1CA1yvQGpKhkugkVGj1DI7oruVJiQUUuJ4l975dH2A8kYhaRvsvrXvERNbCCGf0= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=BLv4nt7h; arc=fail smtp.client-ip=40.107.243.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GdkOwlWiln06piYeyib/wc8iy9PvLPbPBGFPx6+QuIkJhQxMbYUvESWRIpC5tz7G2+W/CV1R8IvmLSt7/WQfX1Qu66XdqEXluyjnqTaoxoqWYPNE8x8C9FOxh5MNi1BbFJRf3Vwd0j32cskbTQSqMlvFx/4/UhlMhHrbKZIue30FwAz04fxU51IBq3VxaABSi7YO8/ihpv5nRe8k0eV5stMmo2/qvWtd5h3l08HTf+svKzhr3vnGxE8dkPF7H6jMGpMx37JZRR2fBuWS9R4I05GCRCyFihFY4d5kbmim/IsEXaU2tAHCcq2sEG7r2BAIS+fsKaeKvXDfjIcOqLTLCg== 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=BvQS5yWtW1d/JMFvzuvvylhTz+HyNzLExBq0x9/sekE=; b=Pt0uzvaOnUkBMT13wcwv2f3/voEKRyZJV389V/cGMKCsOAR8jbt3rj/+RZ3ojtg+Inwhu/IQLCC1QIASEM5Q9s1kHbSc72Ud+Kml0Ax87LIAiG1pdE6DGVFErGOPKp4cC7+lO5r0bveH6CxUlX1Csoq7zxD/dul1jOtQ169jMnbO8X+rxD2TxViEDSlFz4SKwJZsCqgOd9rrSfF5d/LLjteJr7eUyjq8dEk/GUOiCP30A1IzeTV/Qhc5IQTbNRFNMPRuTlVTOltE8Iy8fByDvrg26q76VfZZE/46/+UPg2OvR4MjJceVjBCQnFP8fitAWGytxg9oi9mODCk5pQYzNw== 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=BvQS5yWtW1d/JMFvzuvvylhTz+HyNzLExBq0x9/sekE=; b=BLv4nt7hjTjA4j9bQx8rp4Te9UGsxgllHMJ85mLqSLG0jG6m91SyizO4Bbn6MVevN2KhOCoJ/+o2WDhfcMjnz3MPGyZ0BqtUbanVANQcsImy5zCJ41RysOklGBGXX1M6GNG3rra6ohJOn7pV3+gfV8CPVbobDgCKuy5OT0L9k0OM2bovCof3tYLyV0eqHjJfOATZjE4nIU5CPbAHbxydXevGi6iUK8KxWvmhJ4mSP7x8zXke12kgn8ewpQaDYVxwJkW/78OsTGlAxNOVrFvbyfKAYqQxyee/53IZf9JCbLFSUBdKuRWhaQcUXKgAlQawv31l+FC241cgPVH2e+q9wA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB3849.namprd12.prod.outlook.com (2603:10b6:5:1c7::26) by SJ1PR12MB6076.namprd12.prod.outlook.com (2603:10b6:a03:45d::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Mon, 6 May 2024 13:00:08 +0000 Received: from DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::c296:774b:a5fc:965e]) by DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::c296:774b:a5fc:965e%3]) with mapi id 15.20.7544.041; Mon, 6 May 2024 13:00:08 +0000 Date: Mon, 6 May 2024 10:00:05 -0300 From: Jason Gunthorpe To: Nicolin Chen Cc: will@kernel.org, robin.murphy@arm.com, joro@8bytes.org, thierry.reding@gmail.com, vdumpa@nvidia.com, jonathanh@nvidia.com, linux-kernel@vger.kernel.org, iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org Subject: Re: [PATCH v6 6/6] iommu/tegra241-cmdqv: Limit CMDs for guest owned VINTF Message-ID: <20240506130005.GH3341011@nvidia.com> References: <4ee1f867e838b90a21de16b12cf2e39ba699eab4.1714451595.git.nicolinc@nvidia.com> <20240430170655.GU941030@nvidia.com> <20240501001758.GZ941030@nvidia.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: SJ2PR07CA0003.namprd07.prod.outlook.com (2603:10b6:a03:505::26) To DM6PR12MB3849.namprd12.prod.outlook.com (2603:10b6:5:1c7::26) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR12MB3849:EE_|SJ1PR12MB6076:EE_ X-MS-Office365-Filtering-Correlation-Id: 9d44cd75-6fc1-4dc8-2402-08dc6dcc74e3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|366007|376005; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?VNF9JNcUPgtibiBfpmpr6BHT1JVOOjs80i2spfnY6fL24UKNi4o2Fl6mxDPS?= =?us-ascii?Q?FyxFVnA51shRrWRQdkTWwFMM8VZXXktOkLZ70aXIHYjss8SW3+C6QM5T1/yI?= =?us-ascii?Q?Oe6WcfprX/0WoPCUziuVCrIkE+TKhf4m/YTBqIYq/MCpTk4RAEfa+XCnKu6q?= =?us-ascii?Q?LQk5cscJ9Z0o27lzc8h4IJ8QQZJm2bl1VBXX/DF53QFAiT88UAGrAvq9Lhwz?= =?us-ascii?Q?6+zkhRzLWPS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C7HOfkbN?= =?us-ascii?Q?aLe+bFE9pCaY/4hH58fhEqpUBsx6TI1ALCeV2TnnTsUctZbLEawRHpYMDJfi?= =?us-ascii?Q?8it+mVPyY/8N0guwTLMvv7BfOjdcW6FErObWCHY087TwJDRlCiZ1PoGyj0qK?= =?us-ascii?Q?ye22fUQUQCJv6rU7NuSxIGtBlbhf3kkxUOj9o4W9ig=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB3849.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(366007)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?UfTFancoezYwJqGWaMyP5xyYi4ajBxPYHqXXXN2hYmRk/bJevuhnnpFNMgQ3?= =?us-ascii?Q?ugfeGBOQupC/6Txc+m5C6kdUdIKFb6cQlbvif8yM1tV1RRwPfoqCgIAaOdjL?= =?us-ascii?Q?zEjfbUZb6X33L+gI1juW+20WvinnInrbWz4LPVmKM2SpVm8YGNCLIEcCilVo?= =?us-ascii?Q?JrpKR9GrCRks+INeQ4mEC6qQ9rS/ets5Kd3Zr3kMTkZW+LxAe97nuw7EATnU?= =?us-ascii?Q?sckI/ZsQy8oCSprvnNY79VCAAc/SsJHjbWOdbXlcRss1jAYKBClnqR+qkeyY?= =?us-ascii?Q?ZgE3zgwRN718AwlHlW0bkQ50aU3J7y8gRmHSLVc28l81F+PMYG0T7wbc0/lJ?= =?us-ascii?Q?ugFIePOkJtOAqry28WdJW1XhIOY5F2UfwZk/yiuVgRLapqXnt2ZhQ56z3JQ4?= =?us-ascii?Q?fYuWErngtMpTqSnTEqqc4TAa7rfXWQPZAOZYh/6qBBgI45EH4TeC5nRtIxOZ?= =?us-ascii?Q?wmT0V4Cjn7Sy14SOaeWy0uZ3m1z6KWPQ0U9V15agc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fQZlX+Y6cCr1++7omtfkHVgMtgagQ/MleauAx6dKXmGLhIJfWpYFniM2e?= =?us-ascii?Q?VlX976i8VxQH09KoAtYSAe6Nvc2efDJwRdvW/KSKK4EUEw1PSn4ngiV4Vcb3?= =?us-ascii?Q?eEm9s8gm5m8r3zv0RKLPwP9frBSthhKwkHr53chnw000NjWX11BGu81BFDeC?= =?us-ascii?Q?etZd0+UrApbJdbI0BN3GxdOIYmv6+Vm1wbldcDFj?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9d44cd75-6fc1-4dc8-2402-08dc6dcc74e3 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3849.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2024 13:00:08.2767 (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: +pYi1rFBgS4OlpWvnaC7VkBhGtVl7tEcVhMdXE3CziZnyKPptbFPLBTSLAdRaGMf X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6076 On Sun, May 05, 2024 at 08:52:32PM -0700, Nicolin Chen wrote: > On Tue, Apr 30, 2024 at 09:17:58PM -0300, Jason Gunthorpe wrote: > > On Tue, Apr 30, 2024 at 11:58:44AM -0700, Nicolin Chen wrote: > > > Otherwise, there has to be a get_suported_cmdq callback so batch > > > or its callers can avoid adding unsupported commands at the first > > > place. > > > > If you really feel strongly the invalidation could be split into > > S1/S2/S1_VM groupings that align with the feature bits and that could > > be passed down from one step above. But I don't think the complexity > > is really needed. It is better to deal with it through the feature > > mechanism. > > Hmm, I tried following your design by passing in a CMD_TYPE_xxx > to the tegra241_cmdqv_get_cmdq(), but I found a little painful > to accommodate these two cases: > 1. TLBI_NH_ASID is issued via arm_smmu_cmdq_issue_cmdlist(), so > we should not mark it as CMD_TYPE_ALL. Yet, this function is > used by other commands too. So, either we pass in a type from > higher callers, or simply check the opcode in that function. Yes, you'd have to pass in the type there too, which makes it more ugly. > So, it feels to me that checking against the opcode is still a > straightforward solution. And what I ended up with is somewhat > similar to this v6, yet this time it only checks at batch init > call as your design does. Well, the only downside is that the commands have to be same in a batch, but maybe that is OK anyhow. Don't forget to take the hunks that fix the queue as well. Jason