From patchwork Mon May 13 23:13:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13663712 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 93662C25B79 for ; Mon, 13 May 2024 23:14:34 +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: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:In-Reply-To:References: List-Owner; bh=XGSgDjO+1ZNOZBuE8Ho9AUzb/OExmcWGJAUdyj3VZBk=; b=yqR/EVGJqe/eAC 22Ca5u5TJTkX5hwfRV73CWcQ4v4+kla4k35xM0fNIz0TNsLYCKMXfL9JRHQ4ZwSune/kaW8KS+p96 YvCOsp2XeDs2Mh5owMXrccVXZhCq4lRskVyN+x3lFdiDY7z/ibvd/PhpkjzOCPANrHNwXHlYFOW2O +dLNiLE5Ab299T8xF1jf8HUv2ykJc7jQkPK/wOx6w/dZS1orbJmQ+vRPh3DOockxvwQUofAv7un95 G3dpufcu6QHrMf3G2FYquIGgcZ2uyclUG4zZnpkjvqC0VCBVBTmnQt65g66OkH8sVXsPyAJxCiDWG KrAJiGayNHtBMuWI0j8Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s6esB-0000000ETkO-3i0p; Mon, 13 May 2024 23:14:23 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s6es5-0000000ETiq-0epL for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2024 23:14:21 +0000 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1edc696df2bso42875655ad.0 for ; Mon, 13 May 2024 16:14:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1715642054; x=1716246854; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=/UTWRBSAvd0X00gI81fMU/F+YZQ/Mige07NOxJW4aqM=; b=jFSi5i0JuWHXUykw7yvKpMsuINhpVstJVn5U1L3F2cZVGbFjorNt31FThB86yOXe9J 59wDZUgV6RGqolrnCQuIYtrOzc8KY37DblbmbK3Kc22gA0WZDYZgKVeMrbDjvZ+O+PNO m+2Q9BOpTloaF7hbkIPkhC5sKxmIXaRmGBz84= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715642054; x=1716246854; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/UTWRBSAvd0X00gI81fMU/F+YZQ/Mige07NOxJW4aqM=; b=i50LWmVWiRWkanyqj62sCnlf+rA1QdbVaMSi1L3Nip5scWs9gqBKvOf03vrVhTFsuN mVrCT/Oi5KwWM/t8StK9HFa7sec/FtAYJW0KjXR68R66lUjieGidVkd1mZOMxM/Q0bg/ VMxlnovNutb0g4MolTewJTZBYrTRkZcC3EyHL+c+KAgaaUVuNjXXeI9QGnEGPKjPNd/0 bKEEYKCqxV7EvVjWVn0Q7TFi8uHJEhxGb/rNe33t6Fn1WJVviUReJcpICx6xTSomViWZ NGCSzwfzn8iFrK1Jfc2yHivZXLdXgtJVNEkvMjPGTFQkdh/Idb9wTHz4fRlaFP0YWiOB iSVw== X-Forwarded-Encrypted: i=1; AJvYcCWjlJ6K3kRUZ1vermxtjqA6m2p+0q6HK2WIawpYTu8lFC0DNrqLj3OA4eVwYh3LQZqcoSjnXW3pjNvrt4pNIxLOs6XXd1/P5Nwcr1z3o+lL22W617g= X-Gm-Message-State: AOJu0Yx26cWF6y9kZkdfTMgKv7ze7+ztTQBDMd5SosSG0GKCpQ1qJ5QV jqWssh2LldHYhY65AwYADK8Oa8QtY4tV9Z9Zu+bppNoWmty+zSn3vz+7a5rH9w== X-Google-Smtp-Source: AGHT+IF8+sauERaqDzjL2bI/eirzDn0nfnNAe5M0xI+wO+jJKg/7dcYov0Rv8fpzNykL4ic967Yyvw== X-Received: by 2002:a17:903:1207:b0:1e7:b6f4:2d75 with SMTP id d9443c01a7336-1ef43d16e9amr162929375ad.6.1715642054153; Mon, 13 May 2024 16:14:14 -0700 (PDT) Received: from dianders.sjc.corp.google.com ([2620:15c:9d:2:1165:227d:25c3:aee6]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0c160c63sm84391945ad.282.2024.05.13.16.14.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 16:14:13 -0700 (PDT) From: Douglas Anderson To: Will Deacon , Robin Murphy , Joerg Roedel Cc: Stephen Boyd , Douglas Anderson , Chen Lin , iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] iommu/arm-smmu: Don't disable next-page prefetcher on devices it works on Date: Mon, 13 May 2024 16:13:47 -0700 Message-ID: <20240513161343.1.I5db5530070a1335e6cc3c55e056c2a84b1031308@changeid> X-Mailer: git-send-email 2.45.0.rc1.225.g2a3ae87e7f-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240513_161417_247728_FD2500F4 X-CRM114-Status: GOOD ( 20.63 ) 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 On sc7180 trogdor devices we get a scary warning at bootup: arm-smmu 15000000.iommu: Failed to disable prefetcher [errata #841119 and #826419], check ACR.CACHE_LOCK We spent some time trying to figure out how we were going to fix these errata and whether we needed to do a firmware update. Upon closer inspection, however, we realized that the errata don't apply to us. Specifically, the errata document says that for these errata: * Found in: r0p0 * Fixed in: r2p2 ...and trogdor devices appear to be running r2p4. That means that they are unaffected despite the scary warning. The issue is that the kernel unconditionally tries to disable the prefetcher even on unaffected devices and then warns when it's unable to. Let's change the kernel to only disable the prefetcher on affected devices, which will get rid of the scary warning on devices that are unaffected. As per the comment the prefetcher is "not-particularly-beneficial" but it shouldn't hurt to leave it on for devices where it doesn't cause problems. Fixes: f87f6e5b4539 ("iommu/arm-smmu: Warn once when the perfetcher errata patch fails to apply") Signed-off-by: Douglas Anderson --- drivers/iommu/arm/arm-smmu/arm-smmu-impl.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-impl.c b/drivers/iommu/arm/arm-smmu/arm-smmu-impl.c index 9dc772f2cbb2..d9b38b0db0d4 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu-impl.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-impl.c @@ -109,7 +109,7 @@ static struct arm_smmu_device *cavium_smmu_impl_init(struct arm_smmu_device *smm int arm_mmu500_reset(struct arm_smmu_device *smmu) { - u32 reg, major; + u32 reg, major, minor; int i; /* * On MMU-500 r2p0 onwards we need to clear ACR.CACHE_LOCK before @@ -118,6 +118,7 @@ int arm_mmu500_reset(struct arm_smmu_device *smmu) */ reg = arm_smmu_gr0_read(smmu, ARM_SMMU_GR0_ID7); major = FIELD_GET(ARM_SMMU_ID7_MAJOR, reg); + minor = FIELD_GET(ARM_SMMU_ID7_MINOR, reg); reg = arm_smmu_gr0_read(smmu, ARM_SMMU_GR0_sACR); if (major >= 2) reg &= ~ARM_MMU500_ACR_CACHE_LOCK; @@ -131,14 +132,18 @@ int arm_mmu500_reset(struct arm_smmu_device *smmu) /* * Disable MMU-500's not-particularly-beneficial next-page * prefetcher for the sake of errata #841119 and #826419. + * These errata only affect r0p0 through r2p1 (fixed in r2p2). */ - for (i = 0; i < smmu->num_context_banks; ++i) { - reg = arm_smmu_cb_read(smmu, i, ARM_SMMU_CB_ACTLR); - reg &= ~ARM_MMU500_ACTLR_CPRE; - arm_smmu_cb_write(smmu, i, ARM_SMMU_CB_ACTLR, reg); - reg = arm_smmu_cb_read(smmu, i, ARM_SMMU_CB_ACTLR); - if (reg & ARM_MMU500_ACTLR_CPRE) - dev_warn_once(smmu->dev, "Failed to disable prefetcher [errata #841119 and #826419], check ACR.CACHE_LOCK\n"); + if (major < 2 || (major == 2 && minor < 2)) { + for (i = 0; i < smmu->num_context_banks; ++i) { + reg = arm_smmu_cb_read(smmu, i, ARM_SMMU_CB_ACTLR); + reg &= ~ARM_MMU500_ACTLR_CPRE; + arm_smmu_cb_write(smmu, i, ARM_SMMU_CB_ACTLR, reg); + reg = arm_smmu_cb_read(smmu, i, ARM_SMMU_CB_ACTLR); + if (reg & ARM_MMU500_ACTLR_CPRE) + dev_warn_once(smmu->dev, + "Failed to disable prefetcher [errata #841119 and #826419], check ACR.CACHE_LOCK\n"); + } } return 0;