From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38670634 for ; Thu, 10 Aug 2023 01:37:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691631437; x=1723167437; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=D6M/kMPtxQ6zaM/g8+1a+dQ8Yi3fC4ce3oeCDNqH8+o=; b=mC2RzWznaoWpugXtiTimfgOFGw7HlEiAn6U0NJXuIg6y5T1ua7jnsKoN dD3hcCyYnjxg2yMrQ9CsUdAj0wUwZVet1V5n+fuI5C+IRv52DKCCYJ5f9 4l8grerhoaWdZWFCd0QclZ+lo+pXVOOH4A0PqHzz4j6l2WlDLnRdup+Cv PRAORIoDfBJgCg+zvZsuv9egjhTAslk2A4e8EI9t+Zyb+Yzdt0Lbv8Zsv X7qQlsjEtPmNdbPDoxqfKyHnnTSxvCwfvu55YhOZ7QINQN6MAV8dLJkSA 0UnItlQBYlsn3sJmUq3jJlDygfFLzc2wY1nqFKxfTFXI34AxWOWipDWWt A==; X-IronPort-AV: E=McAfee;i="6600,9927,10797"; a="371267216" X-IronPort-AV: E=Sophos;i="6.01,160,1684825200"; d="scan'208";a="371267216" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Aug 2023 18:37:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10797"; a="681905093" X-IronPort-AV: E=Sophos;i="6.01,160,1684825200"; d="scan'208";a="681905093" Received: from blu2-mobl.ccr.corp.intel.com (HELO [10.254.214.239]) ([10.254.214.239]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Aug 2023 18:37:12 -0700 Message-ID: <84494c88-66eb-a731-fbf0-4a83fb9102f1@linux.intel.com> Date: Thu, 10 Aug 2023 09:37:09 +0800 Precedence: bulk X-Mailing-List: iommu@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Cc: baolu.lu@linux.intel.com, "Tian, Kevin" , "Zhang, Tina" , Michael Shavit , "iommu@lists.linux.dev" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 2/5] iommu: Call helper function to get assigned pasid value Content-Language: en-US To: Jason Gunthorpe References: <20230808074944.7825-1-tina.zhang@intel.com> <20230808074944.7825-3-tina.zhang@intel.com> From: Baolu Lu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2023/8/9 22:48, Jason Gunthorpe wrote: > On Wed, Aug 09, 2023 at 06:58:15PM +0800, Baolu Lu wrote: >> On 2023/8/9 17:49, Tian, Kevin wrote: >>>> From: Baolu Lu >>>> Sent: Wednesday, August 9, 2023 8:22 AM >>>> >>>> On 2023/8/8 15:49, Tina Zhang wrote: >>>>> Use the helper function mm_get_pasid() to get the mm assigned pasid >>>>> value. >>>> >>>> For internal iommu drivers, perhaps we should use another helper. >>>> Something like sva_domain_get_pasid()? >>>> >>>> Suppose that the iommu drivers should have no idea about the "mm". >>>> >>> >>> Aren't all touched functions accept a struct mm_struct pointer? >> >> In the end we should remove all mm reference in the individual drivers. >> The drivers only need to know what they need to know. All mm-aware code >> should eventually be moved to the core. >> >> For now, at least we should avoid using mm in the set/remove_dev_pasid >> code path. Later, once we complete consolidating mm notification in the >> core, drivers will have no need to use "mm" anymore. > > I'm not sure how this will play out... > > We don't want extra function indirections here so ultimately the > driver needs to hook the arch_invalidate_range() in the mm_notifier > with its own function. Agreed. Given the mm notification callback is a performance path, an extra indirection call here is not good. > > The core could put the mm_notifier in a common iommu_domain_sva struct > and it could stick in the driver's invalidate ops, that would be a > nice simplification (and discourage drivers from doing the crazy > things they are currently doing) Yes. So the iommu driver can retrieve the sva domain from struct mmu_notifier. The callback implementation will still be domain centric. Hence, there will be no need to use mm. Best regards, baolu