From patchwork Mon May 1 18:03:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13227851 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 A333CC77B73 for ; Mon, 1 May 2023 18:05:18 +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=eThsGGKvl77cQGlKsP/ACTRa4fX58J5wS8k76s0N8FQ=; b=4epG8xVRSlAQ4E s1LeSpGeWlSZW4UeaRIoPWl/fWONmrt7OmJH7jIXXbBJKy86mIkf6KY1NEp+uBp7BDJ571AmX8KQv hLSoNeU1DMMXkQUkgS9q1L3WkN5Wn3oKOg+B4fU3Mm+2PdtNskPmk+bBed04TM2Ua4q6NK4GHpQsU Wx5RKp6oaIHRahxMcfmqH9BXVYNaqftFem250EAKtAZFLc9Lr4jH22Vq1wqZ7EpM5Rgbh/+2xR3zF J9LrHDWhDs0gqTZJZfsXwjGgtPr+GAs/WDF0Dl6qnCj4HQCcMmmFGZ34P7twprw88+Z4GaCwPGFE4 Gd2rkGx9B9ZeZDwW+q2A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ptXsq-00GT6U-1H; Mon, 01 May 2023 18:04:20 +0000 Received: from mail-mw2nam10on20616.outbound.protection.outlook.com ([2a01:111:f400:7e89::616] helo=NAM10-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ptXrs-00GS56-2K; Mon, 01 May 2023 18:03:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LI+v1RmFl02ZJ8wyqZXg2hKCuPydt0u4RdNSEgDEwJQhV3bSTk3ihE1TWh28TFILPN7G36XTzssZwJemfj3DVIP5UUWFwbLV5vtspO8+l7UesFuQQct81IjVnKVTVt0sUW5C2GEBdssywXCXhT3DCIgjGnQAEdJadRSWU2AEPnJCaz2i/mDaD5QvANB4fj0s/9+9uZoq0mM5ghrHKMTGaeMptsq8tnh+h0s50ENPXhC7iIzRHfV3IhbK5c/hZoMpxuyJTr/gmjim13h61w2vZSNdGPudprZkgQMPyhY7syW2MLt7XUn4muwTh/hY0fQzg46hTDszXcIJr+Qx/rI6qQ== 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=vzBVAMf5sGK0GaBtvrF81cXDydj/HWb03X+ZAZtzJnA=; b=Vk22tihnkyFW6OfBMheuLQi2JWMgUmqJdTcHsekCcvtPrQGZBCMijzphS4Um3onDZpJciLryRuHp66vJBqfeU4TpNBmXdCcPYvRNUylXsfuC/AoTJ7iTv6k3TGxX2rXiODvtAoJbEGbCO76ecoseJWxSihSHR0BAh3LFoThiByYSBIq90dZeD94IoiQ1/hCLqUuUoudddBCS1qCOTmtP7obXZBjsUnFDCgt7DmqI7W8o/k3YV/SXJb4B32txPAV2fiCVxi4qYsous89xWizSC/5TuIiHwQ/SnoVeaw3mtMP9rcnSB7nl2yOYn4SOqGe011R4vcX+z+3xGmHTLRYLXA== 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=vzBVAMf5sGK0GaBtvrF81cXDydj/HWb03X+ZAZtzJnA=; b=aE11JqULmRV+xRBnr+0OqBs5aMcW6vp2wYb1Yh55fcudegmYzF39hb0HH0xHOOtJg5OseDv9SbeJAJ9Pq8jQ3TF0qhXLSpC9AHxNNFV+hZoMO9QcmQ2NZVznL9tRA5sNKlg/HCH/K9MM6wlaT4iKRnlmFLyLk1/RyZ5on0zIMP68I++pCegAeUi/KT7cHwSyuoUDi9cZ1Y9zyajvJ6ba9h+eNau5x68K6TPj7v5ogJsI86TCeVLQqwtGWxQ4xyo+ShUzjbRp5ZlCIV7pXcGqSTsqQMOEVTQxDxlNYzqQQTX8VqbQX/zRFOm7oWJIEw7AVBClsXyKdLKGMeghH45Gzw== 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 IA1PR12MB6457.namprd12.prod.outlook.com (2603:10b6:208:3ab::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.30; Mon, 1 May 2023 18:03:09 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f7a7:a561:87e9:5fab]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f7a7:a561:87e9:5fab%6]) with mapi id 15.20.6340.030; Mon, 1 May 2023 18:03:09 +0000 From: Jason Gunthorpe To: Andy Gross , Alim Akhtar , Bjorn Andersson , AngeloGioacchino Del Regno , Baolin Wang , Gerald Schaefer , Heiko Stuebner , iommu@lists.linux.dev, Jernej Skrabec , Jonathan Hunter , Joerg Roedel , 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, Marek Szyprowski , Matthias Brugger , Matthew Rosato , Orson Zhai , Rob Clark , Robin Murphy , Samuel Holland , Niklas Schnelle , Thierry Reding , Krishna Reddy , Chen-Yu Tsai , Will Deacon , Yong Wu , Chunyan Zhang Cc: Lu Baolu , Kevin Tian , Nicolin Chen , Steven Price Subject: [PATCH 16/20] iommu/sun50i: Add an IOMMU_IDENTITIY_DOMAIN Date: Mon, 1 May 2023 15:03:00 -0300 Message-Id: <16-v1-21cc72fcfb22+a7a-iommu_all_defdom_jgg@nvidia.com> In-Reply-To: <0-v1-21cc72fcfb22+a7a-iommu_all_defdom_jgg@nvidia.com> References: X-ClientProxiedBy: BLAPR03CA0097.namprd03.prod.outlook.com (2603:10b6:208:32a::12) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|IA1PR12MB6457:EE_ X-MS-Office365-Filtering-Correlation-Id: 2a4153af-b8d6-478f-7ebe-08db4a6e50d5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QLonrndzotFoOOizeu1wCQwiFSemaL7X56oWmabz2V7oYJRFQ9EHB3eSY9IfYY3J95jK2pgKjPN+G17M166PKwufzY13PHpGbZq8CiYhf1ZmRbuL45207jr8+2FWHvjuIcm63jLLMLVkqCrkMF2I/fm9qL3/ueY3+UV/hKmV6xzdzRXO+GsueK4X72jnulfKCwGOAiRyhc7tqc+1udo76QhizCoydrycaeOo4ImXsbVQGyQzyTi6HBdZ7gChODVby92rXjxwjvwMYkF4L+omRJg3F8rHkBG29FXxvZId3LmzaY3P0hbTjXyiDRS2Zw/KNP2dZoHQBxTMhG9zs3fz2hMiYU8jZeG9xy/v7JaTxs1PRb3o5q6RMbfaKcd9XUITl3UxgOG0E54HaY8O6ZIjOYt+QXLnBRfLKqPw1WNRQKbEWnR2gwE6PjEASmekmMg6iQedkpvVC0fCsGWKupVqEKb1VSiftu9/qNsCheCmNvOvhjOOaoQaz+pRe6Lof39WjfIGYcf0NYiPf2Te+U64aXpNcjoTyV+pGgnNMGQNX7SymxGcnvn4VwtKhUdLzG/98g2AWtggz2POO8MkOsSOhsgvYPt16sPFek7jWO5Ugq0= 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:(13230028)(4636009)(396003)(39860400002)(366004)(346002)(136003)(376002)(451199021)(6506007)(186003)(6486002)(26005)(83380400001)(2616005)(4326008)(5660300002)(316002)(66476007)(66556008)(66946007)(6512007)(41300700001)(8676002)(8936002)(7406005)(54906003)(478600001)(6666004)(2906002)(110136005)(36756003)(7416002)(86362001)(38100700002)(921005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tF5tcXscjLgH79dYnfpvwZgjdz8i5v9K7+yNa6DW5rAroFsyApssQuX7PhUqriIKWzjiorodDoVaJOSO086lcAj5SNLeOdN+9h2nLxoLvOq5XQCbiEy/3aEBp4iwH22IzkjBX586Pi6ocXiFTlzIaocs7wAghjmk++YRu7f6YjE/y4Bdygf27gW+DR2mYdFF88joJ1CvE8BffP3kC063Y2zh4m0beTLkATtK8POjcv2PnCgHSpVil8Ubj2eXP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/PPw34sYV43iuHCUQA1jApgnkzEPJ3eCX22Fk7SepUkkhoQh9lRmm8fxaf+9Q9g1ieQzNJx3Cz0lzCs4mIisAi/2S58l8p0p5gPVw4D7CIOF/91bUjc06tt3b6wGDkaQ/8gnd1NGrEMnPtfR17bMXU2RSlhEASa7L9Xm5UQdN8jQzCpvOi4Qq2cXgCg2kNpKGFkQHioOmEsM7Yp3UgqbN0XYramJGTxHAZ/J00VTtI/JjqMVvYi+Pbr4Hzreda X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2a4153af-b8d6-478f-7ebe-08db4a6e50d5 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2023 18:03:06.8138 (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: 9QdpPvODeB9lqC5SbDgoXdAphJ9eygw24UQ4DHBn3L7znTILaOb23+CSAzTiDxv/ X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6457 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230501_110320_782377_9D09F457 X-CRM114-Status: GOOD ( 10.26 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This brings back the ops->detach_dev() code that commit 1b932ceddd19 ("iommu: Remove detach_dev callbacks") deleted and turns it into an IDENTITY domain. Signed-off-by: Jason Gunthorpe --- drivers/iommu/sun50i-iommu.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/iommu/sun50i-iommu.c b/drivers/iommu/sun50i-iommu.c index 74c5cb93e90027..15fd62d360778f 100644 --- a/drivers/iommu/sun50i-iommu.c +++ b/drivers/iommu/sun50i-iommu.c @@ -772,6 +772,26 @@ static void sun50i_iommu_detach_device(struct iommu_domain *domain, sun50i_iommu_detach_domain(iommu, sun50i_domain); } +static int sun50i_iommu_identity_attach(struct iommu_domain *identity_domain, + struct device *dev) +{ + struct sun50i_iommu *iommu = dev_iommu_priv_get(dev); + + if (iommu->domain == identity_domain || !iommu->domain) + return 0; + sun50i_iommu_detach_device(iommu->domain, dev); + return 0; +} + +static struct iommu_domain_ops sun50i_iommu_identity_ops = { + .attach_dev = sun50i_iommu_identity_attach, +}; + +static struct iommu_domain sun50i_iommu_identity_domain = { + .type = IOMMU_DOMAIN_IDENTITY, + .ops = &sun50i_iommu_identity_ops, +}; + static int sun50i_iommu_attach_device(struct iommu_domain *domain, struct device *dev) { @@ -827,6 +847,7 @@ static int sun50i_iommu_of_xlate(struct device *dev, } static const struct iommu_ops sun50i_iommu_ops = { + .identity_domain = &sun50i_iommu_identity_domain, .pgsize_bitmap = SZ_4K, .device_group = sun50i_iommu_device_group, .domain_alloc = sun50i_iommu_domain_alloc,