From patchwork Wed Jun 14 15:42:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Shavit X-Patchwork-Id: 13280165 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 74FF8EB64D9 for ; Wed, 14 Jun 2023 15:45:31 +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=QJzQTWUf4ETAcNewICQ8BGhOx/bBRDxY3rhQivICJsA=; b=Uw4qvHlcsSh6tkhcGCbUg0rQ9A DNn0VoYKSQc9bOvVjz6MIPHRpuKb3tOJRie3kTR4HdDlpnsN5JzEb8JzFpgFJIvt5lsD8kI2Ma6yz 4cIhGf4kJBuDj9rPNT5Pi9bHWBnrs5n6tw6fmn241IsHXZF5hHoTzAecdPSfCOTEYTEggnj7VRLME lggnMtpLei/w0F0Ne757X9SY0kcacpezxPd0JihnbFPrOGkArXFzd0CnYEgoMJDIty0Ee88VP/a+A fDFOW8pxCuYyX8sYs7UnUxIRbfV4KpDvQ9LsSblTMufVny5LpSuceBkKJGniWbamMok9Wnn4a0VQm NLZdhzog==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q9SgM-00C6tO-2Y; Wed, 14 Jun 2023 15:45:14 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q9SgJ-00C6rT-1m for linux-arm-kernel@lists.infradead.org; Wed, 14 Jun 2023 15:45:12 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-bd5059e5347so1733308276.0 for ; Wed, 14 Jun 2023 08:45:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686757510; x=1689349510; 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=vp6Nlsbz0oC9g4ftIwLdhomK6sQnklY1ZxeEkHnIXfEXrOB32EsbD/Sxec0iRhhQHg FG7D8M3PpWeaM8iqTIew0USWOhnUT0FjBe9eXnTTSV/LhmO3ZmKELA9cij4LrrquyyEX xN4kZsa+CrEDpQ+9SCj337Iz/uwRx2q05yM0XfIncqMYOokbXzbVERwKppl5BO38z5eP hHmqL5KhrByMtgmNr4kVUihXIw6qeRCfAOy3kJEM2Xe0aOvPnzQXKdDIUXJE6sDAuRHp s5nPeYy80N984gbWZ3p5ANSaT8JevwNNBkebJ7ua9ynBAmNYrnU+pSstx30pek9GSY+/ b8wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686757510; x=1689349510; 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=KNpmspGyRMGfMM2C3eR9+55vphpcwRyWjXoOzCdIQ/ZqAMQ0rLUK+ZJg6mfSBVaWs2 lenhdDMfshjVxvN86EikKDM1XGc7i3hIrbz89alTh8+DvVw6+zaJ5K9wNowK3nkUjAXR DTFmQ4QAsTTDAomO6esWTO922f8LxOUyc1u7QqD/8PDVALqgDbXEjDBO3kT/Ob30sQTz EDQUuN4j2ZD4nhFqhDgiVb+O0V+y4fhl6uLMtdAglBpu5BDVkxMw9oE5p+UDBKTmGKHf ZY78aY+MSK48IvAevZhkqOq98sCdYQUM37wxrehrfM7UAFRb6HRKVXOntnZyQSLRwObE xDYg== X-Gm-Message-State: AC+VfDxdBCBwq12xs+s/8IdOxJTs6GiMjpEL66uIEUj6jDcVHsXaL+xF hh1eYdH/fZya1dO4qSErChTJ/t19ZKKw X-Google-Smtp-Source: ACHHUZ54OC1oThkrdI5m1JIqCvJD/OCLMDFClBfZ1oOPcGRnJCDeBJWfnhAFwtQXg3YtdduEf0o8Lo03wyNZ X-Received: from mshavit.ntc.corp.google.com ([2401:fa00:95:20c:c6e6:49bf:5c44:5965]) (user=mshavit job=sendgmr) by 2002:a05:6902:1185:b0:ba8:381b:f764 with SMTP id m5-20020a056902118500b00ba8381bf764mr888385ybu.3.1686757510234; Wed, 14 Jun 2023 08:45:10 -0700 (PDT) Date: Wed, 14 Jun 2023 23:42:05 +0800 In-Reply-To: <20230614154304.2860121-1-mshavit@google.com> Mime-Version: 1.0 References: <20230614154304.2860121-1-mshavit@google.com> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Message-ID: <20230614154304.2860121-14-mshavit@google.com> Subject: [PATCH v3 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230614_084511_596495_A3680F0E X-CRM114-Status: GOOD ( 10.32 ) 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;