From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 555721E4BE for ; Mon, 20 Oct 2025 07:00:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760943651; cv=none; b=VkVpCNjYo+N9MRf8/2dJxxRDqnguubk4GKIfy0H5ZDcxg3g+BRZSTTwPC+jguqWomEb71OnjSIEIDGIZr546wthNFn4iqTOGOK2nEZ4rrUxJvrefGIPuvNviLbP9WPXYHfbpXBcl6aE7+ibc/wL4vlchf5ldV5KL+r3SK8WxHwA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760943651; c=relaxed/simple; bh=kpi9gSPW33GOs+ZDTbmdXRrJwjaNu9+Xv5xJvmUJFJo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=by2vLIO8dC2+2AQL8nevxSA4Xzp4MkhdvPpm5pBxTXaJgx8zwzZVs0Hoqq7Vv8jaOD+ojsbHv5mtCHNZnDCUAOxFR27JZPzsWvWK9y7Caw1D4XQ1xAv23TGPMjmW7G4UZe6S/7ibja3cA8J466JhRoGxc+cfYi2x8AAkpZF+1ys= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=rkXwAe3T; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=7A+RuZvc; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=OZkoA+CB; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=ODrrMHcl; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="rkXwAe3T"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="7A+RuZvc"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="OZkoA+CB"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="ODrrMHcl" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 384532117C; Mon, 20 Oct 2025 07:00:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1760943643; h=from:from:reply-to: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:autocrypt:autocrypt; bh=7u/nHrJ2mX2Cd1dgYXATzcxbVcWbwcMQQpDccfUOgB8=; b=rkXwAe3T0/ZBD06TqEsXwhiREU9boEFCJi5fFV8f+VqmRaDbjJIjSZaZXsvsCnJjLkjSCY LtD20QftQPgPIgJApKzEpYApt8ps6yNr71KQqYntZ8uQIKHn8kEZ6V7Jt+Ojkk9b4nTW+i 5CpnG9wozywH40scjJ2wO26+ObveVBs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1760943643; h=from:from:reply-to: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:autocrypt:autocrypt; bh=7u/nHrJ2mX2Cd1dgYXATzcxbVcWbwcMQQpDccfUOgB8=; b=7A+RuZvcT8/HSxsZIHUXZ/0aRlXDG3s+GxaHKir9qAC7r4AK2g2ESZsAeMW8Nw/WfMAsCd Ddrwyc9vas+6BLBA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1760943639; h=from:from:reply-to: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:autocrypt:autocrypt; bh=7u/nHrJ2mX2Cd1dgYXATzcxbVcWbwcMQQpDccfUOgB8=; b=OZkoA+CBhk64yzuF5GSMYi4zj+ben9RQNB1Z/vwIICX3G80pQZ1NbVN930EWvSgRru24C1 8eVfZn7MCw1KO5hp38JT61+kt9WN4mHVTP0wc026bPrASUTrGADsna7ZfZwQYQNOi3K3Yc +xne64p3UCg0dFCwWhXNuLd3iXP8fYs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1760943639; h=from:from:reply-to: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:autocrypt:autocrypt; bh=7u/nHrJ2mX2Cd1dgYXATzcxbVcWbwcMQQpDccfUOgB8=; b=ODrrMHcloUk39j3/j43IY/7Ws21qrTxMQOuPiUueycz6zbOru4LMHgb+eqhdDns62kfekR lF8ZcF0PtjSvUMCA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 007E513A8E; Mon, 20 Oct 2025 07:00:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id kIJMOhbe9WhmdwAAD6G6ig (envelope-from ); Mon, 20 Oct 2025 07:00:38 +0000 Message-ID: Date: Mon, 20 Oct 2025 09:00:38 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] drm/gud: rearrange gud_probe() to prepare for function splitting To: Ruben Wauters , Maarten Lankhorst , Maxime Ripard , David Airlie , Simona Vetter Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20251019185642.14266-2-rubenru09.ref@aol.com> <20251019185642.14266-2-rubenru09@aol.com> Content-Language: en-US From: Thomas Zimmermann Autocrypt: addr=tzimmermann@suse.de; keydata= xsBNBFs50uABCADEHPidWt974CaxBVbrIBwqcq/WURinJ3+2WlIrKWspiP83vfZKaXhFYsdg XH47fDVbPPj+d6tQrw5lPQCyqjwrCPYnq3WlIBnGPJ4/jreTL6V+qfKRDlGLWFjZcsrPJGE0 BeB5BbqP5erN1qylK9i3gPoQjXGhpBpQYwRrEyQyjuvk+Ev0K1Jc5tVDeJAuau3TGNgah4Yc hdHm3bkPjz9EErV85RwvImQ1dptvx6s7xzwXTgGAsaYZsL8WCwDaTuqFa1d1jjlaxg6+tZsB 9GluwvIhSezPgnEmimZDkGnZRRSFiGP8yjqTjjWuf0bSj5rUnTGiyLyRZRNGcXmu6hjlABEB AAHNJ1Rob21hcyBaaW1tZXJtYW5uIDx0emltbWVybWFubkBzdXNlLmRlPsLAjgQTAQgAOAIb AwULCQgHAgYVCgkICwIEFgIDAQIeAQIXgBYhBHIX+6yM6c9jRKFo5WgNwR1TC3ojBQJftODH AAoJEGgNwR1TC3ojx1wH/0hKGWugiqDgLNXLRD/4TfHBEKmxIrmfu9Z5t7vwUKfwhFL6hqvo lXPJJKQpQ2z8+X2vZm/slsLn7J1yjrOs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Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Level: X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_SEVEN(0.00)[7]; FREEMAIL_TO(0.00)[aol.com,linux.intel.com,kernel.org,gmail.com,ffwll.ch]; RCVD_VIA_SMTP_AUTH(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; ARC_NA(0.00)[]; FREEMAIL_ENVRCPT(0.00)[aol.com,gmail.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; TO_DN_SOME(0.00)[] X-Spam-Flag: NO X-Spam-Score: -4.30 Hi Am 19.10.25 um 20:53 schrieb Ruben Wauters: > gud_prove() is currently very large and does many things, including 'gud_probe' > pipeline setup and feature detection, as well as having USB functions. > > This patch re-orders the code in gud_probe() to make it more organised > and easier to split apart in the future. > > Signed-off-by: Ruben Wauters > --- > I wanted to move mode config to just before pipeline init, however mode > config is edited in feature detection so I was unsure how to go about it > exactly. > Further untangling of this may be required before splitting it out > --- > drivers/gpu/drm/gud/gud_drv.c | 31 +++++++++++++++++-------------- > 1 file changed, 17 insertions(+), 14 deletions(-) > > diff --git a/drivers/gpu/drm/gud/gud_drv.c b/drivers/gpu/drm/gud/gud_drv.c > index b7345c8d823d..583f7f8f4c00 100644 > --- a/drivers/gpu/drm/gud/gud_drv.c > +++ b/drivers/gpu/drm/gud/gud_drv.c > @@ -463,10 +463,6 @@ static int gud_probe(struct usb_interface *intf, const struct usb_device_id *id) > return PTR_ERR(gdrm); > > drm = &gdrm->drm; > - drm->mode_config.funcs = &gud_mode_config_funcs; > - ret = drmm_mode_config_init(drm); > - if (ret) > - return ret; > > gdrm->flags = le32_to_cpu(desc.flags); > gdrm->compression = desc.compression & GUD_COMPRESSION_LZ4; > @@ -483,11 +479,18 @@ static int gud_probe(struct usb_interface *intf, const struct usb_device_id *id) > if (ret) > return ret; > > + /* Mode config init*/ > + ret = drmm_mode_config_init(drm); > + if (ret) > + return ret; > + > drm->mode_config.min_width = le32_to_cpu(desc.min_width); > drm->mode_config.max_width = le32_to_cpu(desc.max_width); > drm->mode_config.min_height = le32_to_cpu(desc.min_height); > drm->mode_config.max_height = le32_to_cpu(desc.max_height); > + drm->mode_config.funcs = &gud_mode_config_funcs; > > + /*Format init*/ > formats_dev = devm_kmalloc(dev, GUD_FORMATS_MAX_NUM, GFP_KERNEL); > /* Add room for emulated XRGB8888 */ > formats = devm_kmalloc_array(dev, GUD_FORMATS_MAX_NUM + 1, sizeof(*formats), GFP_KERNEL); > @@ -587,6 +590,7 @@ static int gud_probe(struct usb_interface *intf, const struct usb_device_id *id) > return -ENOMEM; > } > > + /*Pipeline init*/ > ret = drm_universal_plane_init(drm, &gdrm->plane, 0, > &gud_plane_funcs, > formats, num_formats, > @@ -598,15 +602,6 @@ static int gud_probe(struct usb_interface *intf, const struct usb_device_id *id) > drm_plane_helper_add(&gdrm->plane, &gud_plane_helper_funcs); > drm_plane_enable_fb_damage_clips(&gdrm->plane); > > - devm_kfree(dev, formats); > - devm_kfree(dev, formats_dev); > - > - ret = gud_get_properties(gdrm); > - if (ret) { > - dev_err(dev, "Failed to get properties (error=%d)\n", ret); > - return ret; > - } > - > ret = drm_crtc_init_with_planes(drm, &gdrm->crtc, &gdrm->plane, NULL, > &gud_crtc_funcs, NULL); > if (ret) > @@ -621,6 +616,13 @@ static int gud_probe(struct usb_interface *intf, const struct usb_device_id *id) > } > > drm_mode_config_reset(drm); > + drm_kms_helper_poll_init(drm); > + > + ret = gud_get_properties(gdrm); This function installs plane properties. So it need to be in its old location after drm_universal_plane_init() and before drm_mode_config_reset(). It should be renamed to gud_plane_add_properties(). See [1] for the connector equivalent. [1] https://elixir.bootlin.com/linux/v6.18-rc1/source/drivers/gpu/drm/gud/gud_connector.c#L474 > + if (ret) { > + dev_err(dev, "Failed to get properties (error=%d)\n", ret); > + return ret; > + } > > usb_set_intfdata(intf, gdrm); After you've called drm_kms_helper_poll_init(), DRM could query the connector for attached displays at any time. This might require the usb interface to point to the gud device. And the DRM driver also needs to know about the DMA device.  I quick look through the driver code suggest that it works without, but better not count on it. Best would be to move this line and the block with the DMA setup [2] just after where the gud device got allocated with devmdrm_dev_alloc(). [3] [2] https://elixir.bootlin.com/linux/v6.18-rc1/source/drivers/gpu/drm/gud/gud_drv.c#L627 [3] https://elixir.bootlin.com/linux/v6.18-rc1/source/drivers/gpu/drm/gud/gud_drv.c#L464 Best regards Thomas > > @@ -638,7 +640,8 @@ static int gud_probe(struct usb_interface *intf, const struct usb_device_id *id) > if (ret) > return ret; > > - drm_kms_helper_poll_init(drm); > + devm_kfree(dev, formats); > + devm_kfree(dev, formats_dev); > > drm_client_setup(drm, NULL); > -- -- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)