From patchwork Mon Oct 19 18:23:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 11844915 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A03CAC433E7 for ; Mon, 19 Oct 2020 18:24:26 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3DB922231B for ; Mon, 19 Oct 2020 18:24:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="n2VmClsQ"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="bFyiA3Ag" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3DB922231B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=qs4BvcmdgaRwPiULPU3Ed1YgMbFbdu9RDGUb8IZPJtU=; b=n2VmClsQrhwOBIQ2b5ej4ZaxA AdjiLldOCGqn519YkwtWztgYl17o0H+OStbBT/bOScdP9vS3bAYUiJPeQwgnRV2mzcrf20Geip+hn QkeKC4C00WTZ6EQJTvBmk4j8ejrum+bXWGoukZcKQpBP2MSoJttuHUd9gBp7mPHFBWpMNrw+w4Wbx CKCShg26ynhT/XOvPTxrOw+w62ioa5/I5SCPWgJB8ne5QInwAx4u8Ww3M2W1Dh3jCPfwJagN6tpnC cD9UQCu5ks7X0oh6JweobDi68aMXgSJIO9vjTa+yY9xaMp1fLL9fvy2BQzgKhSTFoDgvLYNxV9sSp +X5GVrcxg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kUZo8-0001V0-Ia; Mon, 19 Oct 2020 18:22:56 +0000 Received: from mail-ot1-x344.google.com ([2607:f8b0:4864:20::344]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kUZnz-0001QC-IK for linux-arm-kernel@lists.infradead.org; Mon, 19 Oct 2020 18:22:48 +0000 Received: by mail-ot1-x344.google.com with SMTP id n11so573406ota.2 for ; Mon, 19 Oct 2020 11:22:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8WNcSTvyJjqPsluOX/aQHxo6wZkO11EjVoorR/ZeenI=; b=bFyiA3AgOGUPXSmlD9ln5iZpm2IIkGqCKw/60r0m/Cx4zD4T3E0nqY3ega31Z0G4VI HDUVN+RNPyfDT0q1cl1jJmiVwmTvX9jinwXYJYbBO3AndeqrWxw9dVVpqQzIYbBazf7H sFyncVWqYaHCD3gaVlMmsB9+whr4jlJXjuZGiOiz6r6vM7Capkd+ZH8KYvwXBixNTfkz snT5x1MjjB3Tqh6MJxwHwZXcrbpI/im+BZUPMW/HSglDnM1XQeQHpOfD//3cc8O2jngy gy+dOM9EIubZPx/PXHr2KXGetlHK0fHHNO46kQjJzJg3dJ32eb+R5nzuubOOtwvCFcYe 17Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8WNcSTvyJjqPsluOX/aQHxo6wZkO11EjVoorR/ZeenI=; b=O5GBO1zFB3zIoy7phpLFUxtfV7M2IBWxAHN7zsUaS/EtEEk7FlvARrGfrELR9LG4KU MXVu/hYDDstpi7bLvOGWbk0twaFeY98hkE4k9XcYjaz4JmxpmKArkz7RpBsVMs+5tJQZ S5HkgGQX1wgQWLcicki0EfINwh0I9WHDgyTS6OW1K4w8yliHQy7AatuNe4/yLU5RS9S4 nXSHHFWDyym+CBASkjhU/mkMlqbMumS7CQlOpYpU2EVwIJR3mNAQeEMbp/1OTQWDQj/4 u4b1vc0gXM6vsej1XjFb12zI7Qqme7ssOnRV2XHxwkif9nqj7+Aq/XjgVpCfhUrfAR3O pFXA== X-Gm-Message-State: AOAM532NlVHlFSGvgeKTEaMGP3TerPBNi833Jnlu6jpo4XEIQtG3bzKA 4o7PZ4t4jxmb8WpFAWO9KjEZRg== X-Google-Smtp-Source: ABdhPJzVeqVCQDNjLcs4loM+bM++jSYOB3qz5YDAugy+gXljNRXkI2CN8pviTsuIzrWxZhciQsuOTw== X-Received: by 2002:a05:6830:2368:: with SMTP id r8mr915212oth.75.1603131765704; Mon, 19 Oct 2020 11:22:45 -0700 (PDT) Received: from localhost.localdomain (104-57-184-186.lightspeed.austtx.sbcglobal.net. [104.57.184.186]) by smtp.gmail.com with ESMTPSA id o8sm175296oog.47.2020.10.19.11.22.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2020 11:22:45 -0700 (PDT) From: Bjorn Andersson To: Will Deacon , Robin Murphy , Joerg Roedel , Sai Prakash Ranjan , Jordan Crouse , Thierry Reding , Rob Clark Subject: [PATCH v5 1/3] iommu/arm-smmu: Allow implementation specific write_s2cr Date: Mon, 19 Oct 2020 11:23:21 -0700 Message-Id: <20201019182323.3162386-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201019182323.3162386-1-bjorn.andersson@linaro.org> References: <20201019182323.3162386-1-bjorn.andersson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201019_142247_688698_842FCB7F X-CRM114-Status: GOOD ( 18.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-msm@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. Reviewed-by: Robin Murphy Signed-off-by: Bjorn Andersson --- Changes since v4: - Return early instead of indenting the rest of the function 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(-) diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c index dad7fa86fbd4..bcbacf22331d 100644 --- 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 arm_smmu_device *smmu, int idx) 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) diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.h b/drivers/iommu/arm/arm-smmu/arm-smmu.h index 1a746476927c..b71647eaa319 100644 --- 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