From patchwork Thu Oct 13 18:12:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 13006271 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C6731C43217 for ; Thu, 13 Oct 2022 18:14:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wa37Xrlh4VbGNb1v4SregQANdyv3UjMzCaUYRF5UPyo=; b=eIVdQqEHhsOsTV xrB1QOOCe5kZZ6VThX2Gn49N8yy4ut+LBLqiykXbG8psRaXylbZdTvg6BrKo76CMXjMTN3B8qyCJb 4udsS/vp19PVo0LYCQ1ESkbLG9gVnx2uqxdH+dQmF2LRDj3xUN9uIiV3+4Q9eX6yAOuVmPrLnhrBr 0H+hs1sLWR8v/qAjvDsTC8tWIF70w277I5re6L64pIR7T/9YOJrr1DbNrWwIptjGX/DAI/397xpiP N2vaFJJM2l5No7VuI0LcbGGWsmLK1GM+wdq4l9lLE1VHSNYmeQ878CtNLjA/IehLIFIREaHq8FA54 SVyhI9IGEL5+rB/wgDNw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oj2hn-00CdOX-IG; Thu, 13 Oct 2022 18:13:15 +0000 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oj2hT-00CdEp-7E for linux-arm-kernel@lists.infradead.org; Thu, 13 Oct 2022 18:12:57 +0000 Received: by mail-ed1-x52d.google.com with SMTP id u21so3734325edi.9 for ; Thu, 13 Oct 2022 11:12:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wy++TP4MEmK9+IncYVXW5dpqxIdw3c9kXrFdre+ha14=; b=CQ9TnzAPgu0twXcz51eJtm0MYyiV+U12yy5ia/sBn3YqCfoEQNZbJox/YeWnpaIBoE TYEM9Hw0EGjn2tXKlAWjrkaORyfaKwcar28Ec7NSFIeLYAllGCqNh2pU2PYx3LxsqxFG 6z6XuuKosJtWm6yPV0CdYsnYS7GdnBmUj7R82Ws3yOFTwaIxD32pVpcKhNvW/hq4azh/ pyxMhT+TJGWjw77Bz/d7ZlNR59kXaW9mCpfOPX3rRypwf8LOMd1e3Oc7h8YH1pyz08E5 rppEhw2WHhCkDKW3evmIBSWV1bQ5vA0vM4LjoFtItLlNwt+gYHNoOtSigZItkYpjUT00 NUTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wy++TP4MEmK9+IncYVXW5dpqxIdw3c9kXrFdre+ha14=; b=mLmFayfkznVc5skwBMKt72eHAIAkd5iaUTcrwos5pikxao9s5NjKzFgTrukfrj6FhI 0vogGS/U+ie2Y9Q3rn1XWFktZUWkNY7vg/3X/9j1PdVY5N47iQCfNGY21JaPdspdiqa1 UVXDMf3Hs3kKMSsTBXQudC3x2WcLuEnVV0OaH8J2k9ILOIubgBZ2i3zQTcgbc0vP1k9E LjAVpey3XSXdHYIkYyAFj4sM/TdjM93/d8VPPZyuNo2XjPVn5DxdA67rgFsrqgs/ykSP gQ/E4oSpo9t1tCxPJ4LEEsj3Qt2WWE5O6Jhetjfn2EhUsyv3ZOe+eU9Qxfjs1CTQB++d ZGkQ== X-Gm-Message-State: ACrzQf0mve7SGhsFBMK3/Z7bQ1zEXZWTeZxJ92Z3foKxm8LIZ3Q3DeAj oK2JNYRX64kaSXX5kj0Hxa0= X-Google-Smtp-Source: AMsMyM4ICzUCjoigsNUFgWVeKqBHqBJ1tuJkf0WbPLqftDEHH2D+3WKsfapHPDp486t6zWZt35VE2A== X-Received: by 2002:a05:6402:1944:b0:457:fed7:5c30 with SMTP id f4-20020a056402194400b00457fed75c30mr873109edz.278.1665684766034; Thu, 13 Oct 2022 11:12:46 -0700 (PDT) Received: from kista.localdomain (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id ku15-20020a170907788f00b0078b551d2fa3sm211109ejc.103.2022.10.13.11.12.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Oct 2022 11:12:45 -0700 (PDT) From: Jernej Skrabec To: maxime@cerno.tech, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, wens@csie.org, samuel@sholland.org Cc: iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Jernej Skrabec Subject: [PATCH 1/5] iommu/sun50i: Fix reset release Date: Thu, 13 Oct 2022 20:12:16 +0200 Message-Id: <20221013181221.3247429-2-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013181221.3247429-1-jernej.skrabec@gmail.com> References: <20221013181221.3247429-1-jernej.skrabec@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221013_111255_314795_F4C686FE X-CRM114-Status: GOOD ( 13.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Reset signal is asserted by writing 0 to the corresponding locations of masters we want to reset. So in order to deassert all reset signals, we should write 1's to all locations. Current code writes 1's to locations of masters which were just reset which is good. However, at the same time it also writes 0's to other locations and thus asserts reset signals of remaining masters. Fix code by writing all 1's when we want to deassert all reset signals. This bug was discovered when working with Cedrus (video decoder). When it faulted, display went blank due to reset signal assertion. Fixes: 4100b8c229b3 ("iommu: Add Allwinner H6 IOMMU driver") Signed-off-by: Jernej Skrabec --- drivers/iommu/sun50i-iommu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/sun50i-iommu.c b/drivers/iommu/sun50i-iommu.c index a84c63518773..c777882d0ec2 100644 --- a/drivers/iommu/sun50i-iommu.c +++ b/drivers/iommu/sun50i-iommu.c @@ -27,6 +27,7 @@ #include #define IOMMU_RESET_REG 0x010 +#define IOMMU_RESET_RELEASE_ALL 0xffffffff #define IOMMU_ENABLE_REG 0x020 #define IOMMU_ENABLE_ENABLE BIT(0) @@ -893,7 +894,7 @@ static irqreturn_t sun50i_iommu_irq(int irq, void *dev_id) iommu_write(iommu, IOMMU_INT_CLR_REG, status); iommu_write(iommu, IOMMU_RESET_REG, ~status); - iommu_write(iommu, IOMMU_RESET_REG, status); + iommu_write(iommu, IOMMU_RESET_REG, IOMMU_RESET_RELEASE_ALL); spin_unlock(&iommu->iommu_lock); From patchwork Thu Oct 13 18:12:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 13006272 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A3562C433FE for ; Thu, 13 Oct 2022 18:14:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lLF+lI8m5aRlcfmMwtTn76rvIv1xgfXnaQGZ61YQhrY=; b=ygomwhwQTXjb/y nVa8oK0yY1JRQhyMVkO2kIz1TVxTzSYCwZJ54sl1uXJcni4S/94UIFW0hPu/myqk4OTUgsb7x6oBj RkdXXCloOE7m5LRuoazSSJrrdQzmmT1phznjrsIdEJxcO2e3vsRXZv6ZVrXf2c0W5cy7lMv1HEMlM 1mRN1V5IOP+vcNK7toJRpnrKQXs/IRkSYLqgGq3WJ4i1EVO5Q4JIKJ3p9XRCtgAPgp4JXzZe2qN/N Aw6anVih5Xt4i0jl0BomNtwTaO3ixrFAzQjeVepSkwbs5vL9kPZrguSJHpBtqLsCuXZw6it4plkfG NfV9/hWMkHQmWeMmsRsQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oj2hv-00CdQ3-U0; Thu, 13 Oct 2022 18:13:24 +0000 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oj2hT-00CdF1-75 for linux-arm-kernel@lists.infradead.org; Thu, 13 Oct 2022 18:12:57 +0000 Received: by mail-ej1-x62a.google.com with SMTP id d26so5649556ejc.8 for ; Thu, 13 Oct 2022 11:12:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oow4Z/54Ywu9hc74bLjW+CtYs8QrvcOSZ9QuyKFYcEc=; b=ED9AlBSj+HB3AoaKj7DQ6M9wpZ6f6w4GodqNMB1xfK/zk6oF6HLxanhqwuG7Fd6R3S Na43xZWDhuMEVhpRgGli0KufczMvg+iDIQia5e4MkKK7NnuzBjYr9uWV/zTXJ2FFJ9mQ CDyD4aWS4JrSGufnnIK1XfXmJDZocqpnWKg50JoUJhnQJlrDPJUjqGK+uFLhPwnvQaLm DgG4sQ4tmE0ckxaWchNtaudUhH51Q6d4aBK2QPPGJznLm1RAeOMbO6udAqa5gRk6vBbw nvOjXEF3+QAHeLVvYUsrPzaVR7kXWBH6YABlCbDTIH1fcLYhwp2wbMHea3TwU0W1rPJk mbyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oow4Z/54Ywu9hc74bLjW+CtYs8QrvcOSZ9QuyKFYcEc=; b=HzoEfaS73zTvCEp1aNZZ115oQ/G+Rsr9HgogtLwwCitEG48tF+9c7XpRtQCVDBz4tk zCd55Cc9Orohwz38udQU7P1Wgp55TAr7Z+63K/c9UmJuJtHp9yfygobD8ZP3RXKeqvEp u8QfG/dBrwUaCw+yoVducAbH0YBwAxVRUaeWd3tUobsWGLQNEmBMXfLya/EMQKe9w2aV fGEP5lbbIkG2V9QYLKrQelfjfos7dlT0vw/8QHHTLgHcV4pZJdZGEdH+DADVtzrM1Tcz Yy0WselZNY9SpJ5K/yU06PQqpQoWZc05RUe27NlfrsGIQ4VfruV99VK03Z/G2LCC0/oS h7EA== X-Gm-Message-State: ACrzQf1mdYxWqII03N45VsuAbyjSizuZfgEYk9nyR7t2AzUkNtFUscQt 2aKfGFmWZjJ3yJEBI9H0Nu4= X-Google-Smtp-Source: AMsMyM7zbaKTyyrnltI3FlR5A/IP6LXwZcu3J1BPdc+HmT8j7TiQ8hkdI+Pf+LW56SPwakrGxverFA== X-Received: by 2002:a17:906:3fd2:b0:78d:b793:5ef9 with SMTP id k18-20020a1709063fd200b0078db7935ef9mr730855ejj.496.1665684767259; Thu, 13 Oct 2022 11:12:47 -0700 (PDT) Received: from kista.localdomain (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id ku15-20020a170907788f00b0078b551d2fa3sm211109ejc.103.2022.10.13.11.12.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Oct 2022 11:12:46 -0700 (PDT) From: Jernej Skrabec To: maxime@cerno.tech, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, wens@csie.org, samuel@sholland.org Cc: iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Jernej Skrabec Subject: [PATCH 2/5] iommu/sun50i: Consider all fault sources for reset Date: Thu, 13 Oct 2022 20:12:17 +0200 Message-Id: <20221013181221.3247429-3-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013181221.3247429-1-jernej.skrabec@gmail.com> References: <20221013181221.3247429-1-jernej.skrabec@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221013_111255_315191_249C2469 X-CRM114-Status: GOOD ( 11.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org We have to reset masters for all faults - permissions, L1 fault or L2 fault. Currently it's done only for permissions. If other type of fault happens, master is in locked up state. Fix that by really considering all fault sources. Fixes: 4100b8c229b3 ("iommu: Add Allwinner H6 IOMMU driver") Signed-off-by: Jernej Skrabec --- drivers/iommu/sun50i-iommu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/sun50i-iommu.c b/drivers/iommu/sun50i-iommu.c index c777882d0ec2..38d1069cf383 100644 --- a/drivers/iommu/sun50i-iommu.c +++ b/drivers/iommu/sun50i-iommu.c @@ -869,8 +869,8 @@ static phys_addr_t sun50i_iommu_handle_perm_irq(struct sun50i_iommu *iommu) static irqreturn_t sun50i_iommu_irq(int irq, void *dev_id) { + u32 status, l1_status, l2_status, resets; struct sun50i_iommu *iommu = dev_id; - u32 status; spin_lock(&iommu->iommu_lock); @@ -880,6 +880,9 @@ static irqreturn_t sun50i_iommu_irq(int irq, void *dev_id) return IRQ_NONE; } + l1_status = iommu_read(iommu, IOMMU_L1PG_INT_REG); + l2_status = iommu_read(iommu, IOMMU_L2PG_INT_REG); + if (status & IOMMU_INT_INVALID_L2PG) sun50i_iommu_handle_pt_irq(iommu, IOMMU_INT_ERR_ADDR_L2_REG, @@ -893,7 +896,8 @@ static irqreturn_t sun50i_iommu_irq(int irq, void *dev_id) iommu_write(iommu, IOMMU_INT_CLR_REG, status); - iommu_write(iommu, IOMMU_RESET_REG, ~status); + resets = (status | l1_status | l2_status) & IOMMU_INT_MASTER_MASK; + iommu_write(iommu, IOMMU_RESET_REG, ~resets); iommu_write(iommu, IOMMU_RESET_REG, IOMMU_RESET_RELEASE_ALL); spin_unlock(&iommu->iommu_lock); From patchwork Thu Oct 13 18:12:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 13006273 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A9483C4332F for ; Thu, 13 Oct 2022 18:14:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5SMjaPZgNDpaGfkrKuXBxEFiqWGmKy36FsgCzA1emy0=; b=0AbnF5sNHXPrSc ipKu7Rn3gKS1TuAuBTdaWcWtH6LqCehZG8KofX4jW+/xVwZx2KKn4+qt9vM90cL4uxoW2qRDktzx5 vlKDTCFHj0tW4Bsx9NrnM7Ei8xCiZyLSZqn3njg3SNh5+xnMkMmB7qr1Qie86xUhCXKKIz6Zyb3t9 IpSozvayNLwoDGhEIi01dpQ7PNpdXxMkCsbpF+IM8qymCooE5Wb7LbwAZtE0LW0f7sMSKuggj5YCo VeZtNUwDp/7kSU7+kerohP6/bW+SN7tvCYEPHzRGEwSVBva20+MjjLIdJJ37kIk9DLNw2IcvqQAkh /BARc1vQyoM2IU01wzIg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oj2i4-00CdSl-Mz; Thu, 13 Oct 2022 18:13:32 +0000 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oj2hT-00CdF6-7A for linux-arm-kernel@lists.infradead.org; Thu, 13 Oct 2022 18:12:57 +0000 Received: by mail-ed1-x52c.google.com with SMTP id r14so3756079edc.7 for ; Thu, 13 Oct 2022 11:12:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t5o4hmrTo+a4A6KCBunzs3GYyFuyFvq3xuPa8kZR43M=; b=DU//SwH+JfMDyVMKNcHeLU136bnf9QlAcBT+KWFVH1q8TwC873dRzVkVcKr2u+9nNy s4WnYSjekVglH1Dqi8Q5bz1KKUstGlkGyZICaJIhtnSxPx9i4eWPCG4iyWXTFMOu80Yj JuXKwqbN5s/MaQedvEbm5oL0MF5SwXqsOSAYwgO+wM1nu4MxZk5JEX47YxnmZKq5HFWM iOQKeimAZfXCEBU0wVC/OmlYE4XV5R7pbnkFQFzZelR3uIldMiOvA3dP4qKmlcR5MWv6 vPAd8nW9lYSA7dr6TxoqTJEsvKy18NpG7B3jvYfTGmiaad+Tq72HVbY90tsQmCyC0nEC p6rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t5o4hmrTo+a4A6KCBunzs3GYyFuyFvq3xuPa8kZR43M=; b=tdK0OheJUR5sCFPMGlOJP3F8RVxafBSXYiFmS7eGXL9Z1MYQY2EFIFfmvQtrO0i/ZV fZXYjDe/C3T/G7Dgm3rfyR2JTIsxrjBegbc+ctWv3h2Pm1VZjFuiFbfp7ZoEKMso/ZjD /FEz8pArsEtpoUtx5hz6aZg1TOsrleXodc8ISXGozI2Z0jE7K/EYGwUFCKvqqjBaN0Yp H7zYVaYdUlJDzDo6CU6kNiFbXF5r01JA5yqgdPvwu1JZk/0cP3kzYmy6cEW46o4Yvnwm Bj1RLaXZsPtGHic3mX3499AFzM85+jCSQsclSln+CWCAYEdq/d2hHoRzHnNW5a4iXG1J K+Jg== X-Gm-Message-State: ACrzQf374Pl/0B58TxfHVH9KA2LoCB4gZIk35RBoYxBtlQelNs6N3DyD PwlmmDwTw+i6lsHNlr8YYbk= X-Google-Smtp-Source: AMsMyM779LnzMOJRUaV+d5Mya+59vT9EDrXNtlqV4dqAf2i/G2SCcwlVYTXuJQeHdR3GU8JloRYY6Q== X-Received: by 2002:a05:6402:350d:b0:45c:f5a2:348e with SMTP id b13-20020a056402350d00b0045cf5a2348emr895071edd.398.1665684768460; Thu, 13 Oct 2022 11:12:48 -0700 (PDT) Received: from kista.localdomain (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id ku15-20020a170907788f00b0078b551d2fa3sm211109ejc.103.2022.10.13.11.12.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Oct 2022 11:12:47 -0700 (PDT) From: Jernej Skrabec To: maxime@cerno.tech, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, wens@csie.org, samuel@sholland.org Cc: iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Jernej Skrabec Subject: [PATCH 3/5] iommu/sun50i: Fix R/W permission check Date: Thu, 13 Oct 2022 20:12:18 +0200 Message-Id: <20221013181221.3247429-4-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013181221.3247429-1-jernej.skrabec@gmail.com> References: <20221013181221.3247429-1-jernej.skrabec@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221013_111255_310782_46C30554 X-CRM114-Status: GOOD ( 13.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Because driver has enum type permissions and iommu subsystem has bitmap type, we have to be careful how check for combined read and write permissions is done. In such case, we have to mask both permissions and check that both are set at the same time. Current code just masks both flags but doesn't check that both are set. In short, it always sets R/W permission, regardles if requested permissions were RO, WO or RW. Fix that. Fixes: 4100b8c229b3 ("iommu: Add Allwinner H6 IOMMU driver") Signed-off-by: Jernej Skrabec --- drivers/iommu/sun50i-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/sun50i-iommu.c b/drivers/iommu/sun50i-iommu.c index 38d1069cf383..135df6934a9e 100644 --- a/drivers/iommu/sun50i-iommu.c +++ b/drivers/iommu/sun50i-iommu.c @@ -271,7 +271,7 @@ static u32 sun50i_mk_pte(phys_addr_t page, int prot) enum sun50i_iommu_aci aci; u32 flags = 0; - if (prot & (IOMMU_READ | IOMMU_WRITE)) + if ((prot & (IOMMU_READ | IOMMU_WRITE)) == (IOMMU_READ | IOMMU_WRITE)) aci = SUN50I_IOMMU_ACI_RD_WR; else if (prot & IOMMU_READ) aci = SUN50I_IOMMU_ACI_RD; From patchwork Thu Oct 13 18:12:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 13006270 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3584EC4332F for ; Thu, 13 Oct 2022 18:14:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+NTwGIlQgaYqQPIEMF/h8J/r/5rygMiW174A8g8XeFQ=; b=NYfyqeSI0U0A5+ sWkHYnklegszqSvUe7PDv3RFFvQ45juwARbQyP4eCkJY3FJ2TwdK3r/cH1IbI3q5tLL/ocn1T825F ULipNZRK2xSQbObawxsMNXfqTan24/W7jCtpmZI3qQYcKu2rUyDVM7AMIJalUBvG6bG5Ho0mvzImr HCClkCz6sfhWz61sSTTwQniD4Zcvdgpsd8gzSAHPqbiv3kEUyh6Rlet2hJw1YqLeFmPgTtQiXxl1E IWPsGBvPjRpvxT1o/hwfWao2asNyN3cQ9oOiQqI0I9zvmPwA9az7bENfNZf9hAXAvN3sOC7Ktti2k 7q6zn9vOmhRltYae0vbA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oj2hf-00CdMo-8s; Thu, 13 Oct 2022 18:13:07 +0000 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oj2hT-00CdF7-78 for linux-arm-kernel@lists.infradead.org; Thu, 13 Oct 2022 18:12:56 +0000 Received: by mail-ej1-x633.google.com with SMTP id sc25so5615145ejc.12 for ; Thu, 13 Oct 2022 11:12:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DEldd9wQdL+BNIpPagsN4syvK2Vu5z+yJRpIhSRKQMc=; b=qzluUBhJwWMerMPUe1gwWm6V5osUfex8TSHWUCaPokvqy+9fQRlP7jpgo9iflEUD6g clMX3iYM7P+JkEBVsDGWP/fJycFBwJwEj5F7/evQJKj89Q9Uq+rtrU5D8kLD3Ptz9o8W QGPC6LRUw4nVWr7SnJBkCg1O3NStZ/Bsmo/XcHOMkIUJNkLEjKN/2cGlflJjwhEtjDLG aVUbu9K3c9BXOsCY1+KOE1S1+NeKycL2yjfht2mOAaOSQDvmGRyMZH7+rF77Glo/k7LB ip6ygGlGS3didO4QLZtugOcfuvhQsFAyIWPR+8jGmCITGDyYQ9DxS+TGWikBtW/zo4qc DzjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DEldd9wQdL+BNIpPagsN4syvK2Vu5z+yJRpIhSRKQMc=; b=AI4An6ig8YANuvoEV5H9CEvDMyuX5LgODCmQhS4avCTDNvOS5xpwWweGUkr3KLP0ij AcDsqoACo4c9C1IKK3c2gncaYodWpqHvLe6G0FbFwprPwUxIjv+g7341+EU6a65n/5DC tKWiNa8767EjCBqIAFE7B7XSORvqj8fpdZlge2qn0YMmvHPuLKsmgw0+hYE6L3LxtWh+ l71NLkD86R5XDk+Cy4BvjlXLKzYb5qYjfS/18YtG6MI/IS08mHgoTbE4/NoceGDKhPs5 wV7cIdR8IS8rbz/vePsKTK5GkvuVRqHNPQumo6j+mr4pqdW1xi4O+jkriS7tHk8ksQGP CRPw== X-Gm-Message-State: ACrzQf2OTuhZgzpe1FWu80CAhlmsZUpEGIA05+j9PSKVjnPSYWij04mK K3+jS04OL8Hx8fhGtLJphgQ= X-Google-Smtp-Source: AMsMyM4KGX8o0jIoAtj6ooSj5qXqHN5XuDxpnQzzmUfbe78ND/6Vh84BPIfk+ap5UfNfS6dxEyMQNA== X-Received: by 2002:a17:907:3d91:b0:78d:f675:5659 with SMTP id he17-20020a1709073d9100b0078df6755659mr766140ejc.92.1665684769534; Thu, 13 Oct 2022 11:12:49 -0700 (PDT) Received: from kista.localdomain (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id ku15-20020a170907788f00b0078b551d2fa3sm211109ejc.103.2022.10.13.11.12.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Oct 2022 11:12:49 -0700 (PDT) From: Jernej Skrabec To: maxime@cerno.tech, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, wens@csie.org, samuel@sholland.org Cc: iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Jernej Skrabec Subject: [PATCH 4/5] iommu/sun50i: Fix flush size Date: Thu, 13 Oct 2022 20:12:19 +0200 Message-Id: <20221013181221.3247429-5-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013181221.3247429-1-jernej.skrabec@gmail.com> References: <20221013181221.3247429-1-jernej.skrabec@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221013_111255_298702_E70F365D X-CRM114-Status: GOOD ( 10.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Function sun50i_table_flush() takes number of entries as an argument, not number of bytes. Fix that mistake in sun50i_dte_get_page_table(). Fixes: 4100b8c229b3 ("iommu: Add Allwinner H6 IOMMU driver") Signed-off-by: Jernej Skrabec --- drivers/iommu/sun50i-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/sun50i-iommu.c b/drivers/iommu/sun50i-iommu.c index 135df6934a9e..7c3b2ac552da 100644 --- a/drivers/iommu/sun50i-iommu.c +++ b/drivers/iommu/sun50i-iommu.c @@ -512,7 +512,7 @@ static u32 *sun50i_dte_get_page_table(struct sun50i_iommu_domain *sun50i_domain, sun50i_iommu_free_page_table(iommu, drop_pt); } - sun50i_table_flush(sun50i_domain, page_table, PT_SIZE); + sun50i_table_flush(sun50i_domain, page_table, NUM_PT_ENTRIES); sun50i_table_flush(sun50i_domain, dte_addr, 1); return page_table; From patchwork Thu Oct 13 18:12:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 13006274 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 288E4C433FE for ; Thu, 13 Oct 2022 18:14:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hvOTing112068Qwmw5Of4Xet7EJP/f6t9Oe+R37ECPA=; b=KgUalrpF294pD1 XVTVcnpmNldMEnCZdB3IOaKiFkDUzsFZEuplhBGoGwDNN/H6snDrqvLBN5HrxjzSfhNO2EZ/iPVfm 4zeXmUdGhRAGZjrp8uN4jKU7ZoDhSRi7+NNqxG4dkKQuHQfID9uHQVpN9GAlvb5qhCXa0lC53pJ74 d0vKl6G7zAgc1LQOsv2e1ZNq9PPAZLecpfujdWZUkKsuAZbEBHosAUqlogD8cSf55TlPkAoJGbJoM L8S0DsJ53XeMi4ZJrMwgLgjZK6Qf2RkwG/YnqBOYC7aDsnfUYi2zk44OEzRUlkrSEobbQOpeD1pZ8 4wgPzgL8WYMbfHOOJGCw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oj2iE-00CdWX-MS; Thu, 13 Oct 2022 18:13:42 +0000 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oj2hT-00CdFf-9I for linux-arm-kernel@lists.infradead.org; Thu, 13 Oct 2022 18:12:58 +0000 Received: by mail-ed1-x52b.google.com with SMTP id b12so3757295edd.6 for ; Thu, 13 Oct 2022 11:12:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JZtnjkPggA5SjkwbihxQWAD96AH19hj8hGJnqIV/2as=; b=h/9B8PjhRL0AdEzegsu1cN+YgPWzL8Yt8OtB9q1nNDhqtQ9BxH7ACySjVV/VeBVhsK YEPbewQmKHs4dq4cGsFmL1U83j8NROHxO5ExqKlrc0mBdk5uNoQOogiwnXYdFWZXGn6c VQi1BLth7T8fVggZGGh+vH4wQaH8B0d/qIZt/+yGzuhR+W3Vms4FimKOwuByoVAtmLoi WcCXELLiL+pB/sgBkYIYeROPfjjLJLAv/mucTGxPWSek5Xn25URUgyr0sCkeFkN3Xoyf M7gh6EM9INVsfa2wZbUPd/44s6y6wfRp4U1R5/9tuin5dtIrxDiuSioG+I8OaTONeVJM BTCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JZtnjkPggA5SjkwbihxQWAD96AH19hj8hGJnqIV/2as=; b=hUYyPVf12vR9TJ76iJ7NzI36uXz/h57FdqhsbBg0etfS/kTZaVv+Kofa2KyxE4GN3A l/Znfc7zTIqCbjE5ecsJqVHBtfauQ8M/izqxPr1gz838AWrNyY25WSf46m+rDVA6+t+m YHJTGOV6xB0YH1p3BEXoE8qhXLTwwBrvGvfX/h20YNIKGMwgSUHgXJt3njugeDJItIzj 8kaIpD1b/Kd3LZBo5/hk7C6MXz8gMeMc+TF5+83p4ntBUiwgI6C1AaJ/O1vcsk6+gYCT 6XGKPtXJyTBKy1mA4COXxbZtzHLiTaPEZPxVr1Gp5EOUz9yw3PVS35/Sgfn4yFXfysSY NC4Q== X-Gm-Message-State: ACrzQf2m7g33Tj4Lm+OZPybEHowvGi3tjKsl/Ai8YXIZdX/2neRuUdMk YE0HhP+Zwc2IxlMckRdDBQ4= X-Google-Smtp-Source: AMsMyM4nF065eBM9sudXyKpRFJ4LcfEKfLKhmQ5xJQh+63T0xHhPiB6dBG8cwR7SmZC8OKOCNNlJIA== X-Received: by 2002:a05:6402:254f:b0:45a:1799:d8fc with SMTP id l15-20020a056402254f00b0045a1799d8fcmr859345edb.237.1665684771705; Thu, 13 Oct 2022 11:12:51 -0700 (PDT) Received: from kista.localdomain (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id ku15-20020a170907788f00b0078b551d2fa3sm211109ejc.103.2022.10.13.11.12.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Oct 2022 11:12:51 -0700 (PDT) From: Jernej Skrabec To: maxime@cerno.tech, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, wens@csie.org, samuel@sholland.org Cc: iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Jernej Skrabec Subject: [PATCH 5/5] iommu/sun50i: Invalidate iova in map and unmap callback Date: Thu, 13 Oct 2022 20:12:21 +0200 Message-Id: <20221013181221.3247429-7-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013181221.3247429-1-jernej.skrabec@gmail.com> References: <20221013181221.3247429-1-jernej.skrabec@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221013_111255_377699_994F7E44 X-CRM114-Status: GOOD ( 10.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Mapped and unmapped iova addresses needs to be invalidated immediately or otherwise they might or might not work when used by master or CPU. This was discovered when running video decoder conformity test with Cedrus. Some videos were now and then decoded incorrectly and generated page faults. Fixes: 4100b8c229b3 ("iommu: Add Allwinner H6 IOMMU driver") Signed-off-by: Jernej Skrabec --- drivers/iommu/sun50i-iommu.c | 51 ++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/drivers/iommu/sun50i-iommu.c b/drivers/iommu/sun50i-iommu.c index 7c3b2ac552da..21e47ce6946a 100644 --- a/drivers/iommu/sun50i-iommu.c +++ b/drivers/iommu/sun50i-iommu.c @@ -518,6 +518,53 @@ static u32 *sun50i_dte_get_page_table(struct sun50i_iommu_domain *sun50i_domain, return page_table; } +static void sun50i_iommu_zap_iova(struct sun50i_iommu *iommu, unsigned long iova) +{ + unsigned long flags; + u32 reg; + int ret; + + spin_lock_irqsave(&iommu->iommu_lock, flags); + + iommu_write(iommu, IOMMU_AUTO_GATING_REG, 0); + + iommu_write(iommu, IOMMU_TLB_IVLD_ADDR_REG, iova); + iommu_write(iommu, IOMMU_TLB_IVLD_ADDR_MASK_REG, GENMASK(11, 0)); + iommu_write(iommu, IOMMU_TLB_IVLD_ENABLE_REG, IOMMU_TLB_IVLD_ENABLE_ENABLE); + + ret = readl_poll_timeout_atomic(iommu->base + IOMMU_TLB_IVLD_ENABLE_REG, + reg, !reg, 1, 2000); + if (ret) + dev_warn(iommu->dev, "TLB invalidation timed out!\n"); + + iommu_write(iommu, IOMMU_AUTO_GATING_REG, IOMMU_AUTO_GATING_ENABLE); + + spin_unlock_irqrestore(&iommu->iommu_lock, flags); +} + +static void sun50i_iommu_zap_ptw_cache(struct sun50i_iommu *iommu, unsigned long iova) +{ + unsigned long flags; + u32 reg; + int ret; + + spin_lock_irqsave(&iommu->iommu_lock, flags); + + iommu_write(iommu, IOMMU_AUTO_GATING_REG, 0); + + iommu_write(iommu, IOMMU_PC_IVLD_ADDR_REG, iova); + iommu_write(iommu, IOMMU_PC_IVLD_ENABLE_REG, IOMMU_PC_IVLD_ENABLE_ENABLE); + + ret = readl_poll_timeout_atomic(iommu->base + IOMMU_PC_IVLD_ENABLE_REG, + reg, !reg, 1, 2000); + if (ret) + dev_warn(iommu->dev, "PTW cache invalidation timed out!\n"); + + iommu_write(iommu, IOMMU_AUTO_GATING_REG, IOMMU_AUTO_GATING_ENABLE); + + spin_unlock_irqrestore(&iommu->iommu_lock, flags); +} + static int sun50i_iommu_map(struct iommu_domain *domain, unsigned long iova, phys_addr_t paddr, size_t size, int prot, gfp_t gfp) { @@ -546,6 +593,8 @@ static int sun50i_iommu_map(struct iommu_domain *domain, unsigned long iova, *pte_addr = sun50i_mk_pte(paddr, prot); sun50i_table_flush(sun50i_domain, pte_addr, 1); + sun50i_iommu_zap_iova(iommu, iova); + sun50i_iommu_zap_ptw_cache(iommu, iova); out: return ret; @@ -571,6 +620,8 @@ static size_t sun50i_iommu_unmap(struct iommu_domain *domain, unsigned long iova memset(pte_addr, 0, sizeof(*pte_addr)); sun50i_table_flush(sun50i_domain, pte_addr, 1); + sun50i_iommu_zap_iova(sun50i_domain->iommu, iova); + sun50i_iommu_zap_ptw_cache(sun50i_domain->iommu, iova); return SZ_4K; }