From patchwork Sat Sep 5 20:04:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 11759363 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AC4D313B1 for ; Sat, 5 Sep 2020 20:06:38 +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 757672073B for ; Sat, 5 Sep 2020 20:06:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="JB3x/DdQ"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Owm67BOy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 757672073B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.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=QIECCgESBuvbPegHYJg3Lchs8aEqFFUq+HZqoeLuTPY=; b=JB3x/DdQULjsVHzoq3e4WgiJW o2sX3n7FDyA45khNZYWKCRxIVl5nLB+tHa4/ga6FoinY6UFXee4T90exKt6dj4cnjNoDOfRE2c6Dy uMASPXrV4XMUVlubdWut9UHgmY5+J5O9Tx8M8c0FVZPMVUcrhRFOElEqQlm6xtSsGNa1IlG8k8vBZ 2rtJaTc+SHMGlQG572Nf/TvUf9IH+PKSOdKEpBHdcFafimqK45g2Sa4yOl61nOpxJijNM86eb62Or 8ROJPYxH7gs8Pi6bgOaho978NVTMZv0A3hcIrWO7ULy/8Dyy46g95+4iDrBral0bq5H23knUB0/ia 0Ge14x/TA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kEeR3-0007dm-5l; Sat, 05 Sep 2020 20:05:17 +0000 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kEeQv-0007aq-Nz for linux-arm-kernel@lists.infradead.org; Sat, 05 Sep 2020 20:05:10 +0000 Received: by mail-pj1-x1042.google.com with SMTP id o16so4757667pjr.2 for ; Sat, 05 Sep 2020 13:05:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DvFdTPchcbyWEX++eP+RtKIp66/AsHgH2aEoABwhrPw=; b=Owm67BOye7cLn9/FM8RhXNLMKAdbSblV5WEyMv7bJR8n9ma1DGn8BAfSLnoMQDMxMt EPDu/uwUkDOVTGgmEoieRU+cWIYSRwpP6G179J2U3AyXFcG4RCTV7Omxd2wkMnw2R+v+ fRwVl1GJL4pcAu5p6rbMdMtSy5hWFVfpMXB3Fi5mveMK8gC97pkmbrGKY/DZmIW3QNIx g445ia8irLz4OwfA70RY95WQn+fFk8xzYycE4n89onbedeNxEeQr88b+I+Cj/mOsx3yg hpA3R3zMSS120XHism4saTnqpyqyPLWgVOM3h/VOWflTvyH5NhYGduGtkTNrC9FD701Z gevw== 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=DvFdTPchcbyWEX++eP+RtKIp66/AsHgH2aEoABwhrPw=; b=nojZTOO+GKYDQjdn0lOfBMcXpity0tIm2nxLuOP1ZuSrJrgR4jXghbTyMxszHa/725 L3eYUcF3I/6EiK9MvkVpTLV72QIskid+S09BwXGnzrsiW/eiXopvJ8MFVIGplrxZY1F1 iKMhuab2WdZBSSEtNy444yeNCM3KMFvqnBPtvkI2EOgjT8rmZPLnGNrci+OkjVRtM67h 785hzlPCw1ZVVqJ0L8gynmtezeG4fXz6rKDyWgrqhD1lv2ysGmo5KXzZr627c50LAHeU 4v2VfTD1tCd8Hcg9uBPomVpMzLQfGXDCm0U+68JNk7sOpLL73hIFHWWKwuWwEuFlsJ05 8w1A== X-Gm-Message-State: AOAM531ghGea5HIO8cOWjM6YxswkXevgsviuIPKpLCw/1KHHaV2vJmgS iTiVL4DqqX5uJ1dufafvaqg= X-Google-Smtp-Source: ABdhPJxcnTtjrFZorqcAMTBoFnU7uOJs0ZXz5XW2NjfoAJXt07Zkspj2KF6vavtuzciDC2NujMM/Qw== X-Received: by 2002:a17:90a:8402:: with SMTP id j2mr13744447pjn.153.1599336307437; Sat, 05 Sep 2020 13:05:07 -0700 (PDT) Received: from localhost (c-73-25-156-94.hsd1.or.comcast.net. [73.25.156.94]) by smtp.gmail.com with ESMTPSA id 70sm10615253pfu.107.2020.09.05.13.05.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2020 13:05:06 -0700 (PDT) From: Rob Clark To: iommu@lists.linux-foundation.org, dri-devel@lists.freedesktop.org, Will Deacon , Robin Murphy , Joerg Roedel Subject: [PATCH v17 17/20] iommu/arm-smmu: Add a way for implementations to influence SCTLR Date: Sat, 5 Sep 2020 13:04:23 -0700 Message-Id: <20200905200454.240929-18-robdclark@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200905200454.240929-1-robdclark@gmail.com> References: <20200905200454.240929-1-robdclark@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200905_160509_830764_9466ACCA X-CRM114-Status: GOOD ( 15.91 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1042 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [robdclark[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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: Rob Clark , Sai Prakash Ranjan , Thierry Reding , open list , linux-arm-msm@vger.kernel.org, Akhil P Oommen , Stephen Boyd , Jordan Crouse , Sibi Sankar , Vivek Gautam , Greg Kroah-Hartman , Bjorn Andersson , freedreno@lists.freedesktop.org, "moderated list:ARM SMMU DRIVERS" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Rob Clark For the Adreno GPU's SMMU, we want SCTLR.HUPCF set to ensure that pending translations are not terminated on iova fault. Otherwise a terminated CP read could hang the GPU by returning invalid command-stream data. Signed-off-by: Rob Clark Reviewed-by: Bjorn Andersson --- drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 6 ++++++ drivers/iommu/arm/arm-smmu/arm-smmu.c | 3 +++ drivers/iommu/arm/arm-smmu/arm-smmu.h | 3 +++ 3 files changed, 12 insertions(+) diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c index 1e942eed2dfc..0663d7d26908 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c @@ -129,6 +129,12 @@ static int qcom_adreno_smmu_init_context(struct arm_smmu_domain *smmu_domain, (smmu_domain->cfg.fmt == ARM_SMMU_CTX_FMT_AARCH64)) pgtbl_cfg->quirks |= IO_PGTABLE_QUIRK_ARM_TTBR1; + /* + * On the GPU device we want to process subsequent transactions after a + * fault to keep the GPU from hanging + */ + smmu_domain->cfg.sctlr_set |= ARM_SMMU_SCTLR_HUPCF; + /* * Initialize private interface with GPU: */ diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c index dad7fa86fbd4..1f06ab219819 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c @@ -617,6 +617,9 @@ void arm_smmu_write_context_bank(struct arm_smmu_device *smmu, int idx) if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)) reg |= ARM_SMMU_SCTLR_E; + reg |= cfg->sctlr_set; + reg &= ~cfg->sctlr_clr; + arm_smmu_cb_write(smmu, idx, ARM_SMMU_CB_SCTLR, reg); } diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.h b/drivers/iommu/arm/arm-smmu/arm-smmu.h index 6c5ff9999eae..ddf2ca4c923d 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.h +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.h @@ -144,6 +144,7 @@ enum arm_smmu_cbar_type { #define ARM_SMMU_CB_SCTLR 0x0 #define ARM_SMMU_SCTLR_S1_ASIDPNE BIT(12) #define ARM_SMMU_SCTLR_CFCFG BIT(7) +#define ARM_SMMU_SCTLR_HUPCF BIT(8) #define ARM_SMMU_SCTLR_CFIE BIT(6) #define ARM_SMMU_SCTLR_CFRE BIT(5) #define ARM_SMMU_SCTLR_E BIT(4) @@ -341,6 +342,8 @@ struct arm_smmu_cfg { u16 asid; u16 vmid; }; + u32 sctlr_set; /* extra bits to set in SCTLR */ + u32 sctlr_clr; /* bits to mask in SCTLR */ enum arm_smmu_cbar_type cbar; enum arm_smmu_context_fmt fmt; };