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);