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: 103760 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3347917vqr; Tue, 6 Jun 2023 05:15:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ768zBbaBtLXrbm/OVyN1WkG5FVnchF0COf+2+qxkpCOROiwUNJV9ltK7/2F73wzloAMJfK X-Received: by 2002:a17:90a:bd8d:b0:256:dd38:6563 with SMTP id z13-20020a17090abd8d00b00256dd386563mr496754pjr.45.1686053753970; Tue, 06 Jun 2023 05:15:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686053753; cv=none; d=google.com; s=arc-20160816; b=CYb78uR5u3hgvz1xGVu21bv+gTjFJf/tbZOWbAxBNXXbYGoA37RH07PYcHqdLMUE83 Q69k5meskc/CI3C8VB8PhCdZF2uOKpMzrkIgTCCXg2lnTL7MngZBmcL0A8lVOxFvtKEm TDYCscwUyMORPYvBExXTUfL6+yDzcA+McXVZjBP549tW0ugWcZSGh74Eh84JgtA/7CuZ LLGd0NId2+M+dSyZWsAJGiAec3X/hEWV4SL8y5oI3mvgN/MEx/IXh37wHTnS4Jhxb1FO WqnZzzOtNYmYxdZszh1DsC13f2Kmidf8G/4bc4I/3TwmdUQ0m0V5kydRy5GZll/xtokK JGnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=C0PSyQeXC7Iz/P3YpxIMlG3+vOjTAssvVZqtnA/BFhw=; b=FuRVBHmaZjDNK79et3knP+7dXxjt1hKXQSDUyA4C/XtHpyheLygGZHfBrzlHEoZLOE 7CazeLOAnzLrA4x5qhByxIgfSo92Th451hlvHCMm8+wo6KOAeg0g3jzppZM4Zv9tODk5 VDbMqlVc4lF5sNaFxzLlGMHzVR2bKnNlUxKo1Mefby4PDMB2ys5V8vYaj9R4Ijgs6m9i DNEPtU2eoj3ERo/zCkrtozqAIny7rs7MHpVA8Ao0R/+e75GBOapYiUmiJ4l3/3MM92KD u2zJXXzn5db2tEWFabcDSroDznM590yTm3s9LnaiQqXeNuOx9s9ghCGvByu09q2KKsAh O55Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=2YvtQkht; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gb13-20020a17090b060d00b0025677f1197asi8944238pjb.12.2023.06.06.05.15.41; Tue, 06 Jun 2023 05:15:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=2YvtQkht; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237487AbjFFMLW (ORCPT + 99 others); Tue, 6 Jun 2023 08:11:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237479AbjFFMLT (ORCPT ); Tue, 6 Jun 2023 08:11:19 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A94D010E2 for ; Tue, 6 Jun 2023 05:10:51 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id d9443c01a7336-1b0371a51cfso21043365ad.0 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=eYIaFcQQL0RmDGhZxBlrnqAsiL+eUVfRTFMt4MhC8qSxaRpJYsAgApM9q5s9TQhMRp WrzcVmsQfNj04Vwr6ZYmtKZKwWYHukf/NJbSOMOQkja0GcPvjMDyrKUnTXMyz75f5d/u vTIBP6nkbITta04hjtxt7eTlZxfLTHvnkefK1XqUwmK+06l9nhWs6ZuB7TFEupojsi9G uJE73hx0GHgTQI0LebVUf1S2sqU8otBDLzvOF0NrT/T1aS0+G4dOeNaXDT5C4MgMcwus K16ocnOUy8DZG4iT1FOcATgmLVo8DL+iORl5BgTZ/0b8WE9o9WkxfvbnoBbwoRqQ7XWy frCw== X-Gm-Message-State: AC+VfDw+1yyjmV0UIMu+Iw/sP3mZGrR6t2CE3bKOIkO31KVsgR0PstuV gBMdhfIMnc/Cg5i7rKmdRRs3dKar0IzB 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-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767955501287040671?= X-GMAIL-MSGID: =?utf-8?q?1767955501287040671?= 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;