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: 2285 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp425285wrs; Thu, 13 Oct 2022 11:43:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM74ip/fJmm5jrt8jy7o21bvlGbibaCnL4NWyZc56tT5oLcCV21iE6L70ESGBlqJEzEhSx62 X-Received: by 2002:a17:90b:400f:b0:20a:9965:ef08 with SMTP id ie15-20020a17090b400f00b0020a9965ef08mr1271463pjb.155.1665686616952; Thu, 13 Oct 2022 11:43:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665686616; cv=none; d=google.com; s=arc-20160816; b=0F+bKf0pAq8VeF3mPoFGyoxyr9yehpcGrLVr0J8qKeFcaY8rf4HHLlqPNunvNUYrm+ +2QN/6EowH1eOFX9aua/5lxXVg/9uougs4u+1PavQ28rAi9MN/QdGvFIFyDRkuvdkmgq oJOQbCZ7+VoxMVK7jjhMib3fG/xYc3kOf+JFCOlwFYkuZ7Qgk+LddlGdzCMEnaLBhwg6 Cea99ZCJms6skSQsUx1lsuOxXrfZM2wmgbpT0XP5eTlTEiTlKH7JvKKrbjWvR8ChnqJo gYgTodHvQR84/et+skouaA32mUSUKIDu/Evbiw+IweGRLC8uL2AegYq/V+jgJEW4cZeV BPyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oow4Z/54Ywu9hc74bLjW+CtYs8QrvcOSZ9QuyKFYcEc=; b=qgFdhJ0eTZ+mp2jvkPchiJizwZzhQxmK8iEwNHGJbOxZHiQ2b9m4VzMLdLCWANGL5F dht8TLdAzPgCjXE/olprrkKNpViQ7mnGxZzOPOBftXklymqgvIBXuV2LMxGo1dfNLo4h H8trYvDLCKHdeSlx5pVv5kbLFBL+8RQxVppeTyGunc5TKZNSpSSaF/R65wHnwjQNLb7P wKvJ88bWWe41IVNTbGNayM2A9lkASfDxo0LJikopj58K731hFXKQ8SQzTWjvfDdwtMT+ 0zHkuY7mXlcbNz1Ug8LfcAleXeId8pB4K2EKTiBr54PPH8iod5GNCX8LVhUIoRAqKEMv +g3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ED9AlBSj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q12-20020a170902eb8c00b0017f61ac5a53si453617plg.111.2022.10.13.11.43.25; Thu, 13 Oct 2022 11:43:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ED9AlBSj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231929AbiJMSbk (ORCPT + 99 others); Thu, 13 Oct 2022 14:31:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231871AbiJMSbS (ORCPT ); Thu, 13 Oct 2022 14:31:18 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2A901793B0 for ; Thu, 13 Oct 2022 11:26:59 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id bj12so5675713ejb.13 for ; Thu, 13 Oct 2022 11:26:59 -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=f5TJjc+WBDwxq3ACzbaqxu0128WRVwpsOCQR1xcITr95hNT5qTk4no9FDyI/K5pB8f dqb1aFWo4/0zsCj2k3PG0riBejSIGUHzjxsLSwcaFPTXSTbLJaO+w/ZmwV6piTmcXCpx 6JUnQccaN4ebmjkBrnS09IUdFpBMBF3aIXlInreXC54kLuUAADq/LLGdkKd1uvilJK0z MsgIfBOBposElPEiXvJ+MR1fHIxAYw592PpOaNpKBQSP8K13KLvtg8L7i8lG0R6vLNZJ xLZfNZptjAHwTYOZSrF1oCHnNGgFzsDuXChpks9MocsEmJ+2/EYO10sJmJv1Cnemn2MT RfqA== X-Gm-Message-State: ACrzQf1Exbj6vU2UuPQvtfoQJu0CxpgcJ7/nCM1HCgjBoHyDjoiRF7Mk L3QwuImiji8BUayQkEHJmGYtR/fHJChUhX2k 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746599009795742590?= X-GMAIL-MSGID: =?utf-8?q?1746599009795742590?= 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);