From patchwork Mon Dec 28 12:49:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 352684 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp9798683jai; Mon, 28 Dec 2020 06:44:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJyRtBfiuGZznBtdUoTHyApt6EQtsrh4pkI24Sgq8AKhQvKEL5C+sec1YQQQWqLiVeQrsd9M X-Received: by 2002:a50:8b61:: with SMTP id l88mr43358921edl.250.1609166699793; Mon, 28 Dec 2020 06:44:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609166699; cv=none; d=google.com; s=arc-20160816; b=o0ZE6ENnIWoLac9Yv5cB+RiPU97/bsoWKA4Pl0TYgepb5GtLMvlxfX1HpwQE/o5ssE IfuZTHkaiEzx5SMYFmY/oPvY8RtiAHOwXNxPlmKdR+7m6L91gmlD6/rJpvbvYAMsGB6/ 4cKICDDpw82TF0gfjdAH4DVEQEpQGRiNanXxavZEWuk6AV0T7PhQlzBlBy4Mgq+GpAb1 hgNIvU5e00xeun54xrnnq5Z1DdIq8Hyj+88Dr6iEh0YLydZcZ/0T3W4TGvJeZdxaW+ac 6cbY5FzvrPVElOlqKaBo0xyACF4XljgDS9SXWEZ8vltUEy2L/FOt2s6/Ifk4u3UZFH+s 5Xtg== 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=v+yuob2uLydA2tHcWWzRrhfl3GB7XsOKLL30zsnSZCl4duncFf3s3R14HUA+0pqS5c iaS8Ule280c055XQzvcJ5nKesRUh9RlADWzFYgnoCOsisAtFvh7xSc/jFsmeztlJvqwm 9pafp9cGspoB6sKO2nJ9zO0lKbqXeTcB/m+8FbTCxmOCRQCWE3hH5VpID3HDo1iednR/ WIfVBp4oXNESYQPwYGbklpm9uIWDFfszZ4Fi4l4Uv0cEGUSAyY4Ta7YFcAdawpgZpApl vyMkKvawKdw33o3u3/UZ8ZSYmYd4j0DxH2cwF5QrxZjOfLNvpEp0yEcBm09uWvtPicBY Um2Q== 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 stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 ck15si19656600edb.37.2020.12.28.06.44.59; Mon, 28 Dec 2020 06:44:59 -0800 (PST) Received-SPF: pass (google.com: domain of stable-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 stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 S2506347AbgL1Omu (ORCPT + 14 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 Precedence: bulk List-ID: X-Mailing-List: stable@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