From patchwork Mon Jul 31 10:48:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Shavit X-Patchwork-Id: 13334296 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 5CC39C001DE for ; Mon, 31 Jul 2023 10:49:50 +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=pcRa0YQLFEb7XkAAjZBJ/meJygFVLK3xQouXyekMkkc=; b=2hNjMaGtSDPtFPfOIK3UiZPmOu A3M/5yQ4aOgDvSXpvZLr0jmen7IAcQva32N4qEefQkUCjwOikIT3FBsw0AcS/UaNlgo5MhO9biJzg 71Mmldir7h/8EYNsbIzsa/NeF3C3MhkKWAU9bvbGxQykv/k/dMrdJioghH5mlIQ9oWePgR+bH8vLa TeZCGrklbKzpHxTOLvCXeePlyhFdwx0FrAQDsJkSMtWIJCQ1igZ0WfPyQQgduImvLtvq1rHek/Zsm trlz37PCoXGU+wn5qM1EgylzZQ5AdGcn/e1PqITxu6Xcn13aXGjgXFkzNwHPHfwrCBamPokovDSdP ZvmVr6vw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qQQSi-00F9P7-2a; Mon, 31 Jul 2023 10:49:16 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qQQSY-00F9Hd-07 for linux-arm-kernel@lists.infradead.org; Mon, 31 Jul 2023 10:49:07 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-585f254c41aso27937377b3.1 for ; Mon, 31 Jul 2023 03:49:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690800544; x=1691405344; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=TOLHkJaT+7H0fEwKCF1U6y0LUywm6xuO1oN6Y683ukY=; b=wpLAsENIWJ8wPIvQXtzKrwlZ6cmns5IxNkosywEnU8vIi2VRqkKXyg7IgNJLtU2yYM pA798G7cy5i8aGBzkQfk7TMF+3OzVxxf4KXgsLYfYtzN983zooa0XPtIvRQJBZPPTnzb gNIlPXfmoBL6gRtQAKXVw0vyIz3ZVrSzxEV47z7ZCPvWlAWJ43TH/sqJxrU60QmCutYJ unlLPnHUz52Mf7NRqdcrEWLGxS1xK9S1Bgic8ph8D7Kreo16nJyjyyR0MD+usfE8nmr6 S6sFMIovzFLeTmgEVZxrwwFn0cAC2vkGgj9Pkvtb6nNvjIpZU23gEXufrm8bnoRuB2Uz bMJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690800544; x=1691405344; 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=TOLHkJaT+7H0fEwKCF1U6y0LUywm6xuO1oN6Y683ukY=; b=ad9Fkuq1QdZvrQYlhUojxnnwaM8pKFWY8yJ2vnSA5O0seTqQyOOq01H0meDxEMYgMe ToMlWcjuZKrHOtcHm/8hgIeeFhbLotmqDpBjA0ysLarAj9vC/pTydyltZDRTLK55QsNX cpenrpD5559FIXR5FGaMyQ9qcE//DmKfaiJ6NDX1hQMTU2gixkLGy+fquG30xj6dsuUj rgjivBWrBffJJNuCkgXHYU90SL+ddGQxp3LM4Mq4qmzthONOVKD1qbzjgF2pEyJPPuAa SqdXsKwpd0QIHGle6cEtlerofyhG0B9421LCcc4xWwpS3Qlx83gHrVU0kf8paCxx+1o5 CKfQ== X-Gm-Message-State: ABy/qLYgwWoBor+VMbZv4eDxRXEDNrOT8RkDLAei5I4lfMKFuNfVsD6I uPoIV8GJJr1G7nW0SACwKAzv/uCMqzNh X-Google-Smtp-Source: APBJJlF6qpQSFj22+rJwXVfNU7jT8nG/y2QM0YsXib8x2omrgoE9ga/5alIh5ruNgPiD4/m0AgMZfZ9hXHhN X-Received: from mshavit.ntc.corp.google.com ([2401:fa00:95:20c:affc:ad1d:5cbb:3c6a]) (user=mshavit job=sendgmr) by 2002:a81:ec0f:0:b0:576:6e4e:b87f with SMTP id j15-20020a81ec0f000000b005766e4eb87fmr72197ywm.10.1690800544479; Mon, 31 Jul 2023 03:49:04 -0700 (PDT) Date: Mon, 31 Jul 2023 18:48:15 +0800 In-Reply-To: <20230731104833.800114-1-mshavit@google.com> Mime-Version: 1.0 References: <20230731104833.800114-1-mshavit@google.com> X-Mailer: git-send-email 2.41.0.585.gd2178a4bd4-goog Message-ID: <20230731184817.v2.5.Idedc0f496231e2faab3df057219c5e2d937bbfe4@changeid> Subject: [PATCH v2 5/8] iommu/arm-smmu-v3: Skip cd sync if CD table isn't active From: Michael Shavit To: iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: will@kernel.org, robin.murphy@arm.com, nicolinc@nvidia.com, jgg@nvidia.com, jean-philippe@linaro.org, Michael Shavit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230731_034906_073713_AF9B6D6E X-CRM114-Status: GOOD ( 15.82 ) 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 This commit explicitly keeps track of whether a CD table is installed in an STE so that arm_smmu_sync_cd can skip the sync when unnecessary. This was previously achieved through the domain->devices list, but we are moving to a model where arm_smmu_sync_cd directly operates on a master and the master's CD table instead of a domain. Signed-off-by: Michael Shavit Reviewed-by: Jason Gunthorpe --- Changes in v2: - Store field as a bit instead of a bool. Fix comment about STE being live before the sync in write_ctx_desc(). drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 6 +++++- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) 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 654acf6002bf3..4f7fe19d88fda 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -987,6 +987,9 @@ static void arm_smmu_sync_cd(struct arm_smmu_domain *smmu_domain, }, }; + if (!smmu_domain->cd_table.installed) + return; + cmds.num = 0; spin_lock_irqsave(&smmu_domain->devices_lock, flags); @@ -1098,7 +1101,7 @@ int arm_smmu_write_ctx_desc(struct arm_smmu_domain *smmu_domain, int ssid, cdptr[3] = cpu_to_le64(cd->mair); /* - * STE is live, and the SMMU might read dwords of this CD in any + * STE may be live, and the SMMU might read dwords of this CD in any * order. Ensure that it observes valid values before reading * V=1. */ @@ -1368,6 +1371,7 @@ static void arm_smmu_write_strtab_ent(struct arm_smmu_master *master, u32 sid, cd_table->l1_desc ? STRTAB_STE_0_S1FMT_64K_L2 : STRTAB_STE_0_S1FMT_LINEAR); + cd_table->installed = true; } if (s2_cfg) { 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 05b1f0ee60808..3a56987a5fd0b 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h @@ -599,6 +599,8 @@ struct arm_smmu_ctx_desc_cfg { u8 max_cds_bits; /* Whether CD entries in this table have the stall bit set. */ u8 stall_enabled:1; + /* Whether this CD table is installed in any STE */ + u8 installed:1; }; struct arm_smmu_s2_cfg {