Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp1016230pxb; Thu, 17 Feb 2022 21:38:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6xK4BIN6NbkNTihEPeRRlzzMpweFIeRxCI1F4dVE+uWLyQVCpJ+GgdAlDrcOi++6K6VeE X-Received: by 2002:a17:906:3803:b0:6cf:56b9:60a9 with SMTP id v3-20020a170906380300b006cf56b960a9mr4719502ejc.716.1645162716626; Thu, 17 Feb 2022 21:38:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645162716; cv=none; d=google.com; s=arc-20160816; b=nmWU5zgaB07CuT8J7JRh/g6rm4FlJb5ByoVY1CGTfExGaA8xHk4SqZ932Gqekjz4wC HCQghqrSatGLWBof6oE7Ta09AJ1OE4QDRdcAIFyuvnlqeNNFd6Xrob6PjSAs1nO5d2P1 jkzDT0fwYGWLX9A63OV9ySCn/7wmVKgTNBsEntanVwMzDnNMB0zzE4r9Ti3odefv9aDJ HeG1+NruTfUNWw1TO1XK7QcI9c0/wFGiO92gJctUsMXrlTjbfCsNWJ/d/k+9jNlQEOj/ zvhI3UYekdCAtmqeyL3qpQip/jYJyeP1Ly4e9BxYn83rlskxAD1QSPEXE1bvsEmNxlI5 N8rQ== 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 :message-id:date:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=r71xSX5KnN4kkntv9iWFxm7k6dxuJpcSAPeDmjcGgrw=; b=u+Ygx13aQ31iPiRFGHCQixvtT5ENLUudy9U2ApBxxh2C7Ohhq/LKpCs7Jk47w7Q+nz yq9CN0jk1L8th8F3krSgVr4HnW/XE26bBCEyh3WTU/uPApMbCaABRk2F7p22Di2XXI9u UXi880xai1Hx/1ayLB9taaYmytDjSNtrEYhDhAN8doqQntC0D4sdbwQJbwnI3uxi3LY3 9qWvksC8aaZoMxdtfvez5DTcKcbOXOuoeLta7VXnDRRvzXosO1L0idynIJjODEu5tnJs 9U9jqKWhP7K14d7aZ/LrKn2xq3nqQZWZhLHn68FJPMH4GPtThsiiCdwsrpv1vCNR+CkT x0uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="iS/beWCR"; 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 10si3151070ejj.230.2022.02.17.21.38.14; Thu, 17 Feb 2022 21:38:36 -0800 (PST) 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="iS/beWCR"; 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 S229941AbiBRE5z (ORCPT + 99 others); Thu, 17 Feb 2022 23:57:55 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:37654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229593AbiBRE5x (ORCPT ); Thu, 17 Feb 2022 23:57:53 -0500 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E46DFABD5 for ; Thu, 17 Feb 2022 20:57:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645160257; x=1676696257; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version:content-transfer-encoding; bh=l7ftpFnCb/O18IQbZiuP+YjPFB7WGOV4wq64D8YJp0E=; b=iS/beWCRv+byLKkYVXdk+WIQwULKWky8uydPNHpeGzWUSiBCWZk2++ZW 24RuUtYWijwR2pbUVyH0EyzPzYqTSvv0nmx9qN6dAqyJ4NeSw8U0IV4fT tVxq9CPlrH9/zWPpd8ZX+NxEW5K8WZRGvvTFSw+geAc2Wdik/+7VyvMy4 NsqrO10tKv+dyGMYY399qKKg/MbY4Hj4SARegKA/h3BVhDFd1FYao54zc MybpBgX8lsnDOknogyoQ7b05cm5fT8yq6mqE0F7WciFT3lCGpUpxs/+L8 l9UDp/Co2nYGYTyWRq1cWbNm9IelUnYvVXi+5hd3k/uf1HLqBfNwh4LsK Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10261"; a="231034416" X-IronPort-AV: E=Sophos;i="5.88,377,1635231600"; d="scan'208";a="231034416" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 20:57:37 -0800 X-IronPort-AV: E=Sophos;i="5.88,377,1635231600"; d="scan'208";a="546104238" Received: from bmeland-mobl2.amr.corp.intel.com (HELO localhost) ([10.212.148.192]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 20:57:36 -0800 From: Jordan Justen To: Robert Beckett , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter Cc: Matthew Auld , Ramalingam C , Robert Beckett , Thomas =?utf-8?Q?Hellstr=C3=B6m?= , Simon Ser , Pekka Paalanen , Kenneth Graunke , mesa-dev@lists.freedesktop.org, Tony Ye , Slawomir Milczarek , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v8 5/5] drm/i915/uapi: document behaviour for DG2 64K support In-Reply-To: <20220208203419.1094362-6-bob.beckett@collabora.com> References: <20220208203419.1094362-1-bob.beckett@collabora.com> <20220208203419.1094362-6-bob.beckett@collabora.com> Date: Thu, 17 Feb 2022 20:57:35 -0800 Message-ID: <87ee40ojpc.fsf@jljusten-skl> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Robert Beckett writes: > From: Matthew Auld > > On discrete platforms like DG2, we need to support a minimum page size > of 64K when dealing with device local-memory. This is quite tricky for > various reasons, so try to document the new implicit uapi for this. > > v3: fix typos and less emphasis > v2: Fixed suggestions on formatting [Daniel] > > Signed-off-by: Matthew Auld > Signed-off-by: Ramalingam C > Signed-off-by: Robert Beckett > Acked-by: Jordan Justen > Reviewed-by: Ramalingam C > Reviewed-by: Thomas Hellstr=C3=B6m > cc: Simon Ser > cc: Pekka Paalanen > Cc: Jordan Justen > Cc: Kenneth Graunke > Cc: mesa-dev@lists.freedesktop.org > Cc: Tony Ye > Cc: Slawomir Milczarek > --- > include/uapi/drm/i915_drm.h | 44 ++++++++++++++++++++++++++++++++----- > 1 file changed, 39 insertions(+), 5 deletions(-) > > diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h > index 5e678917da70..77e5e74c32c1 100644 > --- a/include/uapi/drm/i915_drm.h > +++ b/include/uapi/drm/i915_drm.h > @@ -1118,10 +1118,16 @@ struct drm_i915_gem_exec_object2 { > /** > * When the EXEC_OBJECT_PINNED flag is specified this is populated by > * the user with the GTT offset at which this object will be pinned. > + * > * When the I915_EXEC_NO_RELOC flag is specified this must contain the > * presumed_offset of the object. > + * > * During execbuffer2 the kernel populates it with the value of the > * current GTT offset of the object, for future presumed_offset writes. > + * > + * See struct drm_i915_gem_create_ext for the rules when dealing with > + * alignment restrictions with I915_MEMORY_CLASS_DEVICE, on devices with > + * minimum page sizes, like DG2. > */ > __u64 offset; >=20=20 > @@ -3145,11 +3151,39 @@ struct drm_i915_gem_create_ext { > * > * The (page-aligned) allocated size for the object will be returned. > * > - * Note that for some devices we have might have further minimum > - * page-size restrictions(larger than 4K), like for device local-memory. > - * However in general the final size here should always reflect any > - * rounding up, if for example using the I915_GEM_CREATE_EXT_MEMORY_REG= IONS > - * extension to place the object in device local-memory. > + * > + * DG2 64K min page size implications: > + * > + * On discrete platforms, starting from DG2, we have to contend with GTT > + * page size restrictions when dealing with I915_MEMORY_CLASS_DEVICE > + * objects. Specifically the hardware only supports 64K or larger GTT > + * page sizes for such memory. The kernel will already ensure that all > + * I915_MEMORY_CLASS_DEVICE memory is allocated using 64K or larger page > + * sizes underneath. > + * > + * Note that the returned size here will always reflect any required > + * rounding up done by the kernel, i.e 4K will now become 64K on devices > + * such as DG2. > + * > + * Special DG2 GTT address alignment requirement: > + * > + * The GTT alignment will also need to be at least 2M for such objects. > + * > + * Note that due to how the hardware implements 64K GTT page support, we > + * have some further complications: > + * > + * 1) The entire PDE (which covers a 2MB virtual address range), must > + * contain only 64K PTEs, i.e mixing 4K and 64K PTEs in the same > + * PDE is forbidden by the hardware. > + * > + * 2) We still need to support 4K PTEs for I915_MEMORY_CLASS_SYSTEM > + * objects. > + * > + * To keep things simple for userland, we mandate that any GTT mappings > + * must be aligned to and rounded up to 2MB. Could I get a clarification about this "rounded up" part. Currently Mesa is aligning the start of each and every buffer VMA to be 2MiB aligned. But, we are *not* taking any steps to "round up" the size of buffers to 2MiB alignment. Bob's Mesa MR from a while ago, https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14599 was trying to add this "round up" size for buffers. We didn't accept this MR because we thought if we have ensured that no other buffer will use the same 2MiB VMA range, then it should not be required. If what we are doing is ok, then maybe this "round up" language should be dropped? Or, perhaps the "round up" mentioned here isn't implying we must align the size of buffers that we create, and I'm misinterpreting this. -Jordan > As this only wastes virtual > + * address space and avoids userland having to copy any needlessly > + * complicated PDE sharing scheme (coloring) and only affects DG2, this > + * is deemed to be a good compromise. > */ > __u64 size; > /** > --=20 > 2.25.1