Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9104562pxu; Mon, 28 Dec 2020 06:45:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJy4dzyMcENZQ5zj6hdZUYUyMUrLCexam9AXr1+1pvLbvMMMZxtWcmZcRvDxR/cFyjuNc4H1 X-Received: by 2002:a17:906:565a:: with SMTP id v26mr41209545ejr.332.1609166711885; Mon, 28 Dec 2020 06:45:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609166711; cv=none; d=google.com; s=arc-20160816; b=IUYhXGUsbqT1e1EZOVQydQBvZnco27I6vooCYCBKRQPrwrQfQDPfoiTmt9+gAEUSi7 dnXPIR+4S4Og+edvYg8SgYpkQ11/vL7+MJohQkEbfYS40O7YnRQsVRzdLucM9WJEQqT8 AkwwV9iAVew+MTv36WknMAtsdWWQxaIdV6SQFFQO6eaozLoJR0+bb0mJXA7gD1cajeNg zxXMt8bGCvPqQg5YBAQy0Gz7rfpglV3ddlMg5cV9C7IMq5CRsXYT323MFEpUfSQcESGy UhhOOnvZHKZL5Ay5pd647/bsWUJn9uF4yT0L5vIlB0P0cFX+xR1Pq3CsnmzjWzkWWWtV 7xOw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=z96GVIl9ooU2k4b1f+6DmBgUUpP/tH8FkhqLPtYVXM4=; b=WFwDlITCs4Kn16mjC92AFd6HPJ9I56LfU91tQyeJMW9kOhUMBEjnGRK9dUCNWSVy1C ko27i/aTQCtgDioTMmhPmtq7wrI+6B2Kaz+ipYZqbH/Ms32vDPqH4AchvHZILb1BuFXD duzh1cxGgw9ugPGWS1BveR7sQ/sEabZMbaYZJi5UvsZEw8ZzF/OyP3HGsglWcPnoWus0 VTEnuezyPfeIp1T9Xyyr3Y8d3azeCSEX7O7XeXvtdlKkUP02/+TWBghOGhAqVLB3UyS4 8mUzq/DaqrP3yjXRZwlvmLNCImDghFExuRN8YO4pLMcD5Iq6r9tbUiG3Ad8kbOIm6A/x xw+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XQGJFesu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m10si17800523eji.137.2020.12.28.06.44.48; Mon, 28 Dec 2020 06:45:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XQGJFesu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2506349AbgL1Omu (ORCPT + 99 others); Mon, 28 Dec 2020 09:42:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:35058 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502297AbgL1O12 (ORCPT ); Mon, 28 Dec 2020 09:27:28 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id BFCCE22B47; Mon, 28 Dec 2020 14:27:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165633; bh=SMCuzkho3iONEHA+ypwyjYM27vyyE6C+l++XRAgkjs8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XQGJFesucOBxMnJQpF+i0K3Yt9cZ2hFpwwIO7iVdENVZ5tpd+OMi0I0V7kiil0gdO p1LaqzGlEXc89n/CPXvHhcpX927l7TiJU3y70Pfb3Oex1XmqhnqfJrO8Ux+7wk/X4T RkM415hnWqWrRoI3X1yuR2OSEfaQpJSIcNe9+l28= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bjorn Andersson , Steev Klimaszewski , Robin Murphy , Will Deacon Subject: [PATCH 5.10 600/717] iommu/arm-smmu: Allow implementation specific write_s2cr Date: Mon, 28 Dec 2020 13:49:58 +0100 Message-Id: <20201228125049.652618236@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bjorn Andersson commit 56b75b51ed6d5e7bffda59440404409bca2dff00 upstream. The firmware found in some Qualcomm platforms intercepts writes to the S2CR register in order to replace the BYPASS type with FAULT. Further more it treats faults at this level as catastrophic and restarts the device. Add support for providing implementation specific versions of the S2CR write function, to allow the Qualcomm driver to work around this behavior. Cc: Signed-off-by: Bjorn Andersson Tested-by: Steev Klimaszewski Reviewed-by: Robin Murphy Link: https://lore.kernel.org/r/20201019182323.3162386-2-bjorn.andersson@linaro.org Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman --- drivers/iommu/arm/arm-smmu/arm-smmu.c | 13 ++++++++++--- drivers/iommu/arm/arm-smmu/arm-smmu.h | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c @@ -929,9 +929,16 @@ static void arm_smmu_write_smr(struct ar static void arm_smmu_write_s2cr(struct arm_smmu_device *smmu, int idx) { struct arm_smmu_s2cr *s2cr = smmu->s2crs + idx; - u32 reg = FIELD_PREP(ARM_SMMU_S2CR_TYPE, s2cr->type) | - FIELD_PREP(ARM_SMMU_S2CR_CBNDX, s2cr->cbndx) | - FIELD_PREP(ARM_SMMU_S2CR_PRIVCFG, s2cr->privcfg); + u32 reg; + + if (smmu->impl && smmu->impl->write_s2cr) { + smmu->impl->write_s2cr(smmu, idx); + return; + } + + reg = FIELD_PREP(ARM_SMMU_S2CR_TYPE, s2cr->type) | + FIELD_PREP(ARM_SMMU_S2CR_CBNDX, s2cr->cbndx) | + FIELD_PREP(ARM_SMMU_S2CR_PRIVCFG, s2cr->privcfg); if (smmu->features & ARM_SMMU_FEAT_EXIDS && smmu->smrs && smmu->smrs[idx].valid) --- a/drivers/iommu/arm/arm-smmu/arm-smmu.h +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.h @@ -436,6 +436,7 @@ struct arm_smmu_impl { int (*alloc_context_bank)(struct arm_smmu_domain *smmu_domain, struct arm_smmu_device *smmu, struct device *dev, int start); + void (*write_s2cr)(struct arm_smmu_device *smmu, int idx); }; #define INVALID_SMENDX -1