Message ID | 20230727182647.4106140-1-mshavit@google.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a985:0:b0:3e4:2afc:c1 with SMTP id t5csp1295939vqo; Thu, 27 Jul 2023 11:46:33 -0700 (PDT) X-Google-Smtp-Source: APBJJlGpLai63bYMM75ZLPNJUOxJhsSgJQvJKhPXOH7vKtLJGqD0AFwSsPKH37bpCaZoFUKMhsVP X-Received: by 2002:a05:6512:2018:b0:4fb:9da2:6cec with SMTP id a24-20020a056512201800b004fb9da26cecmr31717lfb.7.1690483593065; Thu, 27 Jul 2023 11:46:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690483593; cv=none; d=google.com; s=arc-20160816; b=yaokNhMMwk72K3QcFTuoXnZpeaJ4CGyBS8tN47OPSoEE+gCant2FlQweAHdwi/Xb2Y j2oyrISAadgGwCA92s7fo47+3Z5kqbs0I25Cb6UEy6PfQDd3Hqqh7rMRcfu4MdETWU5Q pQ51v/TRqI33DVbm17nTB/piihictEM2N9sHZIiuu0EJYaezRweitV39VzEToeinTCFx 2FaprVc9GeId98FD3MdAeL6F021GVDS+CVy49Tc4ulGBIJdyzXCvO19UX3XrjDcKhZFN cQVLZBfUqXkc7ON0oQgLExzRS2viwtaxQNBbLvEWLbRnPl7BTFOcwd/PD7gszc5OO2MC FR0Q== 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:mime-version:date :dkim-signature; bh=LdqBlA80Wg7TTifhsmcWRJBqXp5WhnKqMSkVfyET1zg=; fh=HnAFHWFlJx6556zbVk+xHReF/Bq7K9G33irMhQzl/Ec=; b=lHSjCG+U0Cux6hCGB9+fWyHcYwPMba194OjhyrHFPhBw+3Ej1LsRUVx4AfBL3XFIlB kvqHP5mkO4GJtGOPyh0ncsqM3UtV5G6PLyCgPRM5trVhTuVJAtCUJCjNct4QvO3eXnzb LlosGDtoO6xkY/r9vF/O/6DF6pan/OzP46wEF4pJsja5DouneqNGUqd8/n5FDCIA3m6C 0nJ8h2wCnpAbIy+1lB37mG3i96kASM+pJY399OEYPMDsXX7YnyT74zyRzUxxno/IV0Fb BKM0ITZuFG+1qEOQsd4S2sejuLe8JrlUvL2I7zYwqsgdBugbNh1Fc7H9aWGK+aUgTmb+ LYUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=2ORqFkA2; 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 y4-20020aa7d504000000b005222c413404si1393338edq.681.2023.07.27.11.46.08; Thu, 27 Jul 2023 11:46: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=2ORqFkA2; 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 S230071AbjG0S2G (ORCPT <rfc822;kloczko.tomasz@gmail.com> + 99 others); Thu, 27 Jul 2023 14:28:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229492AbjG0S2E (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 27 Jul 2023 14:28:04 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3DFD26B2 for <linux-kernel@vger.kernel.org>; Thu, 27 Jul 2023 11:28:03 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-584375eacacso13072487b3.0 for <linux-kernel@vger.kernel.org>; Thu, 27 Jul 2023 11:28:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690482483; x=1691087283; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=LdqBlA80Wg7TTifhsmcWRJBqXp5WhnKqMSkVfyET1zg=; b=2ORqFkA2f3Z9uBQcEXJuPsfPoD3pbCZzEg9K5vjpSb+ANKuVree8tmQXRURnLx56ld kaGAjGT3BxZrdF3VUT+aDQokKYfTI8kUwreH2Ab+JrMFGHHJcKLVDG2OXYPZ3VLXA/Fv 6stescGuyXhxkUxbS5ZRNT907yR2cFGVnzi34CqfJbBZ2Z+D5sawwHlSDSnFU104J90i glA8cm4ApX4r3QoQCorCX6/v+SGlMnEfQVVz+ZVvLaIBZSFCBwZ0nBPt7llVhUy8I30v wq5c/3NJErPcbxT2Qp0L2yDOnvEnZGEV87lSNUYeBc0TkL8RMv3mWzLs08LIc7xWbRRW ya0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690482483; x=1691087283; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=LdqBlA80Wg7TTifhsmcWRJBqXp5WhnKqMSkVfyET1zg=; b=UeOpQQ93+iycItHxWIq1wTocRg+nD/uYCK83W706vx30Uhuzd5vfm40qwZtWkUosw/ AWR7tYU4Za1eT6vda9pVWazk44NRBAIVRBNg2TCCp6dK+qBWNoGyTcxZi+zWghKQ8l5G mR1q9FKBqC5+T4xJeTT/wjULV3I1cpf71lknbNrPnLEXEc0ZZAM+kFp25hPgtWNd2Oq/ l837prZFYt4mqETGCsekhHingkpj/qOWb7Ljqj5CTJj6yugzQ8/9lL6qUhpdLIeNAfA2 1Zfl4OwmG73oXSvxE0V7Tt5q/YCtEO6ApBTLzCZAbQ7pGo2DXjy7qv/7Xmduz3QE7ZbT QAhg== X-Gm-Message-State: ABy/qLZHjB9a16eWobKKm9i6/F8f8O81FamFEpkzew3YCPLgWpnmtuZF rG8DCGgrF1GvcjDB9NfS9YK1m42bcqvX X-Received: from mshavit.ntc.corp.google.com ([2401:fa00:95:20c:780f:26da:d952:3463]) (user=mshavit job=sendgmr) by 2002:a05:690c:72c:b0:576:cd91:b888 with SMTP id bt12-20020a05690c072c00b00576cd91b888mr805ywb.0.1690482483158; Thu, 27 Jul 2023 11:28:03 -0700 (PDT) Date: Fri, 28 Jul 2023 02:26:16 +0800 Mime-Version: 1.0 X-Mailer: git-send-email 2.41.0.585.gd2178a4bd4-goog Message-ID: <20230727182647.4106140-1-mshavit@google.com> Subject: [PATCH v1 0/7] Refactor the SMMU's CD table ownership From: Michael Shavit <mshavit@google.com> To: Will Deacon <will@kernel.org>, Robin Murphy <robin.murphy@arm.com>, Joerg Roedel <joro@8bytes.org> Cc: Michael Shavit <mshavit@google.com>, 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 Content-Type: text/plain; charset="UTF-8" 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772600524216970966 X-GMAIL-MSGID: 1772600524216970966 |
Series |
Refactor the SMMU's CD table ownership
|
|
Message
Michael Shavit
July 27, 2023, 6:26 p.m. UTC
Hi all, This series refactors stage 1 domains so that they describe a single CD entry. These entries are now inserted into a CD table that is owned by the arm_smmu_master instead of the domain. This is conceptually cleaner and unblocks other features, such as attaching domains with PASID (for unmanaged/dma domains). This patch series was originally part of a larger patch series that implemented the set_dev_pasid callback for non-SVA domains but is now split into a distinct series. This patch series is also available on gerrit with Jean's SMMU test engine patches cherry-picked on top for testing: https://linux-review.git.corp.google.com/c/linux/kernel/git/torvalds/linux/+/24729 Thanks, Michael Shavit Changelog v1: * Replace s1_cfg with arm_smmu_ctx_desc_cfg representing the CD table * Assume that the CD table is owned by the SMMU master for most operations. This is forward-compatible with the nested patch series as these operations wouldn't be called when the installed CD table comes from nested domains. * Split off as a distinct patch series Split-off from: https://lore.kernel.org/all/20230621063825.268890-1-mshavit@google.com/ Michael Shavit (7): iommu/arm-smmu-v3: Move ctx_desc out of s1_cfg iommu/arm-smmu-v3: Replace s1_cfg with ctx_desc_cfg iommu/arm-smmu-v3: Encapsulate ctx_desc_cfg init in alloc_cd_tables iommu/arm-smmu-v3: move stall_enabled to the cd table iommu/arm-smmu-v3: Skip cd sync if CD table isn't active iommu/arm-smmu-v3: Refactor write_ctx_desc iommu/arm-smmu-v3: Move CD table to arm_smmu_master .../iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 35 +++- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 167 ++++++++---------- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 39 ++-- 3 files changed, 123 insertions(+), 118 deletions(-) base-commit: 0a8db05b571ad5b8d5c8774a004c0424260a90bd
Comments
On Fri, Jul 28, 2023 at 02:26:21AM +0800, Michael Shavit wrote: > 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 <mshavit@google.com> > --- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 4 ++++ > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 2 ++ > 2 files changed, 6 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 654acf6002bf3..af7949b62327b 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); > @@ -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 0e55ca0d40e6b..f301efe90b599 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. */ > bool stall_enabled; > + /* Whether this CD table is installed in any STE */ > + bool installed; Do u8 xx:1; u8 yy:1; For these things, Linus has complained about lists of bools in structs before. Jason
On Fri, Jul 28, 2023 at 02:26:17AM +0800, Michael Shavit wrote: > @@ -715,25 +714,28 @@ enum arm_smmu_domain_stage { > }; > > struct arm_smmu_domain { > - struct arm_smmu_device *smmu; > - struct mutex init_mutex; /* Protects smmu pointer */ > + struct arm_smmu_device *smmu; > + struct mutex init_mutex; /* Protects smmu pointer */ > > - struct io_pgtable_ops *pgtbl_ops; > - bool stall_enabled; > - atomic_t nr_ats_masters; > + struct io_pgtable_ops *pgtbl_ops; > + bool stall_enabled; > + atomic_t nr_ats_masters; > > - enum arm_smmu_domain_stage stage; > + enum arm_smmu_domain_stage stage; > union { > - struct arm_smmu_s1_cfg s1_cfg; > - struct arm_smmu_s2_cfg s2_cfg; > + struct { > + struct arm_smmu_ctx_desc cd; > + struct arm_smmu_s1_cfg s1_cfg; > + }; > + struct arm_smmu_s2_cfg s2_cfg; > }; > > - struct iommu_domain domain; > + struct iommu_domain domain; > > - struct list_head devices; > - spinlock_t devices_lock; > + struct list_head devices; > + spinlock_t devices_lock; > > - struct list_head mmu_notifiers; > + struct list_head mmu_notifiers; > }; Don't re-indent a whole struct just to get column alignment. Do a few lines around where you are touching. This is also why I quite dislike column alignment, aside from being unreadable, it harms readability of diffs and increases maintenance costs. Jason
Hi Michael, Thanks for sending this! On Fri, Jul 28, 2023 at 02:26:16AM +0800, Michael Shavit wrote: > This series refactors stage 1 domains so that they describe a single CD > entry. These entries are now inserted into a CD table that is owned by > the arm_smmu_master instead of the domain. > This is conceptually cleaner and unblocks other features, such as > attaching domains with PASID (for unmanaged/dma domains). > > This patch series was originally part of a larger patch series that > implemented the set_dev_pasid callback for non-SVA domains but is now > split into a distinct series. > > This patch series is also available on gerrit with Jean's SMMU test > engine patches cherry-picked on top for testing: > https://linux-review.git.corp.google.com/c/linux/kernel/git/torvalds/linux/+/24729 The link isn't accessible for public. I guess it should be this? https://linux-review.googlesource.com/c/linux/kernel/git/torvalds/linux/+/24729 Nicolin
On Fri, Jul 28, 2023 at 4:20 AM Nicolin Chen <nicolinc@nvidia.com> wrote: > The link isn't accessible for public. I guess it should be this? > https://linux-review.googlesource.com/c/linux/kernel/git/torvalds/linux/+/24729 Whoops sorry yeah that's the correct link.