From patchwork Thu Jan 11 08:22:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffy Chen X-Patchwork-Id: 10157595 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0D648602B3 for ; Thu, 11 Jan 2018 08:40:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EEE8A28517 for ; Thu, 11 Jan 2018 08:40:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E37B028526; Thu, 11 Jan 2018 08:40:52 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 66D0C28517 for ; Thu, 11 Jan 2018 08:40:52 +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=SxU8TZwSKM6n2OGWb+mXDWuz1QnPKY9qvAJ0lh2C0Qk=; b=Lc0c19UTED4P3Ccp/8a9ZbS9kz lXKSlLktxULq0Dw+99mobRNa3V83swaWUSOUtVIXGkRw3YyR00mz0W34OHNhRlkngM1Ja9QYrhlIE uttxQV8hJYZ6R9sKTcurNroPxj1UuaDollWBxee8GdOWxaJMZR+P1QWzZzRIcZeFgWa7aMuu3O8LZ e80Lz/JYPfNLhq+7mPDnXZALgKwitQrqh6Lzb0+zhEiuko2yacx9zqiPxA6HvLLYuTI3MT+TyRFL0 MPbdDXOqH16LJx9HGOjd5XGBS/KMLzz1NkFqlQGHeeOnk0VZkwnjCiyr0RKLk9QNXDtN7a9ZyfAUd tepo776Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eZYPq-0003F1-HG; Thu, 11 Jan 2018 08:40:50 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eZYPO-00019W-5g; Thu, 11 Jan 2018 08:40:22 +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=t4hiHx0DydxofJUV1+F8Vs3lJUwpNYrH1uQ/9dbhkwE=; b=qvou9cK4i+ADr6o3QnxWvaQY9 iYCRyrBM+UqCGSHN3W8YjqjtyeWQ6sc9VAh/aI6hlUGR0ZMB9zlnPxAd75TuT7EQy0t2/wj9Hzts5 tl1n0WPyc3jR6gaCG6BmrqfqBKjcEZBmkSNWTFVy9ANt7/DS1pmpuypwgI9epCdySOeMcwvmZIa+i 0CM96OC1bBNNBCuLaK6y42l5mMPBBJu/CuQ7VD0yNRi9jSmiqcwnk5ODSpA2PwltldihG0P4WmNu6 b0ER1rNeCAQe9r2e0XGKquKN/rZHMwcPD8AC7Tlfy4pVlMK3KwqWW9EKXa9AdV6hGcnMvty3TnZaV zkOdkPFYw==; Received: from regular1.263xmail.com ([211.150.99.133]) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eZY9m-0002wl-Rh; Thu, 11 Jan 2018 08:24:18 +0000 Received: from jeffy.chen?rock-chips.com (unknown [192.168.167.164]) by regular1.263xmail.com (Postfix) with ESMTP id 8523A8E79; Thu, 11 Jan 2018 16:23:44 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id 92DDF3C7; Thu, 11 Jan 2018 16:23:41 +0800 (CST) X-RL-SENDER: jeffy.chen@rock-chips.com X-FST-TO: linux-kernel@vger.kernel.org X-SENDER-IP: 103.29.142.67 X-LOGIN-NAME: jeffy.chen@rock-chips.com X-UNIQUE-TAG: <9d09d3d724d45c6545746d108e8e1d8e> X-ATTACHMENT-NUM: 0 X-SENDER: cjf@rock-chips.com X-DNS-TYPE: 0 Received: from localhost (unknown [103.29.142.67]) by smtp.263.net (Postfix) whith ESMTP id 70434Y38UJ; Thu, 11 Jan 2018 16:23:45 +0800 (CST) From: Jeffy Chen To: linux-kernel@vger.kernel.org Subject: [PATCH 6/9] iommu/rockchip: Fix TLB flush of secondary IOMMUs Date: Thu, 11 Jan 2018 16:22:26 +0800 Message-Id: <20180111082229.24011-7-jeffy.chen@rock-chips.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180111082229.24011-1-jeffy.chen@rock-chips.com> References: <20180111082229.24011-1-jeffy.chen@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180111_082415_756622_03DD880A X-CRM114-Status: GOOD ( 10.81 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Heiko Stuebner , Joerg Roedel , Jeffy Chen , tfiga@chromium.org, jcliang@chromium.org, linux-rockchip@lists.infradead.org, iommu@lists.linux-foundation.org, robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tomasz Figa Due to the bug in current code, only first IOMMU has the TLB lines flushed in rk_iommu_zap_lines. This patch fixes the inner loop to execute for all IOMMUs and properly flush the TLB. Signed-off-by: Tomasz Figa Signed-off-by: Jeffy Chen --- drivers/iommu/rockchip-iommu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index 6b797e085340..cfeafbf54096 100644 --- a/drivers/iommu/rockchip-iommu.c +++ b/drivers/iommu/rockchip-iommu.c @@ -274,19 +274,21 @@ static void rk_iommu_base_command(void __iomem *base, u32 command) { writel(command, base + RK_MMU_COMMAND); } -static void rk_iommu_zap_lines(struct rk_iommu *iommu, dma_addr_t iova, +static void rk_iommu_zap_lines(struct rk_iommu *iommu, dma_addr_t iova_start, size_t size) { int i; - - dma_addr_t iova_end = iova + size; + dma_addr_t iova_end = iova_start + size; /* * TODO(djkurtz): Figure out when it is more efficient to shootdown the * entire iotlb rather than iterate over individual iovas. */ - for (i = 0; i < iommu->num_mmu; i++) - for (; iova < iova_end; iova += SPAGE_SIZE) + for (i = 0; i < iommu->num_mmu; i++) { + dma_addr_t iova; + + for (iova = iova_start; iova < iova_end; iova += SPAGE_SIZE) rk_iommu_write(iommu->bases[i], RK_MMU_ZAP_ONE_LINE, iova); + } } static bool rk_iommu_is_stall_active(struct rk_iommu *iommu)