Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp14967373rwb; Mon, 28 Nov 2022 06:45:13 -0800 (PST) X-Google-Smtp-Source: AA0mqf4aVQxmQ7dRVrvACF7GEdtXZB6PbGQg92QtgIDbvd9PJ8FhP3C5bRxno+KI1Z7AJh/nDgBU X-Received: by 2002:a17:90b:46ca:b0:212:ce2d:9fd7 with SMTP id jx10-20020a17090b46ca00b00212ce2d9fd7mr55354860pjb.157.1669646712929; Mon, 28 Nov 2022 06:45:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1669646712; cv=pass; d=google.com; s=arc-20160816; b=ixso2DPrfcWFiE9LOeg04FFE2nnXjouduPiHprjVKmC+PYN4Gsx2Jb4S4Nm/koXXU3 7v01oR8lscoNSmbFBx0PKyXf8cOLa+W7CQi7vB2IquZa4dRI8vgDaqENMoJ+P0KGXjfT RYT+ogVIu9MCB4FGSGqPWXlaKrFjD/HKQM4NyItyiq7Kz5IhSCdg+GyliY8YA2zV17ua UFNMfNh48A6Jyh9NdeBsgsdCRU8EeZNfp7BAJHFRyP6G2RUEHvOVeOFkiiC05CNnR2bh YvpvYpT3uHKyDQtZ9NGdsJDg+OHFUwt80aphDhRqBcd0XpnREFOcFl7GAX4WT3aXJZb1 7uiw== 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=Pnv+axmQ2v/PQadUxc0Fs12JCzWl6uxl/vu+XCY3gzg=; b=KRzdCN09244hImQeCIYczEqDNue8fzS9mtGeW6jgt3ff0S/wGgxKpbMRM6/gijrRMy nnItZ2StHmhI0kmihJUCthwzRQK7e1dGlun5TbplMbN/HytFktGhc26gp0Xmg6J00pR2 YGMX2xgoo4+37W1OJkGeo5OcACVYU6Squewo0Jk6CgWYSdZmPRNgvW6WPoAaSMsURiAs nCKw2O4crVYmg43uU8SNxRKmGvsA6z1Vbe9wVMZZ8VBy0eim7R7FrwcKKao/8etFssOr I/omOwxbP8w+2eOzdBhE+ZrlJsabrewrp2jvQOaJ8szDEQg5UdXVZ42s5kKK4p++Mo6t UZAw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=azZ9CJIz; 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 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o9-20020a62cd09000000b00546ce9189b1si11652319pfg.65.2022.11.28.06.45.01; Mon, 28 Nov 2022 06:45:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=azZ9CJIz; 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 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231859AbiK1NaR (ORCPT + 84 others); Mon, 28 Nov 2022 08:30:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231976AbiK1N36 (ORCPT ); Mon, 28 Nov 2022 08:29:58 -0500 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2059.outbound.protection.outlook.com [40.107.220.59]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAA1B1E3E8; Mon, 28 Nov 2022 05:29:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hOei92wAvIxfACbWOB6pMjvutAnaac5taxvmxgPAx8hxHjPQfRNyTKVLxYWrmhZGpFF3+B2C1YS/a8r0gaNwF9qmQDEVMQz4nlKOgVyL0IjjIWshjRI7lcLpM3OIfYTsPMc+IU4iCgwqQpCttM5mNNGCErzQg1AQALeSo9CGWn73M8AihQN0LSOHKPgtMEX63aWQw5FYUo5zJvvJUAnMXHzJRy15r4Q62VjXldnaj1ASgDSTXj7YdrCSKa3ZIcd6oR4YQ24VxIGE5oCiAAFI/RjGwIkzuiv27HE8Q2tdvB/292u2Eb8HoRzE5Why5uiOgMhRneSqAD4f4Wb2Uc+F8A== 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=Pnv+axmQ2v/PQadUxc0Fs12JCzWl6uxl/vu+XCY3gzg=; b=Kc38Un3EUGLu5azRTtf/XiyFkDmj0o05YsfKwVl2+eIkWR5kI492LnpiilviefzjlN9w8SbHM/U0t2r/zzvUPbCc3vnscja1aFhXYD7bm9Ai1lu8dxmu5Xwc+KaqeM6YKucwRn8ZvtuQ+fRaXdKKtB4e/wi8PHcvdsVqipAdTc/I3gMEt7TzJZCCeUhDGz2AvFCVW1o0jwiNhiXyC19cLbY2dvYHRXXZBSYgHIvBkPPSOZNSBrxzv4FLlNy4BWkG4ZzQxNUexfDkkkCNpdydNs2AWt0wMzvXqrkcqYkpsmeRAMDdjJbD80sWiXSRtJxFXxXbSCW4UCgdrLuAHxhcyA== 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=Pnv+axmQ2v/PQadUxc0Fs12JCzWl6uxl/vu+XCY3gzg=; b=azZ9CJIz9Sjx9zzKZo6BRYpoDGWo5INuqGJglrnqVAwvc3MFozXjGMjTSSv0d8iHW3z+G+b4cGWROXLZMM4wxNGvbXyGALtFRgP/pwX773DuH/yum0CvZJ1Mr316VFS4tC1Xk5pD1FFb9Z2FsBF2sZQE6LoSK6p/KQv22naDkf9kHUMgYwt1F438me88fx24sUkNSkOnYa3oQfJEMlYAQy3L35VytBpDMknpA5DmC2XTiMofpYj2eO2aU/eJ/WHGnj/99gxUf+u/LctgRFT36aNvLBaUj7OfICvfmIA1NngEqw+492S6psnQ7Gn1/jx7ZNn8MrftziEM3Ql53s/KSQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by SJ1PR12MB6098.namprd12.prod.outlook.com (2603:10b6:a03:45f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Mon, 28 Nov 2022 13:29:52 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%9]) with mapi id 15.20.5857.021; Mon, 28 Nov 2022 13:29:52 +0000 Date: Mon, 28 Nov 2022 09:29:51 -0400 From: Jason Gunthorpe To: Niklas Schnelle Cc: Baolu Lu , Matthew Rosato , Gerd Bayer , iommu@lists.linux.dev, Joerg Roedel , Will Deacon , Robin Murphy , Wenjia Zhang , Pierre Morel , linux-s390@vger.kernel.org, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, svens@linux.ibm.com, linux-kernel@vger.kernel.org, Julian Ruess Subject: Re: [PATCH v2 4/7] iommu: Let iommu.strict override ops->def_domain_type Message-ID: References: <20221116171656.4128212-1-schnelle@linux.ibm.com> <20221116171656.4128212-5-schnelle@linux.ibm.com> <33eea9bd-e101-4836-19e8-d4b191b78b00@linux.intel.com> <9163440eb6a47fe02730638bbdf72fda5ee5ad2c.camel@linux.ibm.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9163440eb6a47fe02730638bbdf72fda5ee5ad2c.camel@linux.ibm.com> X-ClientProxiedBy: BL1PR13CA0011.namprd13.prod.outlook.com (2603:10b6:208:256::16) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SJ1PR12MB6098:EE_ X-MS-Office365-Filtering-Correlation-Id: 55a8a091-8b91-48d5-2eff-08dad144a157 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DK0al0j+WpgX7NX753FPkrQQdWFix3w3DQrDQuILgF8rUKA+IuQO7CEXdMrJQ+E59+fK7qQQx5G1nNc2mEFnsAAsZbDEeWIQ3Wwxp2PE4DKESu0KhWi/1kwNjX8OQlr33vszcG32lnhE8OQhhIy8gSFVNBQQ7F2SiCfzCUnYexvP4Qy5UX0cNW5bN1v4cMqr6YWI0UKbwTvZphefZPwDGadL7P3HVuXp8m+MYRp7TlnRJNH9fEYh7EZ3VhuHTxtr0SaAhb02mBQLAcU1mTzwErHI4Qh8aIH8e326k8Vvy+8vdnojpvjU7d5k5wA6frtW6fsoawPzpvuHI+Y8CwZeD9QlipuKrrPIO8zM6JyGbPVH09eAIC0RUn85JRltYiM5NRx4hbWlUnbREdN+yLB3FBFu1ANnqshO//lVuaoPrRqOc3QK1wNItAp03B/tPdDkrtj/P815XeNXEv5dIvK2n/vY3h6IPZXLTQtp1fxVi8ffFBHKb61U2T9y8COioyBl27B1s809kUx/AiMmzBB0PPblxRHAAKy8pc2jjWgmUAA1Q1CHQ1PgsCPCcW1zx/jwYu5C9CoTWKecFJchHYV6qxpDR5sKJtL7gNHehi5rsHKQkjYsgtXBZmlLFWlBaRI685cgzYCjtjV7t55Cg/bD8Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(366004)(39860400002)(136003)(376002)(396003)(451199015)(2906002)(36756003)(86362001)(53546011)(6506007)(6512007)(26005)(2616005)(186003)(38100700002)(66556008)(66476007)(66946007)(8936002)(4001150100001)(7416002)(4326008)(8676002)(5660300002)(41300700001)(6486002)(6916009)(478600001)(54906003)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?ix9ZXWO7m5SSzNvW6ROhbevhedv4D7/jJOnsxx6oS34Oqsu1L3GCVOup3nq1?= =?us-ascii?Q?lgtpZIdp+oPwm+UoH3eVR9tq+JciEI6kY227SKtampHMy+q9CdiH3X37sShp?= =?us-ascii?Q?OVgRSh47XTTMeyHfVLqKQ5ZUllyWes4tsfZZSjJAYjWVTMPTKd1gv4TZ6Bt7?= =?us-ascii?Q?kWYnfBOetSjxLABnlj7wnTWcKUjPrpzh7aoSj/c1GI034eguIPcaADZNRTYJ?= =?us-ascii?Q?0Dby8oL4Xk7pFIg9vg2pnFu6uOfHNm+n3nRhCzayIlC9b67CZ3D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bm6tMJWfmZ3XPiKoFyqkVVVdklNzr5vt0?= =?us-ascii?Q?gdsi8goCdSFoCphvoYoaKpFZmE7u9YKsJvWm7NjLmLybolJ+Z2U4sgPHIrgC?= =?us-ascii?Q?giN3Unb+vpEV1qRB1Ziscj2WtA50tC4+HpFeVhB14fDEKt/sJySM17/ieRik?= =?us-ascii?Q?LwZcSGExH7kQZmktnFVpzcemSVtOpoXgSEaPuYshCfhIEY9HHC5GkUHgRkSg?= =?us-ascii?Q?5cR+DWOOoWJn/rHfd+KldSehj6xiFN3LrWTFc1U831BQZC3uoyLxjTt+J506?= =?us-ascii?Q?5/5zq6sOV3FECfCt14HqFfYy3c4WFYKB95WRc0OMu+m3I6k6DWD89IvoJWIu?= =?us-ascii?Q?hxkaH4PDKsj2wukq4bn8XLgHN2QdR0eFXBM97t10d29Etko9u3y5mK2T9Ptu?= =?us-ascii?Q?qFr6ikh7h45Bmu+SkXA=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 55a8a091-8b91-48d5-2eff-08dad144a157 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Nov 2022 13:29:52.2110 (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: S9mAyqZ3dXNK9iVgr+HHCHpuJWDsqRTuuh1MzCo54fnZnIZwMjXYHA+OTIwG2p8i X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6098 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 28, 2022 at 12:10:39PM +0100, Niklas Schnelle wrote: > On Thu, 2022-11-17 at 09:55 +0800, Baolu Lu wrote: > > On 2022/11/17 1:16, Niklas Schnelle wrote: > > > When iommu.strict=1 is set or iommu_set_dma_strict() was called we > > > should use IOMMU_DOMAIN_DMA irrespective of ops->def_domain_type. > > > > > > Signed-off-by: Niklas Schnelle > > > --- > > > drivers/iommu/iommu.c | 3 +++ > > > 1 file changed, 3 insertions(+) > > > > > > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c > > > index 65a3b3d886dc..d9bf94d198df 100644 > > > --- a/drivers/iommu/iommu.c > > > +++ b/drivers/iommu/iommu.c > > > @@ -1562,6 +1562,9 @@ static int iommu_get_def_domain_type(struct device *dev) > > > { > > > const struct iommu_ops *ops = dev_iommu_ops(dev); > > > > > > + if (iommu_dma_strict) > > > + return IOMMU_DOMAIN_DMA; > > > > If any quirky device must work in IOMMU identity mapping mode, this > > might introduce functional regression. At least for VT-d platforms, some > > devices do require IOMMU identity mapping mode for functionality. > > That's a good point. How about instead of unconditionally returning > IOMMU_DOMAIN_DMA we just do so if the domain type returned by ops- > >def_domain_type uses a flush queue (i.e. the __IOMMU_DOMAIN_DMA_FQ bit > is set). That way a device that only supports identity mapping gets to > set that but iommu_dma_strict at least always prevents use of an IOVA > flush queue. I would prefer we create some formal caps in iommu_ops to describe whatever it is you are trying to do. Jason