Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4281631ooa; Tue, 14 Aug 2018 03:59:23 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxKtVVCdN8ChjSn8s4hRm9MJMz4S1jVaTTpmCxwFHDUF4EOp3riO6N3GvCLeRxNm5uDCRmK X-Received: by 2002:a62:106:: with SMTP id 6-v6mr23125904pfb.168.1534244362976; Tue, 14 Aug 2018 03:59:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534244362; cv=none; d=google.com; s=arc-20160816; b=kV/D6aHww9+r8efYBQN4hivT/i9VrputHFMxsaiv058FXL1sdQjLypYVIShME8hs06 JTqR8FTcNjoVdh4ZyHmT04K6x3O7Pgkac+RHnF3xoYKJfoazfSdvoIGe0FWYSPFetj04 L924lmA/9LKPStF00yMQFhLxX0ULTDW4fbc1tX0Io9SE7E7gQx5o4K4tAOFMEiVORBoo HPQRYIxgUK6mMrdO7Pvn4aTYQSBn62wCF1JjoD2lmbsdi7qYPhAg3KDtZ7gxb95Q7Dmx cik4it2TdDW5v0VxRhGhsGP5Wh3SnOzmXvE4Xdckaa1fyXzEQJXsJcqXRF/g8IwOT0AR RTkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=xMqNUQNdNSaM8QEfQHA2D672uZoARsUSE9iLhDeVGBg=; b=s7rSlGdywUuS4Y5qcLRV7teI8t1iuXxGqd+m9Q5nYGjbjdEyHV7xmRyyjQjPEASggu bHhIXcEGTtdxff7y35wmX9H5/Eg085XHe73Kb38pFk4H9aea7kha4DL4h0OYJ32B+Mhe J7sLqIHXX/gm1CmYunyIGbPXbhh8htnS+4PERi7A3CvyDtV20BGeflvNFch+PM9WBeOA SARDQ+ofJegMNTvsWFADU6rSiELckfF9d4QnstJ2YTI4536s2Q8dJU3aBizuJ/o1eg8s dHGG7JSAUHuSsi0zt2oYJJ5wuVyMmOjHP5HahVXu5g8VKz9LOof5o3Kd5C8+M7CWPz6w 8rTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=lgazkwG4; dkim=pass header.i=@codeaurora.org header.s=default header.b=cRp4UaBs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u21-v6si20605267pgn.86.2018.08.14.03.59.08; Tue, 14 Aug 2018 03:59:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=lgazkwG4; dkim=pass header.i=@codeaurora.org header.s=default header.b=cRp4UaBs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732021AbeHNNmz (ORCPT + 99 others); Tue, 14 Aug 2018 09:42:55 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:54570 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727858AbeHNNmy (ORCPT ); Tue, 14 Aug 2018 09:42:54 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 6C5C660C8A; Tue, 14 Aug 2018 10:56:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1534244175; bh=imINSkoKG3HWjUH9No+Ke/14n2fh8HwmVPnF9Gezd+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lgazkwG4V3x+qiers/QYsmXb/qxY2Z2OxKpDhegmJXBV3rULFapzUY+9yCajhmXtA L2smSNpSyHTHD5fSLT6XM9eRhHHhCsxp3VyCjfLm8wYcK0sWbQezqhskosuWsj/x71 K3mHmh3VRZANe4r753Ga7Z4GaUjc7s0toCIiIKUM= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from blr-ubuntu-41.ap.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: vivek.gautam@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id A945B608C9; Tue, 14 Aug 2018 10:55:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1534244160; bh=imINSkoKG3HWjUH9No+Ke/14n2fh8HwmVPnF9Gezd+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cRp4UaBsT3HkwMoHm+k/MM6qd33Aj9+GPOPm/WpM4yHGlx/QNImZKhwjsk2Gmqx66 BnqI5oixW3yOpoO3H9P4Fkrrr8tU7vteQhsn+Yk7tgWEuwVmTeTbKpBI5nCo56GmMu 9g0PW6D8yK+wiFXdSyFm2sEVGz5BUe9BkHEFAev8= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org A945B608C9 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=vivek.gautam@codeaurora.org From: Vivek Gautam To: joro@8bytes.org, andy.gross@linaro.org, will.deacon@arm.com, robin.murphy@arm.com, bjorn.andersson@linaro.org, iommu@lists.linux-foundation.org Cc: mark.rutland@arm.com, david.brown@linaro.org, tfiga@chromium.org, swboyd@chromium.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Vivek Gautam Subject: [PATCH 4/5] iommu/arm-smmu: Make way to add Qcom's smmu-500 errata handling Date: Tue, 14 Aug 2018 16:25:27 +0530 Message-Id: <20180814105528.20592-5-vivek.gautam@codeaurora.org> X-Mailer: git-send-email 2.16.1.72.g5be1f00a9a70 In-Reply-To: <20180814105528.20592-1-vivek.gautam@codeaurora.org> References: <20180814105528.20592-1-vivek.gautam@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Cleanup to re-use some of the stuff Signed-off-by: Vivek Gautam --- drivers/iommu/arm-smmu.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 32e86df80428..75c146751c87 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -391,21 +391,31 @@ static void __arm_smmu_free_bitmap(unsigned long *map, int idx) clear_bit(idx, map); } -/* Wait for any pending TLB invalidations to complete */ -static void __arm_smmu_tlb_sync(struct arm_smmu_device *smmu, - void __iomem *sync, void __iomem *status) +static int __arm_smmu_tlb_sync_wait(void __iomem *status) { unsigned int spin_cnt, delay; - writel_relaxed(0, sync); for (delay = 1; delay < TLB_LOOP_TIMEOUT; delay *= 2) { for (spin_cnt = TLB_SPIN_COUNT; spin_cnt > 0; spin_cnt--) { if (!(readl_relaxed(status) & sTLBGSTATUS_GSACTIVE)) - return; + return 0; cpu_relax(); } udelay(delay); } + + return -EBUSY; +} + +/* Wait for any pending TLB invalidations to complete */ +static void __arm_smmu_tlb_sync(struct arm_smmu_device *smmu, + void __iomem *sync, void __iomem *status) +{ + writel_relaxed(0, sync); + + if (!__arm_smmu_tlb_sync_wait(status)) + return; + dev_err_ratelimited(smmu->dev, "TLB sync timed out -- SMMU may be deadlocked\n"); } @@ -461,8 +471,9 @@ static void arm_smmu_tlb_inv_context_s2(void *cookie) arm_smmu_tlb_sync_global(smmu); } -static void arm_smmu_tlb_inv_range_nosync(unsigned long iova, size_t size, - size_t granule, bool leaf, void *cookie) +static void __arm_smmu_tlb_inv_range_nosync(unsigned long iova, size_t size, + size_t granule, bool leaf, + void *cookie) { struct arm_smmu_domain *smmu_domain = cookie; struct arm_smmu_cfg *cfg = &smmu_domain->cfg; @@ -498,6 +509,13 @@ static void arm_smmu_tlb_inv_range_nosync(unsigned long iova, size_t size, } } +static void arm_smmu_tlb_inv_range_nosync(unsigned long iova, size_t size, + size_t granule, bool leaf, + void *cookie) +{ + __arm_smmu_tlb_inv_range_nosync(iova, size, granule, leaf, cookie); +} + /* * On MMU-401 at least, the cost of firing off multiple TLBIVMIDs appears * almost negligible, but the benefit of getting the first one in as far ahead -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation