From patchwork Tue Aug 14 10:55:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 10565359 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8BEC11805 for ; Tue, 14 Aug 2018 11:12:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 778A329860 for ; Tue, 14 Aug 2018 11:12:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 68B64298F8; Tue, 14 Aug 2018 11:12:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 191AF29860 for ; Tue, 14 Aug 2018 11:12:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=RTROfX8cQb8ZzezV2TAJ3ZMlXi2ynL9vCEygkSlhAHg=; b=WrI+UVIQZhQwNHis/Ye+89fOtJ /bkIQwy27qqq8iWEW4nclgPUUkQTFDW2DojFNw1JdUjuHwBvDx35Z0Rz4hc91kDjnurCq5pFIcF+w dYE58u+GNSDf/cly2kF/mf64cWk8KPn9fQLBDdFECHc6/dlFuvd+hGgqGr8EqUNl4cbXxzRJlXi36 Ya4LFWWIr0af0EpJoklZCywhOuezxDwD6TwPu5H3v/gBdL+hnePqVPvJ9H/RMuMchKmGdLZl14sz1 62XMtugxzpQe3GaeHWXwxiRcoJ3VrcbbceHhj9i23Bmgfmqhu8CR40oADk9w3lOCdlGunDlX1rPTp G+9AdzLQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fpXF3-0004Yu-Qm; Tue, 14 Aug 2018 11:12:01 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fpXF2-0004XB-2k for linux-arm-kernel@bombadil.infradead.org; Tue, 14 Aug 2018 11:12:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=xMqNUQNdNSaM8QEfQHA2D672uZoARsUSE9iLhDeVGBg=; b=QC5oicVDUhU0i5WjQE3fJqm7h jnBAJ/0/pcVVhT9ba9tM98jUs+wR7y/NQd02ebsI26rADJElrT65Hw8IR/ci2eRsH664WAV5Vrh8x 1RNAOobSEr1qxryReRKkpDajkne3i/2sbak1JXaMV0I20IHh2goCNsgjn2sO6ejvom6oNglabe9WO AjxsduPUvRNsf0EfTWqFfaTEG2cFxWFM3Lef7b6sRGzf9pSWIRxeG4kxw3dX4Yc4Pd/xa+wn7dMj/ n6ot02LO4Ze4TsBfl0lIDuCqeHVV8tTUFC4CrWkPd/87EfC5tUK5CB6YFKkol5Rzv0+zoynZdrHlT iKohLcG5w==; Received: from smtp.codeaurora.org ([198.145.29.96]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fpWzy-0005Q7-Ev for linux-arm-kernel@lists.infradead.org; Tue, 14 Aug 2018 10:56:28 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 69D0A60C6C; 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=1534244172; bh=imINSkoKG3HWjUH9No+Ke/14n2fh8HwmVPnF9Gezd+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QbzgSDy1TlvB7vINWGk6wEshCVg1kURM7TjxMJ7jlIsRc3TXbmODz/+jF8pMjCqJe AJW7+pVHAFsapaPN7APXN88N3gOj6gsuI9AxvAhHqhi/877uFnC2NPiataXxdlGSOV tR61vcKvM68XUWyVOsmVn7/UcJ6iJ8m8DJqdZ9Yg= 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180814_115626_764178_1FC4E8D2 X-CRM114-Status: GOOD ( 13.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, swboyd@chromium.org, david.brown@linaro.org, Vivek Gautam , tfiga@chromium.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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