Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1195142pxb; Fri, 21 Jan 2022 12:00:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJyQqlSDmatyXXl6uDbIZYZvpOxhC04YmRArG2kHhohMFdINACSklrHZZIGrcd27JlZMp6xo X-Received: by 2002:a17:903:32d2:b0:14b:612:7fae with SMTP id i18-20020a17090332d200b0014b06127faemr5357264plr.80.1642795229967; Fri, 21 Jan 2022 12:00:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642795229; cv=none; d=google.com; s=arc-20160816; b=k819dsXj8PGBWseLfO0HV5U4kIqbnnsTbCt6MUTMZcdzpS/HuGfpf/XQg/j3645wLA Tmaz7XTuMAt562OLYF6HLlGJ4E+tpyg2CuPlYiKGYieNGBvGAQigh9oWA7l3VSN1diih hFL8JE2PL7ASsPl3/AFOkhIHAO9r/ylb9vqGe48dQKaFU5L2R/5Avoee8hBX3AsjX0KM 0bZNGNNwc+8WKPi/gfGHBOywcKv4fOlfEVG3aI22ABbDMRwsMiZg9SCdzkoZn+/lg6W5 oVXdTSAO3VAagpH8NrQunkHCJs/uFq2QSxmInxrmhEv9CNM/vDdJwnOIrofQnbG+L/cH y6LQ== 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:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=VA7zRg8dEkpTWP6FBFqfJzZvnWPPi5YNhiDDg1DAbso=; b=GrBwtcDYQZlqRdLPtiOspYJ6brQ9hD8gLHmQL27eV/JQ/EJo9rhDQnlVqSbr7IVdgu MKyovj0L+I1N2EgyngdDSyk6QhO9BeYTJVyFPBt3FpgnBdB7FExYqaOCzKZYy7Vvsg8G 5iCIcSVkJpS4zrANVrHPPJSz3J1koIWyn1vWgN0amTKHhG+AK6+qfNA+nn0umJG0k9mb +XMN+dN26+CpucxWxEDnlNSic2x3BzIHlggg2WjGqh3od7bM6Zhe2mRHfD699Es35HQJ 2it6cZ7o9KRABtIFjBtcSjIspUi3hZhnaKf9ZQTj6pQeamll1jGlbxs/7jpzhbzoghrR BVLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=NNcsmrQb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lw16si14873991pjb.158.2022.01.21.12.00.17; Fri, 21 Jan 2022 12:00:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=NNcsmrQb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357163AbiASTtO (ORCPT + 99 others); Wed, 19 Jan 2022 14:49:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230233AbiASTtN (ORCPT ); Wed, 19 Jan 2022 14:49:13 -0500 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 359C8C061574 for ; Wed, 19 Jan 2022 11:49:13 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: bbeckett) with ESMTPSA id EAFFE1F446F5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1642621751; bh=UIoafffS0/l3S1GB6KgQfq7k8XDj/WzZMnJi03jT+4w=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=NNcsmrQbUywS/Hicnx0DJF53N17Jr42HJKPIKGUJaxLaQTDR+kveaR+cFJf+fyfwu GMMAvv48j6+f2ZWTFED+g0ojdxBaXlOW8je2j2TQ1btl2H7c7kOhH7MTPs0+oJUxNe VMB8fv4YSY7acGIBIlEsEKeTVu4/kj5E1/QCWENbP/syauBoeVGSh0Bqti9t6vEzoi RwdnwaT3pL8jQEP8cZNjJRRVSRX6gVa9O2W2eegsEALXmPVxUyYqL66kgqm+KPE5f/ QBtS3Nlvh6LqNmT7MNOB93OfVwHlr0lBZBcj49BeEuLuZwcxPu3Do5qhXcfZ/pRawh lRJA+NW1EyX0g== Message-ID: Date: Wed, 19 Jan 2022 19:49:08 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.1 Subject: Re: [PATCH v2 4/4] drm/i915/uapi: document behaviour for DG2 64K support Content-Language: en-US To: Jordan Justen , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter Cc: Matthew Auld , Ramalingam C , 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 References: <20220118175036.3840934-1-bob.beckett@collabora.com> <20220118175036.3840934-5-bob.beckett@collabora.com> <87zgnrefoo.fsf@jljusten-skl> From: Robert Beckett In-Reply-To: <87zgnrefoo.fsf@jljusten-skl> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 19/01/2022 18:36, Jordan Justen wrote: > 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. >> >> v2: Fixed suggestions on formatting [Daniel] >> >> Signed-off-by: Matthew Auld >> Signed-off-by: Ramalingam C >> Signed-off-by: Robert Beckett >> 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..486b7b96291e 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; >> >> @@ -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_REGIONS >> - * extension to place the object in device local-memory. >> + * >> + * **DG2 64K min page size implications:** > > Long term, I'm not sure that the "**" (for emphasis) is needed here or > below. It's interesting at the moment, but will be just another thing > baked into the kernel/user code in a month from now. :) fair point, I'll make it less shouty > >> + * >> + * 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 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. As this only wastes virtual >> + * address space and avoids userland having to copy any needlessly >> + * complicated PDE sharing scheme (coloring) and only affects GD2, this >> + * id deemed to be a good compromise. > > typos: GD2, id thanks > > Isn't much of this more relavent to the vma offset at exec time? Is > there actually any new restriction on the size field during buffer > creation? No new restriction on size, just placement, which mesa is already doing. The request for ack was just to get an ack from mesa folks that they are happy with the mandatory 2MB alignment for DG2 vma. > > I see Matthew references these notes from the offset comments, so if the > kernel devs prefer it here, then you can add my Acked-by on this patch. thanks! > > -Jordan > >> */ >> __u64 size; >> /** >> -- >> 2.25.1