From patchwork Fri Feb 17 11:21:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 654867 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96991C05027 for ; Fri, 17 Feb 2023 11:21:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229904AbjBQLVv (ORCPT ); Fri, 17 Feb 2023 06:21:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229803AbjBQLVu (ORCPT ); Fri, 17 Feb 2023 06:21:50 -0500 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73C6816AE2 for ; Fri, 17 Feb 2023 03:21:47 -0800 (PST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230217112143euoutp01fc6bbcd7b7f62f2b47666cfa8739350f~EmL4Z43QB2433924339euoutp01I for ; Fri, 17 Feb 2023 11:21:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230217112143euoutp01fc6bbcd7b7f62f2b47666cfa8739350f~EmL4Z43QB2433924339euoutp01I DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1676632903; bh=+uOpsJCb+Nz9liQB+kMqji9vblPsM55cQXn1mbsU4F0=; h=From:To:Cc:Subject:Date:References:From; b=lUt59TRmq5ziJ3073xYX9wiA4TFSM/ZhOPgrYk0AsvCsWywmkDXI0z4WBW3kG+F1+ HvaDFzide34pc785EoBqDTR7yKnwFaflywpcuvtyH8IDUiz2h/h/aGlDD0ELZ/aPza kD3vRDp2Z3j/pJs1HDO9/JK/rU4ykQ/LTP12wqmk= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230217112140eucas1p178afa3ad5cc3e92f3c09b7339c9cbe02~EmL1iJ-Jk2773627736eucas1p1N; Fri, 17 Feb 2023 11:21:40 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id CE.D3.61197.4436FE36; Fri, 17 Feb 2023 11:21:40 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230217112140eucas1p1703b82cfcdb933f07baa154183845986~EmL1J4ceV1036610366eucas1p1K; Fri, 17 Feb 2023 11:21:40 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230217112140eusmtrp233be37adf77008a1df1522ba82d13087~EmL1I0UfW2334023340eusmtrp2Y; Fri, 17 Feb 2023 11:21:40 +0000 (GMT) X-AuditID: cbfec7f5-7c5ff7000000ef0d-b4-63ef6344fae1 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 8F.8D.00518.3436FE36; Fri, 17 Feb 2023 11:21:39 +0000 (GMT) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230217112139eusmtip28c25a8baa540d8515329c27011c372ab~EmL0kK9yh1230512305eusmtip2H; Fri, 17 Feb 2023 11:21:39 +0000 (GMT) From: Marek Szyprowski To: iommu@lists.linux.dev, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Joerg Roedel , Will Deacon , Robin Murphy , Krzysztof Kozlowski , lim Akhtar , Lu Baolu , Jason Gunthorpe Subject: [PATCH] iommu/exynos: Fix set_platform_dma_ops() callback Date: Fri, 17 Feb 2023 12:21:29 +0100 Message-Id: <20230217112129.18879-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrMKsWRmVeSWpSXmKPExsWy7djPc7ouye+TDZ4cFbV4MG8bm8XmiVvZ LH59sbCYOeMEo0Xn7A3sFntfb2W3mHF+H5PF2iN32S0OfnjCatFyx9SBy+PJwXlMHmvmrWH0 2LSqk83jzrU9bB7zTgZ6vNg8k9Gjb8sqRo/Pm+Q8tn6+zRLAGcVlk5Kak1mWWqRvl8CV8Xx7 G0vBJaGKa89XsTcwfubvYuTkkBAwkVjwbDV7FyMXh5DACkaJr0f3MkE4Xxgl1i+awwLhfGaU 6Dv1gRWmZe/DVjaIxHJGidP/TiG0HNizjxGkik3AUKLrbRcbiC0iYCNx5dQSsA5mgT1MElte 3mMHSQgLOElcnLmCCcRmEVCVeL3rFVicV8BWYuubiVDr5CUuHpnHDBEXlDg58wkLiM0MFG/e OpsZZKiEwAUOicbOmSwQDS4Sc/d0MEPYwhKvjm9hh7BlJP7vnM8E0dDOKLHg930oZwKjRMPz W4wQVdYSd879ArqVA2iFpsT6XfogpoSAo8TyeTwQJp/EjbeCEDfwSUzaNp0ZIswr0dEmBDFD TWLW8XVwWw9euAR1jYdEz81bYO8KCcRKdBxaxj6BUWEWks9mIflsFsIJCxiZVzGKp5YW56an FhvnpZbrFSfmFpfmpesl5+duYgSmq9P/jn/dwbji1Ue9Q4xMHIyHGCU4mJVEeDfdfJMsxJuS WFmVWpQfX1Sak1p8iFGag0VJnFfb9mSykEB6YklqdmpqQWoRTJaJg1OqganaL/ivfe3ilEWx wfPY90/3zV7yO4nRrv1w9iZVtZMh/MyZBhqZKSyfLzBLzL7SfnBD5HzDXPOS7BcXWcoSr06I K+tbXhKzeUrmWptsNeEcp12iz1vKvsnNO3dVMuDpvU7n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IxxRm66VTKq5eNas4pDz56hGjXb4brA2mKMnsTlgnFujwJb7f5rMJ B+/r9TMeOW6uVd9yb5pO+6ZLefeW+q3fFicSOVOquCYkfcqqmQJXgj5seh75+e+pd0WavtOa ijq3xvDsO8rsIvRbpkVPbZ9+r/XVBd9zdEo57+xnZT9golscPe/Oh8ks0hOKb5yZeUBi1S71 R5/FlViKMxINtZiLihMBdekHghsDAAA= X-CMS-MailID: 20230217112140eucas1p1703b82cfcdb933f07baa154183845986 X-Msg-Generator: CA X-RootMTR: 20230217112140eucas1p1703b82cfcdb933f07baa154183845986 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230217112140eucas1p1703b82cfcdb933f07baa154183845986 References: Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org There are some subtle differences between release_device() and set_platform_dma_ops() callbacks, so separate those two callbacks. Device links should be removed only in release_device(), because they were created in probe_device(). While fixing this, remove the conditional code as it is not really needed. Reported-by: Jason Gunthorpe Fixes: 189d496b48b1 ("iommu/exynos: Add missing set_platform_dma_ops callback") Signed-off-by: Marek Szyprowski --- drivers/iommu/exynos-iommu.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 483aaaeb6dae..4141625542ef 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -1415,23 +1415,26 @@ static struct iommu_device *exynos_iommu_probe_device(struct device *dev) return &data->iommu; } -static void exynos_iommu_release_device(struct device *dev) +static void exynos_iommu_set_platform_dma(struct device *dev) { struct exynos_iommu_owner *owner = dev_iommu_priv_get(dev); - struct sysmmu_drvdata *data; if (owner->domain) { struct iommu_group *group = iommu_group_get(dev); if (group) { -#ifndef CONFIG_ARM - WARN_ON(owner->domain != - iommu_group_default_domain(group)); -#endif exynos_iommu_detach_device(owner->domain, dev); iommu_group_put(group); } } +} + +static void exynos_iommu_release_device(struct device *dev) +{ + struct exynos_iommu_owner *owner = dev_iommu_priv_get(dev); + struct sysmmu_drvdata *data; + + exynos_iommu_set_platform_dma(dev); list_for_each_entry(data, &owner->controllers, owner_node) device_link_del(data->link); @@ -1478,11 +1481,9 @@ static int exynos_iommu_of_xlate(struct device *dev, static const struct iommu_ops exynos_iommu_ops = { .domain_alloc = exynos_iommu_domain_alloc, .device_group = generic_device_group, -#ifdef CONFIG_ARM - .set_platform_dma_ops = exynos_iommu_release_device, -#endif .probe_device = exynos_iommu_probe_device, .release_device = exynos_iommu_release_device, + .set_platform_dma_ops = exynos_iommu_set_platform_dma, .pgsize_bitmap = SECT_SIZE | LPAGE_SIZE | SPAGE_SIZE, .of_xlate = exynos_iommu_of_xlate, .default_domain_ops = &(const struct iommu_domain_ops) {