From patchwork Wed Aug 2 17:09:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Easwar Hariharan X-Patchwork-Id: 130041 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp638188vqx; Wed, 2 Aug 2023 11:11:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlGrCHdwbL9xxvb89urhR0uXIOTdlT1xFrjagzzUnMOVJS6aq9YlaNp5btajczeAAwrh+A18 X-Received: by 2002:a17:90a:74cc:b0:268:3b8b:140d with SMTP id p12-20020a17090a74cc00b002683b8b140dmr12709280pjl.35.1690999862614; Wed, 02 Aug 2023 11:11:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690999862; cv=none; d=google.com; s=arc-20160816; b=CEmJby38RWZxwFL5wADo/60TS1fSWOGIUAjIp+qttEkYDL7GPyru3kjIwZpy8LvyGJ ya4lnzwqUMFV6xuiL5av5N2f2EM2C+sEjJ6dTlGZYuWkP7nF1jmISxBnGw+kk65QdiIW ykH6CBRuWiigmAK64cWJY4zgnKt1H8ZRv+QH9wgrdi/y9cN+GIYhnlV+K+xUNN5CUM+v D3NgdlXs0GH543ummfcTwNB/GvMLb2HNrongnv9qsa+oO0rk/p4/1bRyleHmMnicKVP3 sOtJy0RxkdFivpaYuZxS9eXF4j1eEOQEBVy5ZGzeZAd+Ew2jvjEThPAwvDevf0ZydRFP WOvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=oeSc+GkK/ZLJKOD7kmtbAT61HWgiUosa2UOiw2GfqGc=; fh=sVBj3If4geHpOL9+mdgG4VsvkwWZIMIjYhOYb3rVo1k=; b=DAhTn2+1rDeUBTqQuK1FAlpu9fyosLFVAuSZIDaqm7KG0FYtHomFXtNdRahZmqP7CN l+iWJYUm52lDhS5ujAxta9C04uovK+C4xk9n5Kggrm0KggCfPzUG75tJjq8dTla/r4oU jOZtavM/aadUk4B9hiWkoLT73YYpScPD0lyBH2G/Yt6+HDyPlqHmzJIOVJSWMZSDxYq3 gDHJVb4du4CFFGlW5ozHF77cB4gSdZPRoA2ALcDKrvjjNBdHHUlZe9PEOVKd8giZxyW/ k4bf3UTVUK9S16n1rteGJcdJktQ/cmQj7RtNizeTXD97Ehq1Dj/5z3E3c0k9NdUaSISf ovhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=kDbOYeQe; 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=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l6-20020a17090ab70600b00262ebe643a2si1427180pjr.186.2023.08.02.11.10.49; Wed, 02 Aug 2023 11:11:02 -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=@linux.microsoft.com header.s=default header.b=kDbOYeQe; 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=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232396AbjHBRJf (ORCPT + 99 others); Wed, 2 Aug 2023 13:09:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231483AbjHBRJZ (ORCPT ); Wed, 2 Aug 2023 13:09:25 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 926F61729; Wed, 2 Aug 2023 10:09:23 -0700 (PDT) Received: from rrs24-12-35.corp.microsoft.com (unknown [131.107.147.181]) by linux.microsoft.com (Postfix) with ESMTPSA id 10332238C44E; Wed, 2 Aug 2023 10:09:23 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 10332238C44E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1690996163; bh=oeSc+GkK/ZLJKOD7kmtbAT61HWgiUosa2UOiw2GfqGc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kDbOYeQez/oUFad4T7OjQw9wG5M0GWSyvD9Rz9HCoqbWgIvt8+i36yT48MISLyi6M ctAEzAzFH/zNMyj2MCJPU5x7vx0yGbilvQglujrrtn2IOzNimZiSaO1lIJYw1mF9Gg zk4fIRvdp2lQtl8i3bAcgN4ybGS/UEJNmm7jSbKw= From: Easwar Hariharan To: stable@vger.kernel.org Cc: easwar.hariharan@microsoft.com, Robin Murphy , Nicolin Chen , Will Deacon , Joerg Roedel , Sasha Levin , Yicong Yang , Tomas Krcka , linux-arm-kernel@lists.infradead.org (moderated list:ARM SMMU DRIVERS), iommu@lists.linux-foundation.org (open list:IOMMU DRIVERS), iommu@lists.linux.dev (open list:IOMMU DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 6.1 3/4] iommu/arm-smmu-v3: Add explicit feature for nesting Date: Wed, 2 Aug 2023 17:09:10 +0000 Message-Id: <20230802170911.1593275-4-eahariha@linux.microsoft.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230802170911.1593275-1-eahariha@linux.microsoft.com> References: <20230802170911.1593275-1-eahariha@linux.microsoft.com> MIME-Version: 1.0 X-Spam-Status: No, score=-19.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_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: INBOX X-GMAIL-THRID: 1773141871820628312 X-GMAIL-MSGID: 1773141871820628312 From: Robin Murphy commit 1d9777b9f3d55b4b6faf186ba4f1d6fb560c0523 upstream In certain cases we may want to refuse to allow nested translation even when both stages are implemented, so let's add an explicit feature for nesting support which we can control in its own right. For now this merely serves as documentation, but it means a nice convenient check will be ready and waiting for the future nesting code. Signed-off-by: Robin Murphy Reviewed-by: Nicolin Chen Link: https://lore.kernel.org/r/136c3f4a3a84cc14a5a1978ace57dfd3ed67b688.1683731256.git.robin.murphy@arm.com Signed-off-by: Will Deacon Signed-off-by: Easwar Hariharan --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 4 ++++ drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 1 + 2 files changed, 5 insertions(+) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c index 6a551a48d271..7cec4a457d91 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -3703,6 +3703,10 @@ static int arm_smmu_device_hw_probe(struct arm_smmu_device *smmu) smmu->ias = max(smmu->ias, smmu->oas); + if ((smmu->features & ARM_SMMU_FEAT_TRANS_S1) && + (smmu->features & ARM_SMMU_FEAT_TRANS_S2)) + smmu->features |= ARM_SMMU_FEAT_NESTING; + arm_smmu_device_iidr_probe(smmu); if (arm_smmu_sva_supported(smmu)) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h index abaecdf8d5d2..c594a9b46999 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h @@ -646,6 +646,7 @@ struct arm_smmu_device { #define ARM_SMMU_FEAT_BTM (1 << 16) #define ARM_SMMU_FEAT_SVA (1 << 17) #define ARM_SMMU_FEAT_E2H (1 << 18) +#define ARM_SMMU_FEAT_NESTING (1 << 19) u32 features; #define ARM_SMMU_OPT_SKIP_PREFETCH (1 << 0)