From patchwork Wed Jun 21 06:37:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Shavit X-Patchwork-Id: 110850 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4198066vqr; Wed, 21 Jun 2023 01:06:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6EqJCQTWLZMpkI8kXJHAU0+LkClgs3AoL+nXDz0ZnlyrcEcVR6/R5AaJjorU9d1P4fZ4cr X-Received: by 2002:a05:6a00:2303:b0:668:8c3c:313e with SMTP id h3-20020a056a00230300b006688c3c313emr6119753pfh.22.1687334793799; Wed, 21 Jun 2023 01:06:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687334793; cv=none; d=google.com; s=arc-20160816; b=Y/kA300dRD0h0L+mtDaDt+kGyksvwWsZLAGaYRpNNtsWed0r6u/N7A9FOwfr+dynkc psXOzBhxh0de1P8Q4enyHY/40GmobMc3C9lvVwPIOjyUP2OdDwSCA5+rEEY6tH02BmiX zabuz1yAYkhukMrOHPUOPWak+OkOAu7HBhhKul8bCh+rh9g278Ui/TyqCgeoB4OYI6OL HksrzozNxyAGph7ThM5vO7uYRR6WN3xmQ0717s6E5/w2F7PncbUpCeefsawsECY9XrwS jKdycgs0+/CA2LB7dic/LS+DQ8xCY5zQvBGq2AYmvkIFzebvLDA7s/MTu/WiHVEffMsi WiAQ== 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=GFfBSOUvUPqFSx6n4vEtFQq3Hc8Ha+kDvCzi3+3mgos=; b=osNwrW/Efp0XBLfuw+KwB2ck9Di1AO7wVh3l/tiJO0pBj9uQBq7yTeIye8vFIKci5V nSS31wzKFApVPiTs09qsLPY1puUk1Ia1AZHSEhOoSN6iQHlajcawXLBQNCA6Uf3ZvHG5 AiuygmepbPt9lRYdvo9wAT5Cs0U0f6v0gL1RmilYz+j71jzmXcwlFIqc1K4L9WtGCRMH LkjB5LU9IDvDlxBnr0YmIcsbxkBQIFQ9MS8blcp04bw56rB0Q+g/sd5KeLbw3NUeQlqU m4GwQyZJfpsOk2G1VXmi78TjC+62DAp4HyufbtD4thri2putfayb2ARLkJMAukIHYfL/ q6Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=t4HhyrUZ; 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 e28-20020a056a0000dc00b00659af029c39si3454761pfj.90.2023.06.21.01.06.20; Wed, 21 Jun 2023 01:06:33 -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=t4HhyrUZ; 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 S231165AbjFUGrB (ORCPT + 99 others); Wed, 21 Jun 2023 02:47:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230170AbjFUGqT (ORCPT ); Wed, 21 Jun 2023 02:46:19 -0400 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DE631FC4 for ; Tue, 20 Jun 2023 23:45:02 -0700 (PDT) Received: by mail-pj1-x1049.google.com with SMTP id 98e67ed59e1d1-25e89d51bf2so2581661a91.0 for ; Tue, 20 Jun 2023 23:45:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687329902; x=1689921902; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=GFfBSOUvUPqFSx6n4vEtFQq3Hc8Ha+kDvCzi3+3mgos=; b=t4HhyrUZx343POQssx8xWB3bNqEwvVz5axTthBdUwUeHP98YwM0/jOGBkI8RNJ6CfV q813TeRnvgUNnvQ5yy+drxSkGdqSae/ZdfJL2CLBJbfVgemKrHUzyxNImNn9WE4R5pN1 QgALlayI2ddPtiW6CPlWgIpz9CmCsE/e1EJarXWy6qGQnc+hIy5agSCGPnJEUO2/Lcx0 w31wnEnCEJrXmNRkg29aSfwTjpHDwxP6w/ngMobxEgWSJDGOmFnCq3Hf+OQierGh/m/V vjKc3DIyPkMR9sdzlVpuqyKBLwgRtHl253JAEGraYWPxylZDrHFJArJHYf6fcfRkfMfq s4QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687329902; x=1689921902; 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=GFfBSOUvUPqFSx6n4vEtFQq3Hc8Ha+kDvCzi3+3mgos=; b=GCKtJzarPQ3nonHalz0+J0b9efmwtlITGzAt09JU1Ja4BmKwmM/Lcp4uaR7vPIhr2N e7k9YOrYY2Tdpu8k7ICM4X35APA+BUrCP6CKgxHxTJAHG4qWcSHQrIdy8WQKnqKqQmg4 TUoCLvGNNJTlniK/9KqXNTAgFozaR1L+zazEwswGq9f58g4GGr6U35Z5XxshsGTdzyMH akh2NmdnnyJaNmM25M6E9eLiI4QjUgP7OE6ypAxmNkodg8aTk99Kbt3V/2EVUbfKD9Rd b5nCsS02k56VZ3K79ynJhbiWnnXjV8FcW5sLIpD4PRYY2A30853rYUn2cIBUnkDGReS5 pwfQ== X-Gm-Message-State: AC+VfDwAr2r3LDkDU/dvcl+GmPHNtFbzcSpO6xebca/HobIPsO8uf8Gq R/xQ8juK0SKheN9LTuOMkNtR84lHZSMq X-Received: from mshavit.ntc.corp.google.com ([2401:fa00:95:20c:384f:f7da:c61d:5a3e]) (user=mshavit job=sendgmr) by 2002:a17:90a:fa06:b0:25b:d689:72a4 with SMTP id cm6-20020a17090afa0600b0025bd68972a4mr1992026pjb.4.1687329901714; Tue, 20 Jun 2023 23:45:01 -0700 (PDT) Date: Wed, 21 Jun 2023 14:37:25 +0800 In-Reply-To: <20230621063825.268890-1-mshavit@google.com> Mime-Version: 1.0 References: <20230621063825.268890-1-mshavit@google.com> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Message-ID: <20230621063825.268890-14-mshavit@google.com> Subject: [PATCH v4 13/13] 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?1769298768901258983?= X-GMAIL-MSGID: =?utf-8?q?1769298768901258983?= 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;