From patchwork Tue Jun 6 12:07:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Shavit X-Patchwork-Id: 13269061 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 161EAC77B7A for ; Tue, 6 Jun 2023 12:11:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=itz/HEtdE90toX6nOsnTfTTcWg83Y74TTyTwILuM1Qk=; b=Qnc2PzeH46Yd0DOxYs3bVlufot i6724xruecXrVu+Ah3rUIukn+aFuADTsWVZTmTj+4vUhRcnWf4IyNpjSR0Bzhj0c6aSql20qK/8oh hh85bUdB0IfmZC8zriQ9GbalLa6v/0dJaTOV+eJ8X+LhYoCiBynxNsYsJSu/HZ8uJAR4HUy18IlIZ IgE/Lslj1i6fkQBfeWiNMUiDr+oQjX61jr2YEUPCntcehF6ttZ/3UxLDndGFfTLDQLW5/ThcEq4by N8DL/6BcNF2TOId1pFveLhJ2rLgfV19aggNxcSx9EZqMjJrkhOxCjJRQy/C2HbhT9ImiZmzm4zKf+ 6/wy8Upg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6VWa-001ZXJ-1r; Tue, 06 Jun 2023 12:10:56 +0000 Received: from mail-pj1-x104a.google.com ([2607:f8b0:4864:20::104a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6VWX-001ZSi-1p for linux-arm-kernel@lists.infradead.org; Tue, 06 Jun 2023 12:10:54 +0000 Received: by mail-pj1-x104a.google.com with SMTP id 98e67ed59e1d1-256647a6fadso2017423a91.3 for ; Tue, 06 Jun 2023 05:10:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686053451; x=1688645451; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=C0PSyQeXC7Iz/P3YpxIMlG3+vOjTAssvVZqtnA/BFhw=; b=2YvtQkhtruPyaU6tyIiOFVtpwOKVajkps/SV+rmgxl5WcQGFxK06oATnOVAhefKsb/ /+tX6arfJ/Za9QYTa80Ei6E11onSKYS7FIz7iInWoRFPOWEY5aPsmfcRL0zuObD3kAq0 teU/b922dsyZ//kQGYgXVvkHMSBnz3ieADNsR8xmAE0B3/N50Bl+vA1z7orEKcxD09Na bdbw4y7eF6C+HCfUimAIszfp3GX30HXWkqD/lwSejlJbb9AM/4g8brT1EpgR9qNhnEbM IypWkQ/P7yNKwLZhGySBmvzzhXMm7ZZFnsb2tJniozWmxdNQhN6ba8XMv52XGQjbrdS9 De3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686053451; x=1688645451; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=C0PSyQeXC7Iz/P3YpxIMlG3+vOjTAssvVZqtnA/BFhw=; b=QHoQUJK4an+kLjZsSEZ/mboBR2P124y8uVXEbdet2fvUgk3+zexd/SFjmYU9ccFGuC wVe0/2VmtbRef5E9gPNtLcIQ34xkQANPNun9BO1ym5ouwTeSABmiDfwIVgyzNz58LTpo KUy8eJndhvhdZSmesV9cv3VUlo75ZLSIPwC0xqqMnWe+WFPqugxlwj1ebbCTimP3GTBJ vWOfWcstuWqAXw/BehDuAxtmfZxKS2BmZ5fyKN2egKmsf1el0o4lUMDnW1g+B5dJtoXx VE/StxFiXUXlF/cmNB2HB/usunhJIN0NNo9PaJ9mt3m/stduENZaA4AQ0GFuyfjmNgNE fyNg== X-Gm-Message-State: AC+VfDwg9g+r34EDa1UoRZSCgFHGGWqPI2e+WBa60zS6UYz8tnTVo6Qp geD7o0Lk8V+mn48BpFgOKGaPQO2Z/a+Z X-Google-Smtp-Source: ACHHUZ4x7W0FDltSlEvI3muVSMQ0fdaK5g12vYIpYYXAKI4ob4o42ABzQjjOpYbLtirWzKE/HT0Jn0tZ7kY+ X-Received: from mshavit.ntc.corp.google.com ([2401:fa00:95:20c:a615:63d5:b54e:6919]) (user=mshavit job=sendgmr) by 2002:a17:902:d483:b0:1ae:485e:d192 with SMTP id c3-20020a170902d48300b001ae485ed192mr629661plg.8.1686053451002; Tue, 06 Jun 2023 05:10:51 -0700 (PDT) Date: Tue, 6 Jun 2023 20:07:49 +0800 In-Reply-To: <20230606120854.4170244-1-mshavit@google.com> Mime-Version: 1.0 References: <20230606120854.4170244-1-mshavit@google.com> X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog Message-ID: <20230606120854.4170244-14-mshavit@google.com> Subject: [PATCH v2 13/18] iommu/arm-smmu-v3-sva: Add check when enabling sva From: Michael Shavit To: Will Deacon , Robin Murphy , Joerg Roedel Cc: Michael Shavit , jean-philippe@linaro.org, nicolinc@nvidia.com, jgg@nvidia.com, baolu.lu@linux.intel.com, linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230606_051053_622052_AFE01E1A X-CRM114-Status: GOOD ( 10.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org SVA domains can only be attached when the master's STEs have a stage 1 domain. Signed-off-by: Michael Shavit --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c index b615a85e6a54e..e2a91f20f0906 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c @@ -499,9 +499,15 @@ int arm_smmu_master_enable_sva(struct arm_smmu_master *master) int ret; mutex_lock(&sva_lock); + + if (!master->s1_cfg) { + ret = -EBUSY; + goto unlock; + } ret = arm_smmu_master_sva_enable_iopf(master); if (!ret) master->sva_enabled = true; +unlock: mutex_unlock(&sva_lock); return ret;