From patchwork Thu Aug 17 16:03:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Shavit X-Patchwork-Id: 13356767 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 ECAC7C3DA4E for ; Thu, 17 Aug 2023 16:05:26 +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: Mime-Version:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=3BzjXa2U5wMeXxWwTz2B2Z4Sy1u8qYDKGefu436dVgU=; b=dQa CJKIQM0XGlKIEWvXStRVhRNDuN49nmOTya7dqDi18kLGJayumw5DGHNjBYhmJakI3WiFgro6QbSw6 Xwo3QwhmSX4mkcRaWIayG7bAplOVKFBzXbiQ5ncT4afqCugPMpS8L0vm+Erp5FvbpEJ2en73BaTfg XVvo5JIdEVBK6i4W4zASVvm+VbIfA2YjYER+dOO+wo+puImOnlltTPkfwJui0FQZ5Av8c+61jQfws MAIHlkF69Qq2oLDvdIn/rhs1OZT8VaVoyXyKr59e9Cr9H1Yr1Pn6rYrinwz+yShxQ0j0lixPW61g4 ACULuC3dARRtF60Y4SGQkLtgFISSUbw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qWfUT-006kMH-2o; Thu, 17 Aug 2023 16:04:53 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qWfUR-006kLx-0X for linux-arm-kernel@lists.infradead.org; Thu, 17 Aug 2023 16:04:52 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-58419550c3aso82869577b3.0 for ; Thu, 17 Aug 2023 09:04:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1692288288; x=1692893088; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=nhmsuM5yHQfjgDqk/74LT3YBolDr49Ko8c7EPxuWM5Q=; b=fpTsJB9QT5AxLuechA/2AWtVlA5fkNgrOvdKvs6fU6vVZrpzY+0HwOk7iT4oEsqvvj igoEHneiHtSWmblo1kPXhQgIUExEQOKv+VoEB0qdMYR0yEgqXlHoW+Z0edU9LLQPBD6i UDexN08PcHJzpFu5gtNVaobxrvOvaqyMpn/aKtWnfg9/mnONaXIH5S5IEpzK2LGuhos7 dVRFwlCzsF5IJ0g9BBhyKSfA0Aoo/tblAqaby34DASj+JXCYQd2fHAVQfQkURcu/lPhP s+WQ70AoMHWt/3jnmWu2VlzsjJ8cBoqSG+Z81b3K4lYJsLnY5d6I9WKJkHwZTFP9Rgbc BfPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692288288; x=1692893088; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=nhmsuM5yHQfjgDqk/74LT3YBolDr49Ko8c7EPxuWM5Q=; b=ERIa/OGfjhmEOof6P2RI7vHkgoY9DsbmKThvdSxWcJe0l7sEcVnVI66kwBzOswk9UL CtC1JZEghPPXW2dlJz33cfoHhQRyhr1SmiNr0pe8qskzYaAJfjLwtPqlXzczAEeElbXt Lw6JI7Q7/6EH1MhOU4/Fm4tHTUmvKMs4g5HNHr1ntFvg2NeXKrGaCfyvdLt485ZbMBuh 5s+NmKW5pISj9/CSHRM7XGXNA+Li4N4xMPxnKmPPIu5eHLGEgmISjYVE1kNnODUhhM81 WqoWFWQbudq1690MnT8/uLbYqIKfN4HVerBXllfl5So6BHhswQqmtkEGXU179lUycVBj mc8A== X-Gm-Message-State: AOJu0YyOzGXnTxeztOnhVAD1g68mUF+XyEMoJWLxUMCqC29yMeZbinJT FSCcZcRx/OwEKJiyx6XYK9/Z63Fc67CJ X-Google-Smtp-Source: AGHT+IH/2ZEVO1MgS6IrCQGrdLUhLc7XCvX7bO1lPrLmBV6kXD7edJxFI23NCe5BR7m3R10h3YAQoKli5qWR X-Received: from mshavit.ntc.corp.google.com ([2401:fa00:95:20c:4a77:fd20:7069:bdf9]) (user=mshavit job=sendgmr) by 2002:a81:ad1a:0:b0:576:8cb6:62a9 with SMTP id l26-20020a81ad1a000000b005768cb662a9mr76288ywh.6.1692288288309; Thu, 17 Aug 2023 09:04:48 -0700 (PDT) Date: Fri, 18 Aug 2023 00:03:30 +0800 Mime-Version: 1.0 X-Mailer: git-send-email 2.41.0.694.ge786442a9b-goog Message-ID: <20230818000321.1.Ibca43cc8d1bcad3ac3deef5726b9745128aea634@changeid> Subject: [PATCH] iommu/arm-smmu-v3: Simplify stage selection logic From: Michael Shavit To: iommu@lists.linux.dev Cc: Michael Shavit , Jason Gunthorpe , Jean-Philippe Brucker , Joerg Roedel , Lu Baolu , Nicolin Chen , Robin Murphy , Tomas Krcka , Will Deacon , Yicong Yang , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230817_090451_222350_4798A52B X-CRM114-Status: GOOD ( 13.51 ) 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 It is invalid for an arm-smmu-v3 to have neither FEAT_TRANS_S1 nor FEAT_TRANS_S2 bits set, and this is even checked in the probe. Only set ARM_SMMU_DOMAIN_S2 if FEAT_TRANS_S1 isn't supported, otherwise set ARM_SMMU_DOMAIN_S1. This is clearer as the existing code implies that something more sophisticated is going on with the stage selection logic. Signed-off-by: Michael Shavit Reviewed-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) base-commit: 6eaae198076080886b9e7d57f4ae06fa782f90ef 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 9b0dc35056019..e74c8c630adfa 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2206,7 +2206,7 @@ static int arm_smmu_domain_finalise(struct iommu_domain *domain, /* Restrict the stage to what we can actually support */ if (!(smmu->features & ARM_SMMU_FEAT_TRANS_S1)) smmu_domain->stage = ARM_SMMU_DOMAIN_S2; - if (!(smmu->features & ARM_SMMU_FEAT_TRANS_S2)) + else smmu_domain->stage = ARM_SMMU_DOMAIN_S1; switch (smmu_domain->stage) {