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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C967BC531DF for ; Tue, 20 Aug 2024 10:46:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5C63910E723; Tue, 20 Aug 2024 10:46:32 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.b="lhHZx2FI"; dkim-atps=neutral X-Greylist: delayed 403 seconds by postgrey-1.36 at gabe; Tue, 20 Aug 2024 10:46:31 UTC Received: from out-187.mta1.migadu.com (out-187.mta1.migadu.com [95.215.58.187]) by gabe.freedesktop.org (Postfix) with ESMTPS id 95F9B10E733 for ; Tue, 20 Aug 2024 10:46:31 +0000 (UTC) Message-ID: <59e832ae-dd0e-4746-ad9c-327b997e992b@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1724150386; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+J6AUM5BA0XHMhLLUg9xC6LMZgDMWJLm3dx3v9LVjJE=; b=lhHZx2FIP/RCUXZs8p29eG005r9RJMGyeMBgQ8ovBQAz2f8rtIT0wFDvnjR2Flagaf9ZGa s29BHqCl/tgoW2VpLdAJfG418mIvnaeszKp4LYCtGHunZrtwlZqsm68QT+G2wpDRaNp9Kx Y282my+JYqtSdE0sex8AwzrnZs2qxl8= Date: Tue, 20 Aug 2024 18:39:29 +0800 MIME-Version: 1.0 Subject: Re: [82/86] drm/i915: Move custom hotplug code into separate callback To: Thomas Zimmermann , daniel@ffwll.ch, airlied@gmail.com, jfalempe@redhat.com, javierm@redhat.com Cc: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, nouveau@lists.freedesktop.org, Jani Nikula , Rodrigo Vivi , Joonas Lahtinen , Tvrtko Ursulin , Lucas De Marchi , =?UTF-8?Q?Thomas_Hellstr=C3=B6m?= References: <20240816125408.310253-83-tzimmermann@suse.de> <86a55d3c-930d-4b30-9f05-82dd2966df85@linux.dev> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Sui Jingfeng In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Hi, On 2024/8/20 15:39, Thomas Zimmermann wrote: > Hi > > Am 19.08.24 um 10:52 schrieb Sui Jingfeng: >> Hi, Thomas >> >> >> I love your patch, yet ... >> >> >> On 2024/8/16 20:23, Thomas Zimmermann wrote: >>> i915's fbdev contains additional code for hotplugging a display that >>> cannot be ported to the common fbdev client. Introduce the callback >>> struct drm_fb_helper.fb_hotplug and implement it for i915. The fbdev >>> helpers invoke the callback before handing the hotplug event. >>> >>> Signed-off-by: Thomas Zimmermann >>> Cc: Jani Nikula >>> Cc: Rodrigo Vivi >>> Cc: Joonas Lahtinen >>> Cc: Tvrtko Ursulin >>> Cc: Lucas De Marchi >>> Cc: "Thomas Hellström" >>> --- >>>   drivers/gpu/drm/drm_fb_helper.c            |  6 +++ >>>   drivers/gpu/drm/i915/display/intel_fbdev.c | 43 >>> ++++++++++++---------- >>>   include/drm/drm_fb_helper.h                | 13 +++++++ >>>   3 files changed, 42 insertions(+), 20 deletions(-) >>> >>> diff --git a/drivers/gpu/drm/drm_fb_helper.c >>> b/drivers/gpu/drm/drm_fb_helper.c >>> index d9e539b0fd1a..92926cb02dfb 100644 >>> --- a/drivers/gpu/drm/drm_fb_helper.c >>> +++ b/drivers/gpu/drm/drm_fb_helper.c >>> @@ -1938,6 +1938,12 @@ int drm_fb_helper_hotplug_event(struct >>> drm_fb_helper *fb_helper) >>>       if (!drm_fbdev_emulation || !fb_helper) >>>           return 0; >>>   +    if (fb_helper->funcs->fb_hotplug) { >> >> We seems need to check the existence on the 'fb_helper->funcs' here, >> >> For example: >> >> >> if (fb_helper->funcs && fb_helper->funcs->fb_hotplug) { >> >> Otherwise, it will de-reference NULL pointer. >> Can be observed on a trivial driver though, >> with no monitor(display) connected. > > Indeed. That needs to be fixed. Thank you for noting. > Thanks for you efforts then. > To give some context:  I was hoping to remove drm_fb_helper_funcs at > some point. Yeah, too many helper functions may make peoples daze. > fb_probe is now gone with these patches and fb_dirty can certainly be > replaced as well. (I once had prototype patches to do that). Well, the grammar of "ret = (*fb_helper->funcs->fb_probe)(fb_helper, &sizes);" looks strange, It's lengthy and I observed you have cleaned it up at the last patch. Which also eliminates one pair "if and else" clause, the codes looks more fluent now. > This leaves the new callbacks for 915, for which I don't have a good > alternative solution. So it seems that drm_fb_helper_funcs will only > be used by i915/xe in the long term. > Well, since it is a DRM client now, maybe we could try to drop it into struct drm_driver. Just like the '.fbdev_probe' callback, this may help to achieve a 100% DRM-based console/logger IMO. Besides, a lot of DRM driver instances has the DMA/2D acceleration hardware, promote it into drm_driver structure may has the potential to utilize hardware acceleration. Drivers will more easily to have custom implementation. I'm not 100% sure if it will only be used by i915 in the future. Best regards, Sui