Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752095AbdGMMCu (ORCPT ); Thu, 13 Jul 2017 08:02:50 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:33434 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751106AbdGMMCr (ORCPT ); Thu, 13 Jul 2017 08:02:47 -0400 X-AuditID: cbfec7f2-f797e6d000004438-7f-59676163cd7f Subject: Re: [PATCH V4 3/6] iommu/arm-smmu: Invoke pm_runtime during probe, add/remove device To: Rob Clark , Sricharan R Cc: Vivek Gautam , Stephen Boyd , Joerg Roedel , Robin Murphy , Rob Herring , Mark Rutland , Will Deacon , "iommu@lists.linux-foundation.org" , "devicetree@vger.kernel.org" , Linux Kernel Mailing List , linux-clk , linux-arm-msm , Stanimir Varbanov , Archit Taneja , "linux-arm-kernel@lists.infradead.org" From: Marek Szyprowski Message-id: <939f8745-6f72-522c-1216-70e424740b62@samsung.com> Date: Thu, 13 Jul 2017 14:02:40 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-version: 1.0 In-reply-to: Content-type: text/plain; charset=utf-8; format=flowed Content-transfer-encoding: 7bit Content-language: en-US X-Brightmail-Tracker: H4sIAAAAAAAAA02SbUhTURjHO7v3bnfL6W1aPqi9MIrI0JL6cLDoBfpwwS9RFJmhjbxNcTPZ Vcv6YC/OdJk298GaOo3USpbFTNPIamulmFnDWoYmhpll3jJN0AKreRfs2++c53ee8/wPhyZU E1QEnZ6ZzRkyNTq1VEG2Ppt7GXNEo03ceG9qMT5bJFC4xt1L4dpHW3Bx5R0Zdox4KWx+9EKG f5QMUbjvfpUU17/1SPDY1VkCGzvcMuyc/Ejh2Z4LJP5pLiJxQaFbgrvm2gj85UcXuWMJ+9Fp k7B2mx2xfaUXJWy79b2MdTQWS9lB7wMp21yXz1r6ryN22rFit/ygYmsqp0vP5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HKk jxnCFpO4cG89WxcjF4eQwBJGiZ9TZjBDOM8ZJQ5cb2YEqRIWiJfY8fg5UxcjB4eIgLfEg09B IDXMApdZJV6suw7VfYBZ4unLSSwgDWwChhJdb7vYQGxeATuJhfPOg9ksAqoSq64tYQKxRQVi JK7NvMMKUSMo8WPyPbBeToFgiaMPethBbGYBM4kvLw+zQtjyEpvXvGWGsMUlmltvskxgFJyF pH0WkpZZSFpmIWlZwMiyilEktbQ4Nz232FCvODG3uDQvXS85P3cTIzAtbDv2c/MOxksbgw8x CnAwKvHwcmimRQqxJpYVV+YeYpTgYFYS4V0anR4pxJuSWFmVWpQfX1Sak1p8iNEU6LmJzFKi yfnAlJVXEm9oYmhuaWhkbGFhbmSkJM5b8uFKuJBAemJJanZqakFqEUwfEwenVANjrt+bfU79 EspOpeW+V+9JiWrp7ck5+/3F+oiK0iWxk3N2m0z5v1qP0zOsKcbly8Vfzh3hJTfqm1tn7Tzr 9Hthq7zyDqeyywe9Z09oV7G7Utr4kbPZ+WKQyBV17p5dRzfHed6bufeRTrhmfs2TpdtiKm8d cNXOnTNPLLe2XT1U5ukDvrk3lngpsRRnJBpqMRcVJwIAZP9jtyEDAAA= X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170713120242eucas1p2eeaf1b03737435486b6f82593f6ceb81 X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?UTF-8?B?TWFyZWsgU3p5cHJvd3NraRtTUlBPTC1LZXJuZWwgKFRQKRs=?= =?UTF-8?B?7IK87ISx7KCE7J6QG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Global-Sender: =?UTF-8?B?TWFyZWsgU3p5cHJvd3NraRtTUlBPTC1LZXJuZWwgKFRQKRtT?= =?UTF-8?B?YW1zdW5nIEVsZWN0cm9uaWNzG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Sender-Code: =?UTF-8?B?QzEwG0VIURtDMTBDRDAyQ0QwMjczOTI=?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20170713115036epcas1p250113e9009dbf92487d258a90fffc66a X-RootMTR: 20170713115036epcas1p250113e9009dbf92487d258a90fffc66a References: <1499333825-7658-1-git-send-email-vivek.gautam@codeaurora.org> <1499333825-7658-4-git-send-email-vivek.gautam@codeaurora.org> <20170712225459.GZ22780@codeaurora.org> <5ee0bacd-e557-a6c4-a897-844fb12ea6ae@codeaurora.org> <4dbc938c-ac88-9bd4-cf00-458008ae24c1@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2397 Lines: 51 Hi All, On 2017-07-13 13:50, Rob Clark wrote: > On Thu, Jul 13, 2017 at 1:35 AM, Sricharan R wrote: >> On 7/13/2017 10:43 AM, Vivek Gautam wrote: >>> On 07/13/2017 04:24 AM, Stephen Boyd wrote: >>>> On 07/06, Vivek Gautam wrote: >>>>> @@ -1231,12 +1237,18 @@ static int arm_smmu_map(struct iommu_domain *domain, unsigned long iova, >>>>> static size_t arm_smmu_unmap(struct iommu_domain *domain, unsigned long iova, >>>>> size_t size) >>>>> { >>>>> - struct io_pgtable_ops *ops = to_smmu_domain(domain)->pgtbl_ops; >>>>> + struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); >>>>> + struct io_pgtable_ops *ops = smmu_domain->pgtbl_ops; >>>>> + size_t ret; >>>>> if (!ops) >>>>> return 0; >>>>> - return ops->unmap(ops, iova, size); >>>>> + pm_runtime_get_sync(smmu_domain->smmu->dev); >>>> Can these map/unmap ops be called from an atomic context? I seem >>>> to recall that being a problem before. >>> That's something which was dropped in the following patch merged in master: >>> 523d7423e21b iommu/arm-smmu: Remove io-pgtable spinlock >>> >>> Looks like we don't need locks here anymore? >> Apart from the locking, wonder why a explicit pm_runtime is needed >> from unmap. Somehow looks like some path in the master using that >> should have enabled the pm ? >> > Yes, there are a bunch of scenarios where unmap can happen with > disabled master (but not in atomic context). On the gpu side we > opportunistically keep a buffer mapping until the buffer is freed > (which can happen after gpu is disabled). Likewise, v4l2 won't unmap > an exported dmabuf while some other driver holds a reference to it > (which can be dropped when the v4l2 device is suspended). > > Since unmap triggers tbl flush which touches iommu regs, the iommu > driver *definitely* needs a pm_runtime_get_sync(). Afair unmap might be called from atomic context as well, for example as a result of dma_unmap_page(). In exynos IOMMU I simply check the runtime PM state of IOMMU device. TLB flush is performed only when IOMMU is in active state. If it is suspended, I assume that the IOMMU controller's context is already lost and its respective power domain might be already turned off, so there is no point in touching IOMMU registers. Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland