From patchwork Thu Dec 19 16:30:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 182140 Delivered-To: patch@linaro.org Received: by 2002:a92:d0a:0:0:0:0:0 with SMTP id 10csp702476iln; Thu, 19 Dec 2019 08:31:34 -0800 (PST) X-Google-Smtp-Source: APXvYqyxNpt1fqUUSyfnLHOz0CSmUrb+9fy9fYhb052FYXYsZJPNYFIi7Y7jPSJJdABRp2rb8Zd6 X-Received: by 2002:a9d:754a:: with SMTP id b10mr9737698otl.273.1576773094906; Thu, 19 Dec 2019 08:31:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576773094; cv=none; d=google.com; s=arc-20160816; b=RoNClveHbZpWhKTiVR/B9+taUPGMpvfPn0YoGZCeCXdqWUXZHXXM79Bo6VS+wwIMQh 8lyX1kzG/jp1pt+iPwzMoZv9jQ9fnIDY29XmAJ6QCd0QAiw72V8dGjAh9C3xB2UcFqCr p/pzKC99ls0kOQgAeM15ZWfvOIDGu4dQe6UfQ2MNXIy1wbQy3x6FS3n7mttqyd3yO1Yl MTfLVd/1+CcvQ1fVYN6WWH1mA/0sV2j8rw9a6jaHtCiIu9CZhwN5Um6wJY2rgmhIN8QJ YcJkIeHg9OauoeGJFNHo+Owq/q9x2XO4NrWNaOvEhgdZAr6sZCzWjJMLCjiDsoQ8B3tq bXAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0nQT4ayYi2icUCghAPJFv/Sszvlp8khOsvgAay7NA80=; b=QQxazRHKf+JIUxDtW1YtOUd5mrejH+oeTMGWdZDVefansaH4bKRnWXPs/Q/YXR//7J Wqm0Mw+EqFB7bzIrJG9ltfyMkKA0XEqmpKe/+AORJPHjvbJjydk72kaM9Mi2R8r30rAJ RZWGNzeYtNAENaDrtoGkOfdhmxfwbP6DchedxuUeEIsBEb+rreQWPcwLRVM+BIGEcLRS ciNL26AF9H7mczAUPTUfYDPlyJTs35a5gHE1EAipa/F2HgyyG5Bt0QiVNgZGQSR4adMu caEEuzLoVLmRbIOcflDQDQ4jx1tP7u3scef5kSI1mMraN4gbH0QVIEOrBgrEM5cwTCkT TBNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=npHKtHQy; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n25si2200080oij.175.2019.12.19.08.31.34; Thu, 19 Dec 2019 08:31:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=npHKtHQy; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726971AbfLSQbd (ORCPT + 8 others); Thu, 19 Dec 2019 11:31:33 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:43190 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726982AbfLSQbc (ORCPT ); Thu, 19 Dec 2019 11:31:32 -0500 Received: by mail-wr1-f66.google.com with SMTP id d16so6592799wre.10 for ; Thu, 19 Dec 2019 08:31:31 -0800 (PST) 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=0nQT4ayYi2icUCghAPJFv/Sszvlp8khOsvgAay7NA80=; b=npHKtHQyMJP1HB7cti1f6qmoeI+DJKFn7XvDJJvdFOvDZnGuyq626gmPPg1VW/g+vf NqHOB4YW3LtpAFxkZLtWK59MIggQeBHMnf2FU4aoFn2biHVyVWj0iduHkMNtN+Cw2QKl 3GzgzVR/AU8hNb4bXoVdj3ptMWKCW30ACKJ3zUu58boNWddLRmDvOzJlIlY5xbZoskN5 NreU0QK4KXWGIqcGeZD3D1pGnvnWQRzTZfOi+0GHu41hGDI1yGc6L4u2Cpc68atX6ZYW BASd0KfcX6CjN1z5HsyiO9BpOuElbJpjkF8aVQmcH6L1OGUKS7nE3VlxwSQerqKeYRZZ jh5g== 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=0nQT4ayYi2icUCghAPJFv/Sszvlp8khOsvgAay7NA80=; b=lAFNSlAi4GEDAwzTniKUJgf1nvwCFnjSPjEbJAWfp9DnaT8nqVnpbgwayceR81jn/l /SwKlzw/LNMOZ4u+VXMEJ+wW26ENtX5BeApVv5RW95sXHKy5HhBcwnA4uIFH1v/9+bSf ZNO+vrRhPsjWoqxcv1wlvQQHc8mmfGvPoZ3u/WPTZOfglR/KITfFf1Ft02sBPokCmGhP mvbIqLHza4Z3n0oaCEdC3ZKYrfvdtQS9x+GQ6Q0gI80etJLD7r/mJcMtk0KqgIvtcKsC KpVGNXO/NzKpsOmnNsk9RC0s6PMTfRPlamtwwNnimPbhLEjUOpW9rT1/EmSZCiqwGU3C c2PA== X-Gm-Message-State: APjAAAW3v2HROY3EdS/APJNoPAa9b9pwCZDvqEoAwkzLv6QQ7fm7Hw64 bAivrSqFPeJLrwpHTh3rAQCaKA== X-Received: by 2002:a5d:53d1:: with SMTP id a17mr10010531wrw.327.1576773090913; Thu, 19 Dec 2019 08:31:30 -0800 (PST) Received: from localhost.localdomain (adsl-84-227-176-239.adslplus.ch. [84.227.176.239]) by smtp.gmail.com with ESMTPSA id u22sm7092068wru.30.2019.12.19.08.31.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 08:31:30 -0800 (PST) From: Jean-Philippe Brucker To: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, devicetree@vger.kernel.org, iommu@lists.linux-foundation.org Cc: joro@8bytes.org, robh+dt@kernel.org, mark.rutland@arm.com, lorenzo.pieralisi@arm.com, guohanjun@huawei.com, sudeep.holla@arm.com, rjw@rjwysocki.net, lenb@kernel.org, will@kernel.org, robin.murphy@arm.com, bhelgaas@google.com, eric.auger@redhat.com, jonathan.cameron@huawei.com, zhangfei.gao@linaro.org Subject: [PATCH v4 09/13] iommu/arm-smmu-v3: Prepare for handling arm_smmu_write_ctx_desc() failure Date: Thu, 19 Dec 2019 17:30:29 +0100 Message-Id: <20191219163033.2608177-10-jean-philippe@linaro.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191219163033.2608177-1-jean-philippe@linaro.org> References: <20191219163033.2608177-1-jean-philippe@linaro.org> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Second-level context descriptor tables will be allocated lazily in arm_smmu_write_ctx_desc(). Help with handling allocation failure by moving the CD write into arm_smmu_domain_finalise_s1(). Reviewed-by: Eric Auger Reviewed-by: Jonathan Cameron Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/arm-smmu-v3.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) -- 2.24.1 diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index e147087198ef..b825a5639afc 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -2301,8 +2301,15 @@ static int arm_smmu_domain_finalise_s1(struct arm_smmu_domain *smmu_domain, cfg->cd.ttbr = pgtbl_cfg->arm_lpae_s1_cfg.ttbr[0]; cfg->cd.tcr = pgtbl_cfg->arm_lpae_s1_cfg.tcr; cfg->cd.mair = pgtbl_cfg->arm_lpae_s1_cfg.mair; + + ret = arm_smmu_write_ctx_desc(smmu_domain, 0, &cfg->cd); + if (ret) + goto out_free_tables; + return 0; +out_free_tables: + arm_smmu_free_cd_tables(smmu_domain); out_free_asid: arm_smmu_bitmap_free(smmu->asid_map, asid); return ret; @@ -2569,10 +2576,6 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) if (smmu_domain->stage != ARM_SMMU_DOMAIN_BYPASS) master->ats_enabled = arm_smmu_ats_supported(master); - if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1) - arm_smmu_write_ctx_desc(smmu_domain, 0, - &smmu_domain->s1_cfg.cd); - arm_smmu_install_ste_for_dev(master); spin_lock_irqsave(&smmu_domain->devices_lock, flags);