From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4487EC873A for ; Thu, 7 Sep 2023 16:05:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234546AbjIGQFA (ORCPT ); Thu, 7 Sep 2023 12:05:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236859AbjIGQEd (ORCPT ); Thu, 7 Sep 2023 12:04:33 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BD8F6A76; Thu, 7 Sep 2023 08:53:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694102023; x=1725638023; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=4Zc2NSQczgzpNCTjAeZ+vgoDDV24z7zZmEzSqmTWoV8=; b=UdfaggH2VB5SmzXi54f6JDs0yVt0a/jKfSP4xHqye9vADx4Kr3u8pl4e 2s3kgggxgOE9fiEerRwc/BjSXHuvhgvg+h71NJKRD6jpIR7bkzi7QymOp jfqlPN/rn57HrUVze4IQDcGiFuNopiowLupxs8uV8FQDWGVHJdi4Snvu6 gbwVQ+f7nkW1HpaoZ3mM2ViWukJZq6GrjhLuyv90WrFiSEg+wDDJaQ1WM +yCPNGZaZqlC7A+kTSTKR67A6fp7aU5yoB+y0jLmFoySzrqD2cbbkcZ32 FkFQZQpPe59/A0o0/FiFfUi5NXd1tp7AJ60NvGjlE5oYIs+cQJh94ZWhm Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10825"; a="356825430" X-IronPort-AV: E=Sophos;i="6.02,235,1688454000"; d="scan'208";a="356825430" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2023 06:16:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10825"; a="691782245" X-IronPort-AV: E=Sophos;i="6.02,235,1688454000"; d="scan'208";a="691782245" Received: from jnikula-mobl4.fi.intel.com (HELO localhost) ([10.237.66.162]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2023 06:16:00 -0700 From: Jani Nikula To: Donald Robson , "dri-devel@lists.freedesktop.org" , Sarah Walker Cc: "corbet@lwn.net" , "luben.tuikov@amd.com" , "christian.koenig@amd.com" , "krzysztof.kozlowski+dt@linaro.org" , "tzimmermann@suse.de" , "mripard@kernel.org" , "matthew.brost@intel.com" , "afd@ti.com" , "hns@goldelico.com" , Matt Coster , "boris.brezillon@collabora.com" , "linux-kernel@vger.kernel.org" , "conor+dt@kernel.org" , "devicetree@vger.kernel.org" , "linux-doc@vger.kernel.org" , "robh+dt@kernel.org" , "dakr@redhat.com" , "faith.ekstrand@collabora.com" Subject: Re: [PATCH v6 02/20] drm/gpuva_mgr: Helper to get range of unmap from a remap op. In-Reply-To: <5b7f431f26eea296193d9e49ea85e0377e6ebcf0.camel@imgtec.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20230906095542.3280699-1-sarah.walker@imgtec.com> <20230906095542.3280699-3-sarah.walker@imgtec.com> <87a5tygoyx.fsf@intel.com> <5b7f431f26eea296193d9e49ea85e0377e6ebcf0.camel@imgtec.com> Date: Thu, 07 Sep 2023 16:15:57 +0300 Message-ID: <877cp2gm42.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On Thu, 07 Sep 2023, Donald Robson wrote: > On Thu, 2023-09-07 at 15:14 +0300, Jani Nikula wrote: >> On Wed, 06 Sep 2023, Sarah Walker wrote: >> > From: Donald Robson >> > >> > Signed-off-by: Donald Robson >> > --- >> > include/drm/drm_gpuva_mgr.h | 27 +++++++++++++++++++++++++++ >> > 1 file changed, 27 insertions(+) >> > >> > diff --git a/include/drm/drm_gpuva_mgr.h b/include/drm/drm_gpuva_mgr.h >> > index ed8d50200cc3..be7b3a6d7e67 100644 >> > --- a/include/drm/drm_gpuva_mgr.h >> > +++ b/include/drm/drm_gpuva_mgr.h >> > @@ -703,4 +703,31 @@ void drm_gpuva_remap(struct drm_gpuva *prev, >> > >> > void drm_gpuva_unmap(struct drm_gpuva_op_unmap *op); >> > >> > +/** >> > + * drm_gpuva_op_remap_get_unmap_range() - Helper to get the start and range of >> > + * the unmap stage of a remap op. >> > + * @op: Remap op. >> > + * @start_addr: Output pointer for the start of the required unmap. >> > + * @range: Output pointer for the length of the required unmap. >> > + * >> > + * These parameters can then be used by the caller to unmap memory pages that >> > + * are no longer required. >> > + */ >> > +static __always_inline void >> >> IMO __always_inline *always* requires a justification in the commit >> message. >> >> BR, >> Jani. > > Hi Jani, > I went with __always_inline because I can't see this being used more than once per driver. > I can add that to the commit message, but is that suitable justification? I could move > it to the source file or make it a macro if you prefer. My personal opinion is that static inlines in general should always have a performance justification. If there isn't one, it should be a regular function. Static inlines leak the abstractions and often make the header dependencies worse. Not everyone agrees, of course. More than anything I was looking for justification on __always_inline rather than just inline, though. BR, Jani. > Thanks, > Donald >> >> >> > +drm_gpuva_op_remap_get_unmap_range(const struct drm_gpuva_op_remap *op, >> > + u64 *start_addr, u64 *range) >> > +{ >> > + const u64 va_start = op->prev ? >> > + op->prev->va.addr + op->prev->va.range : >> > + op->unmap->va->va.addr; >> > + const u64 va_end = op->next ? >> > + op->next->va.addr : >> > + op->unmap->va->va.addr + op->unmap->va->va.range; >> > + >> > + if (start_addr) >> > + *start_addr = va_start; >> > + if (range) >> > + *range = va_end - va_start; >> > +} >> > + >> > #endif /* __DRM_GPUVA_MGR_H__ */ -- Jani Nikula, Intel Open Source Graphics Center