Message ID | 20231017032045.114868-8-tina.zhang@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp3872493vqb; Mon, 16 Oct 2023 20:22:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGDPoW04pVIZPdNCS8lDjHPke2d2KjDPfG1UIz9uSyUFXHzq94dPukI74SQMq64YI40gHov X-Received: by 2002:a05:6358:514e:b0:166:d909:74e with SMTP id 14-20020a056358514e00b00166d909074emr1049665rwj.0.1697512946284; Mon, 16 Oct 2023 20:22:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697512946; cv=none; d=google.com; s=arc-20160816; b=zR8mTKzSmLwdT0pEslSlKjZc0TCqTEmXko3TcxY25v+o8JMr1wsIzrWpXXLVKt025r 2DEuHcb+60GRiUMYSJ0EZzaJXM6E4WRvtgbMT3FIxypyiMQRtvqyXk9OLneHVxFSuzUJ F3hdg1r+11EazS8hI818dgZy2FjCdXU5VLqOwdWmmQmcFGX5QD8LHfk066X/s/IHI0Qv bV89vT+bGAJjph42jDntRph3cbgFtE2F1dMgM+QmZ0HYfrz3a0RZYEI7nsndcHDp/HgB TcZXDNmnNriPmP4QbU1wLDCT0IyGiQwx+MJpy869e+15Nb93bokqEz9mKwTjrgQUF6tt spsQ== 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; bh=x1Nc2tcmx5S41wHimByt+J2JxVaVlEvzy9eDtDFDdxc=; fh=R49q8kPD/ziIvsyYshS2LccDCxkbN9TSdzSyy3EleF0=; b=MxemSM0lgNNHkxmoSZPwO89pyo6o8QwLfeNgVniTE2QF7NgzXlOzsUDBGfDtrvhYEu EaOAkyxLrdM2mPm9miNuotGSPzhdJws3fMtFKyRFkI0/JhqQwbIsoFr2PJLQibel6nKe oLBCwzEsFHqOnZjFEehPFlokdAc9azOuvah33iC3l8aQmcBQz0rZ7aW0loRUOOz+SeuG U5NdPB09ZPtOJPlpcXMRrgJ+D7L1t6P73WEQMHc3duFhzj9fRH7nFda47arjupmsCTCa NO/IWKO7wAuscFgS2aU2XKcyrakvP3rpEbnBpamkqNmRQj3wxqjuQKbOBpHl27P5fCsy WxKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VYd9GTkw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id i13-20020a63e44d000000b00565eb0b2e66si854591pgk.864.2023.10.16.20.22.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 20:22:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VYd9GTkw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id A09F9802FD49; Mon, 16 Oct 2023 20:22:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234353AbjJQDWA (ORCPT <rfc822;hjfbswb@gmail.com> + 19 others); Mon, 16 Oct 2023 23:22:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234339AbjJQDVf (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 16 Oct 2023 23:21:35 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 752FB12E; Mon, 16 Oct 2023 20:21:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697512886; x=1729048886; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZhmxoShuHLiM8DBi/fzm6G4kHK6SDXHp234E7569BMQ=; b=VYd9GTkwakgTet/PqtlaCUawQ9FLonUV23Us/ZTUMO8PyQh16q6YO2V5 C1VV9OoUORl8Dz8Yi7WMzJETfDK86anDJzzs17SALkmK9/YHlq7e9M2sF Uglyq0bwH0hCeM0j6mI/LcwrG1dgZicRh3X9ECVLTnKAXGY0aGixUob59 D9BseVgCn08L2fTl/qSJUqkRq3MCYIK/5f+zq8dYTfthKRXzAZrNynGpx HCeuE1inmbt96OkaoTxUqpKBTqkDnIJ67G7SzDLRS+UVlOrQ/1eXWKs3d k7aZ2SgWGjg1D4qaSb0biZiZeKW2YTFISnhzJxIIMjkyfK63/xODjZAMT g==; X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="389560852" X-IronPort-AV: E=Sophos;i="6.03,231,1694761200"; d="scan'208";a="389560852" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 20:21:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="826270060" X-IronPort-AV: E=Sophos;i="6.03,231,1694761200"; d="scan'208";a="826270060" Received: from sqa-gate.sh.intel.com (HELO spr-2s5.tsp.org) ([10.239.48.212]) by fmsmga004.fm.intel.com with ESMTP; 16 Oct 2023 20:21:23 -0700 From: Tina Zhang <tina.zhang@intel.com> To: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: David Woodhouse <dwmw2@infradead.org>, Lu Baolu <baolu.lu@linux.intel.com>, Joerg Roedel <joro@8bytes.org>, Jason Gunthorpe <jgg@ziepe.ca>, Kevin Tian <kevin.tian@intel.com>, Tina Zhang <tina.zhang@intel.com> Subject: [RFC PATCH 06/12] iommu: Add mmu_notifier to sva domain Date: Tue, 17 Oct 2023 11:20:39 +0800 Message-Id: <20231017032045.114868-8-tina.zhang@intel.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231017032045.114868-1-tina.zhang@intel.com> References: <20231017032045.114868-1-tina.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 16 Oct 2023 20:22:23 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779971334854556330 X-GMAIL-MSGID: 1779971334854556330 |
Series |
iommu/vt-d: Remove superfluous IOMMU IOTLB invalidations
|
|
Commit Message
Zhang, Tina
Oct. 17, 2023, 3:20 a.m. UTC
Devices attached to shared virtual addressing (SVA) domain are allowed to
use the same virtual addresses with processor, and this functionality is
called shared virtual memory. When shared virtual memory is being used,
it's the sva domain's responsibility to keep device TLB cache and the CPU
cache in sync. Hence add mmu_notifier to sva domain.
Signed-off-by: Tina Zhang <tina.zhang@intel.com>
---
include/linux/iommu.h | 2 ++
1 file changed, 2 insertions(+)
Comments
On Tue, Oct 17, 2023 at 11:20:39AM +0800, Tina Zhang wrote: > Devices attached to shared virtual addressing (SVA) domain are allowed to > use the same virtual addresses with processor, and this functionality is > called shared virtual memory. When shared virtual memory is being used, > it's the sva domain's responsibility to keep device TLB cache and the CPU > cache in sync. Hence add mmu_notifier to sva domain. > > Signed-off-by: Tina Zhang <tina.zhang@intel.com> > --- > include/linux/iommu.h | 2 ++ > 1 file changed, 2 insertions(+) You should look at how arm smmuv3 ended up after I went over it to make similar changes, I think you should take this patch https://lore.kernel.org/linux-iommu/20-v1-afbb86647bbd+5-smmuv3_newapi_p2_jgg@nvidia.com/ into this series (maybe drop the arm part) And copy the same basic structure for how the mmu notifier works. It would also be nice if alot of the 'if_sva' tests could be avoided, smmu didn't end up with those.. In the guts of the pasid handling sva shouldn't be special beyond a different source for the pgd. Jason
Hi Jason, > -----Original Message----- > From: Jason Gunthorpe <jgg@ziepe.ca> > Sent: Tuesday, October 24, 2023 2:35 AM > To: Zhang, Tina <tina.zhang@intel.com> > Cc: iommu@lists.linux.dev; linux-kernel@vger.kernel.org; kvm@vger.kernel.org; > David Woodhouse <dwmw2@infradead.org>; Lu Baolu > <baolu.lu@linux.intel.com>; Joerg Roedel <joro@8bytes.org>; Tian, Kevin > <kevin.tian@intel.com> > Subject: Re: [RFC PATCH 06/12] iommu: Add mmu_notifier to sva domain > > > On Tue, Oct 17, 2023 at 11:20:39AM +0800, Tina Zhang wrote: > > Devices attached to shared virtual addressing (SVA) domain are allowed > > to use the same virtual addresses with processor, and this > > functionality is called shared virtual memory. When shared virtual > > memory is being used, it's the sva domain's responsibility to keep > > device TLB cache and the CPU cache in sync. Hence add mmu_notifier to sva > domain. > > > > Signed-off-by: Tina Zhang <tina.zhang@intel.com> > > --- > > include/linux/iommu.h | 2 ++ > > 1 file changed, 2 insertions(+) > > You should look at how arm smmuv3 ended up after I went over it to make > similar changes, I think you should take this patch > > https://lore.kernel.org/linux-iommu/20-v1-afbb86647bbd+5- > smmuv3_newapi_p2_jgg@nvidia.com/ > > into this series (maybe drop the arm part) Good suggestion. The new domain_alloc_sva() callback allows drivers to fully initialize sva domain that is what we need. I'll take the domain_alloc_sva() part as a patch and include it in this patch-set. Thanks. > > And copy the same basic structure for how the mmu notifier works. > > It would also be nice if alot of the 'if_sva' tests could be avoided, smmu didn't > end up with those.. Agree. With the help of domain_alloc_sva() callback, I think most of the if_sva brought by this RFC version can be reduced, as we can reuse fields from dmar_domain (or add new ones if necessary) and initialize them in domain_alloc_sva(). Regards, -Tina > > In the guts of the pasid handling sva shouldn't be special beyond a different > source for the pgd. > > Jason
diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 19b5ae2303ff..afb566230427 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -7,6 +7,7 @@ #ifndef __LINUX_IOMMU_H #define __LINUX_IOMMU_H +#include <linux/mmu_notifier.h> #include <linux/scatterlist.h> #include <linux/device.h> #include <linux/types.h> @@ -114,6 +115,7 @@ struct iommu_domain { * protected by iommu_sva_lock. */ struct list_head next; + struct mmu_notifier notifier; }; }; };