Received: by 2002:a05:6358:51dd:b0:131:369:b2a3 with SMTP id 29csp509632rwl; Wed, 9 Aug 2023 19:09:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGU4NQrFlyxBCy23uh5wZ4gJZ0dHT3xMOBLejR4pKStfBld1J1P2V5LxDvai5fjdGN+WmLA X-Received: by 2002:a17:90b:3b92:b0:263:856:fcdf with SMTP id pc18-20020a17090b3b9200b002630856fcdfmr812417pjb.12.1691633377786; Wed, 09 Aug 2023 19:09:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691633377; cv=none; d=google.com; s=arc-20160816; b=UPj6jbAuGljHdeOhLNizZB5eP2nwACg3N4/RVk27F2HpAJxxPNZi/PqgaasiwBCaKv vhqMvUNhUr9eqC+/KHyrBzVK69bOBQ7N2PGYHKYmpK9v71HduIB6SehJILZ30AepENwu JaitvGQ6nNKGTQeA/vo81apNb4kZZfx5gAXPyb8W2P9fYUbYjo4ei5hDtjA/4G1k8Uwm sw3V8k8kEopE4SmjPQXuUXEq4gFOL2Sd0tqpsCzUba3CMGqC1kgzGCuTGI9lOkFX/cHd IgFCdApyAzLAgoVotNVUMR1IsYc042JZ6ugdwE3TxW2FF13Q12GnKXtEnjFP0JVIhHs6 XLwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:cc:user-agent:mime-version :date:message-id:dkim-signature; bh=XxLCSJ7dzE2GDjaV7tpHCTvXuJpd5xV6GLGRqtuUueo=; fh=CAa3QO6iNVXeFgf2WmK4ESlfiD8FDcwxWHL1z+R4D4M=; b=QZRxXl8TrbP0yUVOF3fgTKFOZw9oJ4j1x5Hairz0CeCEonssMi1wnnxJCLFc4aemQM eElS40Sp90p3ec1FQz3JuRx5mcoxdeVMJd1fIThfpAjWTggp3wWsn47hAchDNZu/KSwi vSzh1EXgtMD0txG/wRXU/WcplAWNCGOvnB32dHL9QP8FAcqxJ7+MY8B8BPhikEQ3I3Rm 5zn5iaO0MvZawOGrxDpeAoFW9Sa+lKxhV81Tt8KcdwDGWrLZqGXxtcuaDIlrO+ugvkGf Vdx7tm0VIjNGdQlE2pX2skARwFyv9ieNdyFYsVz7E1p3vIZuw0cvJD/uf9IzdB4JXn/Z Hphg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FhqDPmU1; 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=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q31-20020a17090a752200b0026958c3d255si517816pjk.126.2023.08.09.19.09.25; Wed, 09 Aug 2023 19:09:37 -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=@intel.com header.s=Intel header.b=FhqDPmU1; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231703AbjHJBhQ (ORCPT + 99 others); Wed, 9 Aug 2023 21:37:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229940AbjHJBhP (ORCPT ); Wed, 9 Aug 2023 21:37:15 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE3E91724 for ; Wed, 9 Aug 2023 18:37:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691631434; x=1723167434; 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=FhqDPmU1IC0rhbY2y3XB7Y+s7n1qdfZYxLBnwunAHtFsF2UASAhCW9d1 KPzLLRP4uellB5FEfgCtzDK9cAbH5CS1SH0eaN9wXfNuhrFb/Tn40FZk7 vWMf05+Rzv5L+4vxm3e30E0RVlpd3sbV+fP+Ewv3WS45NVArs84l8EL/t H9ig1Pq+7VqwBI0dikWJ/V+P5e3/QKl5hzjKTYE7XG1ST2NZvkSXfnjcF Hub85VTnsrXtS/5TbkSL7SVUyYQMGTkApiBjIhjYXKKWCkJcmX1oi+Nt6 SoHPdfuPgBHLMnEnHcf2VizOl6EwsOlF8oLWS9ONznn19v610Dz197vCC w==; X-IronPort-AV: E=McAfee;i="6600,9927,10797"; a="371267215" X-IronPort-AV: E=Sophos;i="6.01,160,1684825200"; d="scan'208";a="371267215" 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 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 X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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: X-Mailing-List: linux-kernel@vger.kernel.org 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