From patchwork Wed Aug 23 16:47:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13362839 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id DEE3FC3DA66 for ; Wed, 23 Aug 2023 16:50:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IztGouCsoS1yMno3tWbJ86v0RZhblhFQMcOACTGBdrE=; b=D/qROn+MWS1aKp DNp08yNSaEtOaF/YCcjfek8VMqEyh6qEHAUL9cDiDNpJNUoR+McOI+tb2KoIRDPW9L8ZVeUTNRhla b72gCpxQb9TYN2VgJuoi7FDCQU5rhoXW/fMQ2zAoTQziMCbKDv0P1S5EYRBYn/2Kvi5Ob7QOy6cbE tdTqXbyTebTsod4Tn5gR1MQZ/V7joHtLFIG49IZLINC31JcrldyQhRk5h5kJ1angfb3Jb/xRK/LvQ sVwaN4mC8rAu0BpF0a9H1nUEjPjmMzHs0k+7qIjS91zzUcCqWl3DFlGdLeV+ewK4X68Fu16VDP3Wl l4EpLBV4H6HDgchLZ/cQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYr3q-0018Vi-2x; Wed, 23 Aug 2023 16:50:26 +0000 Received: from mail-bn8nam12on20629.outbound.protection.outlook.com ([2a01:111:f400:fe5b::629] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qYr1e-0016EL-0B; Wed, 23 Aug 2023 16:48:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AJol+rIJQeGZKdKBPOYvAcan5WmyWhSk5eOAD60TNJcM67nYXwDP5gftOa08uOF4up7DUdTWH5ooXHFvitHzgtxXPC402QlQe95c6MiB9ZKESujxgqPN86WB0Z4LX9T3DCts2EX3teVAa9VWI3yPfCxwdXWYceF1zLq9pIAVN833HllpKp6CE0zHN2ujI1G5pUBCXu6SYjCc8T0Bei1XNdETmLEtFfIoDH5WGw0BuPrs5V221IMtYvvI0LK0blYN/8JJhWuJNNDM69A5uvail4TqzQAgSvGB+AW4fLNr3TtnYg3s51VHZHrS5MdLROKdBZtgpaQsfY7zTD3tCUTtPQ== 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=6TwDiWXXvGQGGxHhKF/TFRK9HB8cy+wK6EJFCKtVVIY=; b=dFXb/feOVTI8C3+E0IlHX/aTHygIBDWyEEVPpC9Nj8Cxf1YZjVe4maOsp/qPVGB8q/Ceq4yC+wXPXjXMgRljlsVKC6ia0xoCAllI7BzvAQXDhxuK2w+BhjzXteDl2cZ1+U/CJ4C8iz3ep6ejCC3ArYnU2oqrmWglmKqVb7VUo5ZmqF/H1jTwAq+t97Sgc0XFqShW1mc9kherLxoae9JN8OHjhpLVvFXZnIJcZHghypqstIhGe5/JlbXqmFN0+qRjt6IGNEjij39OHv1+kf430hxlJBtZjdgM0pPa4gWoAhTZPgb0PAVvwDUIqmzzK4izZ+xB1qQY0o5k3FlGPTb8pg== 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=6TwDiWXXvGQGGxHhKF/TFRK9HB8cy+wK6EJFCKtVVIY=; b=BQUfWDZx8feE/8eRmFgmTl76oEriVtvmEI0TLO33O9zPFdWOOxkKXQu9UHoJgmQa81r35h3pPx9mVkm23ujwDKMRRrR2nNeLKjIj4LnRMsRkZg0ENu5xwcgXeO7ExeU851YFdyvCu+W0lCxY7kEaeA05s6LHtpCC2d82I00cDJ/z+HNXnvzvg7qeqk/8O78At5MGPxiOgPPq/h+B53QJKs9iyeUF030Nrc0UOlbeoOqw91UIwF35mJkIHL7bwixbpzUbDyj3l0j0kFvnf2HefekDydErUc40RbYqPobXn0edLZBQ60wus0FsEzbnH3MilXJPyMSP38o5aC5oJfap9A== 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 CY5PR12MB6346.namprd12.prod.outlook.com (2603:10b6:930:21::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Wed, 23 Aug 2023 16:47:56 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::5111:16e8:5afe:1da1]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::5111:16e8:5afe:1da1%6]) with mapi id 15.20.6699.020; Wed, 23 Aug 2023 16:47:56 +0000 From: Jason Gunthorpe To: Andy Gross , Alim Akhtar , Bjorn Andersson , AngeloGioacchino Del Regno , Baolin Wang , Christophe Leroy , Gerald Schaefer , Heiko Stuebner , iommu@lists.linux.dev, Jernej Skrabec , Jonathan Hunter , Joerg Roedel , Kevin Tian , Konrad Dybcio , Krzysztof Kozlowski , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-s390@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, Russell King , linuxppc-dev@lists.ozlabs.org, Matthias Brugger , Matthew Rosato , Michael Ellerman , Nicholas Piggin , Orson Zhai , Rob Clark , Robin Murphy , Samuel Holland , Thierry Reding , Krishna Reddy , Chen-Yu Tsai , Will Deacon , Yong Wu , Chunyan Zhang Cc: Lu Baolu , Dmitry Osipenko , Marek Szyprowski , Nicolin Chen , Niklas Schnelle , Steven Price , Thierry Reding Subject: [PATCH v7 12/24] iommu/tegra-smmu: Support DMA domains in tegra Date: Wed, 23 Aug 2023 13:47:26 -0300 Message-ID: <12-v7-de04a3217c48+15055-iommu_all_defdom_jgg@nvidia.com> In-Reply-To: <0-v7-de04a3217c48+15055-iommu_all_defdom_jgg@nvidia.com> References: X-ClientProxiedBy: CH0PR03CA0352.namprd03.prod.outlook.com (2603:10b6:610:11a::21) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|CY5PR12MB6346:EE_ X-MS-Office365-Filtering-Correlation-Id: ad215c65-3840-4387-0a5a-08dba3f8acf2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dX6q/JfWU62h5+QWsXCVGhx01rHULEf+WMCmnaEbnidHx6W3RaiQ8gHsGwo/5rndSUEhHjQPRsFPVILfhCHR9JQN/7TpKXJrU7SgbQRlkCAQ4P26SqRg1FxGE5GOz8PxYued+GGY8d0ViogKpSZvJOn7Xzu5HP3azYlQi0SMUtU7EHqqrSiR8guhXbRmh+/6OwoibWKes6x5tR86RR242jznYrD0wDUXH109Sr6HjeMQ/VL5Dod0IebIJMZWevEb0mHj31f4RAkR0P7esfghx+dz/9YLAzbSyEgda8woalXgBaqyBWGxmKX4xBub5XAum9EEEvGpvPHCDkxT4GQYgF7HdLL+5eqdyC1YMM3frc00+suDzfmExg2gqlIMZOantJ00ltNlVy8VPG7om8I2qpMaRv8RoMZHI6aoCnr9GRn/x2OuQJkPyubU0f07MwTkoP5IHY4PPYm5VczvEOR7LkWi/m0A+5FwBy3bv/Wawh+jvx5pPqAI+n/L841SaC4sRVRC6zCwdrkmhzl6A+UWgy7XVvXYKEjsBfK21PAW7ykUJKb//mWqusmsimk6Sowsl+Hoz0MEKNzFtXAPpwf88RnzwWKUkIMN/mJt2Wj75pc= 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:(13230031)(376002)(396003)(136003)(346002)(366004)(39860400002)(186009)(1800799009)(451199024)(54906003)(66476007)(66946007)(6512007)(316002)(66556008)(110136005)(8676002)(8936002)(107886003)(2616005)(4326008)(36756003)(41300700001)(921005)(478600001)(6666004)(6506007)(38100700002)(6486002)(83380400001)(7416002)(2906002)(7406005)(86362001)(5660300002)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: B5eyCVvPuOz1gnHKByc1+4yywowZeKwW6WMG/iLGswTZw8bAoMx4BXk2jC3VvzPWu/9vPbbsPpR3VRCzvHkSjY0wF58y932q+BSKhlkeBLPvVxpfi7EZS74NqIeeFSKJvrB/IAKy+cXthV8qac9iFdvXRe0y9z7GHzksbHrzQ+qJtfRVDifE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oX3Myd8Do3NY+cgy21BlDz1eeyYhswgbnWgkdnLkvKfYdNGDP1iz/u4Tqqg98wwKAJ/YceCVzKIO/meZAn02gyG92tme7s+BxlF6rafkJzt2mlk1JJCU2JZ8HAh7UiX3fkZ+aTNMeQ/bFQk92O1meLeqYzfmhVxFStAOjmVmcoUIFY2E6313gnR9cv49MUXIJM+7n5CT/Di54bU6Q0D8nBExWhu3yHGpnbNW5+sgHALLOOg/G9sslhZPvOoRxOIctw8qnqh2OMe9mSrGqtSJPxB/87HBwd8Ql7rdD4/YmoVFvJVFvh9ncP97WQe6gdTfWUY7Cd1l8/+N9DNa/xaQ X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: ad215c65-3840-4387-0a5a-08dba3f8acf2 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2023 16:47:45.4881 (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: tXY1tT6CzZkjgPdpTQlji1WtE1+kqNOU6uzQVt6kqckCxkEcj0YhcN5GJG+qKKir X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6346 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230823_094810_106614_BCB24618 X-CRM114-Status: GOOD ( 11.41 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org All ARM64 iommu drivers should support IOMMU_DOMAIN_DMA to enable dma-iommu.c. tegra is blocking dma-iommu usage, and also default_domain's, because it wants an identity translation. This is needed for some device quirk. The correct way to do this is to support IDENTITY domains and use ops->def_domain_type() to return IOMMU_DOMAIN_IDENTITY for only the quirky devices. Add support for IOMMU_DOMAIN_DMA and force IOMMU_DOMAIN_IDENTITY mode for everything so no behavior changes. Signed-off-by: Jason Gunthorpe Reviewed-by: Jerry Snitselaar --- drivers/iommu/tegra-smmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c index 80481e1ba561b8..b91ad1b5a20d36 100644 --- a/drivers/iommu/tegra-smmu.c +++ b/drivers/iommu/tegra-smmu.c @@ -276,7 +276,7 @@ static struct iommu_domain *tegra_smmu_domain_alloc(unsigned type) { struct tegra_smmu_as *as; - if (type != IOMMU_DOMAIN_UNMANAGED) + if (type != IOMMU_DOMAIN_UNMANAGED && type != IOMMU_DOMAIN_DMA) return NULL; as = kzalloc(sizeof(*as), GFP_KERNEL);