Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: Javier Martinez Canillas <javierm@redhat.com>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	DRI Development <dri-devel@lists.freedesktop.org>
Cc: Daniel Vetter <daniel.vetter@intel.com>,
	Intel Graphics Development <intel-gfx@lists.freedesktop.org>
Subject: Re: [Intel-gfx] [PATCH 1/8] drm/gma500: Use drm_aperture_remove_conflicting_pci_framebuffers
Date: Thu, 6 Apr 2023 10:49:42 +0200	[thread overview]
Message-ID: <f5f9fe8e-9df2-e201-b7f3-be717fa4bdb8@suse.de> (raw)
In-Reply-To: <87ttxt8kxr.fsf@minerva.mail-host-address-is-not-set>


[-- Attachment #1.1: Type: text/plain, Size: 5827 bytes --]

Hi

Am 06.04.23 um 10:38 schrieb Javier Martinez Canillas:
> Thomas Zimmermann <tzimmermann@suse.de> writes:
> 
> [...]
> 
>> Am 04.04.23 um 22:18 schrieb Daniel Vetter:
>> Gma500 therefore calls both helpers to catch all cases. It's confusing
>> as it implies that there's something about the PCI device that requires
>> ownership management. The relationship between the PCI device and the
>> VGA devices is non-obvious. At worst, readers might assume that calling
>> two functions for aperture clearing ownership is a bug in the driver.
>>
> 
> Yeah, or someone looking as the driver for reference may wrongly think
> that calling both aperture helpers are needed for PCI drivers and that
> is not the case.
> 
>> Hence, move the PCI removal helper's code for VGA functionality into
>> a separate function and call this function from gma500. Documents the
>> purpose of each call to aperture helpers. The change contains comments
>> and example code form the discussion at [1].
>>
>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
>> Link: https://patchwork.kernel.org/project/dri-devel/patch/20230404201842.567344-1-daniel.vetter@ffwll.ch/ # 1
>> ---
> 
> Looks good to me and I agree that it makes the code easier to understand.
> 
> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

Thanks for the review.

> 
> I've a couple of comments below though:
> 
> [...]
> 
>> + * Hardware for gma500 is a hybrid device, which both acts as a PCI
>> + * device (for legacy vga functionality) but also more like an
>> + * integrated display on a SoC where the framebuffer simply
>> + * resides in main memory and not in a special PCI bar (that
>> + * internally redirects to a stolen range of main memory) like all
>> + * other integrated PCI display devices have.
>> + *
> 
> Is "have" the correct word here or "do" ? Or maybe "are implemented" ?

Right. I'll update this.

> 
>> + * To catch all cases we need to remove conflicting firmware devices
>> + * for the stolen system memory and for the VGA functionality. As we
>> + * currently cannot easily find the framebuffer's location in stolen
>> + * memory, we remove all framebuffers here.
>> + *
>> + * TODO: Refactor psb_driver_load() to map vdc_reg earlier. Then
>> + *       we might be able to read the framebuffer range from the
>> + *       device.
>> + */
>> +static int gma_remove_conflicting_framebuffers(struct pci_dev *pdev,
>> +					       const struct drm_driver *req_driver)
>>   {
>> -	struct drm_psb_private *dev_priv;
>> -	struct drm_device *dev;
>> +	resource_size_t base = 0;
>> +	resource_size_t size = PHYS_ADDR_MAX;
>> +	const char *name = req_driver->name;
>>   	int ret;
>>   
>> -	/*
>> -	 * We cannot yet easily find the framebuffer's location in memory. So
>> -	 * remove all framebuffers here. Note that we still want the pci special
>> -	 * handling to kick out vgacon.
>> -	 *
>> -	 * TODO: Refactor psb_driver_load() to map vdc_reg earlier. Then we
>> -	 *       might be able to read the framebuffer range from the device.
>> -	 */
>> -	ret = drm_aperture_remove_framebuffers(&driver);
>> +	ret = aperture_remove_conflicting_devices(base, size, name);
>>   	if (ret)
>>   		return ret;
>>   
>> -	ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &driver);
>> +	return __aperture_remove_legacy_vga_devices(pdev);
> 
> I don't like the __ prefix for this function name, as it usually implies
> that is a function that is only local to the compilation unit. But it is
> an exported symbol from the aperture infrastructure.
> 
> [...]
>    
>> +/**
>> + * __aperture_remove_legacy_vga_devices - remove legacy VGA devices of a PCI devices
>> + * @pdev: PCI device
>> + *
>> + * This function removes VGA devices provided by @pdev, such as a VGA
>> + * framebuffer or a console. This is useful if you have a VGA-compatible
>> + * PCI graphics device with framebuffers in non-BAR locations. Drivers
>> + * should acquire ownership of those memory areas and afterwards call
>> + * this helper to release remaining VGA devices.
>> + *
>> + * If your hardware has its framebuffers accessible via PCI BARS, use
>> + * aperture_remove_conflicting_pci_devices() instead. The function will
>> + * release any VGA devices automatically.
>> + *
>> + * WARNING: Apparently we must remove graphics drivers before calling
>> + *          this helper. Otherwise the vga fbdev driver falls over if
>> + *          we have vgacon configured.
>> + *
>> + * Returns:
>> + * 0 on success, or a negative errno code otherwise
>> + */
>> +int __aperture_remove_legacy_vga_devices(struct pci_dev *pdev)
>> +{
>> +	/* VGA framebuffer */
>> +	aperture_detach_devices(VGA_FB_PHYS_BASE, VGA_FB_PHYS_SIZE);
>> +
>> +	/* VGA textmode console */
>> +	return vga_remove_vgacon(pdev);
>> +}
>> +EXPORT_SYMBOL(__aperture_remove_legacy_vga_devices);
> 
> I would just call this symbol aperture_remove_legacy_vga_devices() as
> mentioned, the fact that aperture_remove_conflicting_pci_devices() use it
> internally is an implementation detail IMO. But it's an exported symbol so
> the naming should be consistent.

That prefix __ is supposed to indicate that it's not a all-in-one 
solution. Most of all, it doesn't do sysfb_disable(). The helper is 
meant to be used as part of a larger function. I tried to outline this 
in the comment, where I say that drivers should first aquire framebuffer 
ownership and then call this helper. If naming isn't a showstopper, I'd 
like to keep the underscores.

Best regards
Thomas

> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

  reply	other threads:[~2023-04-06  8:49 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-04 20:18 [Intel-gfx] [PATCH 1/8] drm/gma500: Use drm_aperture_remove_conflicting_pci_framebuffers Daniel Vetter
2023-04-04 20:18 ` [Intel-gfx] [PATCH 2/8] video/aperture: use generic code to figure out the vga default device Daniel Vetter
2023-04-05 11:27   ` Javier Martinez Canillas
2023-04-04 20:18 ` [Intel-gfx] [PATCH 3/8] drm/aperture: Remove primary argument Daniel Vetter
2023-04-04 21:20   ` Martin Blumenstingl
2023-04-05  9:25   ` Thierry Reding
2023-04-05 11:30   ` Javier Martinez Canillas
2023-04-04 20:18 ` [Intel-gfx] [PATCH 4/8] video/aperture: Only kick vgacon when the pdev is decoding vga Daniel Vetter
2023-04-05 11:31   ` Javier Martinez Canillas
2023-04-04 20:18 ` [Intel-gfx] [PATCH 5/8] video/aperture: Move vga handling to pci function Daniel Vetter
2023-04-05 11:34   ` Javier Martinez Canillas
2023-04-04 20:18 ` [Intel-gfx] [PATCH 6/8] video/aperture: Drop primary argument Daniel Vetter
2023-04-05 11:36   ` Javier Martinez Canillas
2023-04-04 20:18 ` [Intel-gfx] [PATCH 7/8] video/aperture: Only remove sysfb on the default vga pci device Daniel Vetter
2023-04-04 20:59   ` Aaron Plattner
2023-04-05  8:48     ` Daniel Vetter
2023-04-05 11:37   ` Javier Martinez Canillas
2023-04-04 20:18 ` [Intel-gfx] [PATCH 8/8] fbdev: Simplify fb_is_primary_device for x86 Daniel Vetter
2023-04-05 11:40   ` Javier Martinez Canillas
2023-04-04 23:44 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/8] drm/gma500: Use drm_aperture_remove_conflicting_pci_framebuffers Patchwork
2023-04-04 23:44 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2023-04-04 23:51 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2023-04-05  7:49 ` [Intel-gfx] [PATCH 1/8] " Thomas Zimmermann
2023-04-05  8:05   ` Patrik Jakobsson
2023-04-05  8:15     ` Thomas Zimmermann
2023-04-05  8:07   ` Thomas Zimmermann
2023-04-05  8:59     ` Daniel Vetter
2023-04-05  9:26       ` Thomas Zimmermann
2023-04-05  9:38         ` Daniel Vetter
2023-04-05 11:00           ` Thomas Zimmermann
2023-04-05 11:16             ` Javier Martinez Canillas
2023-04-05 13:18               ` Daniel Vetter
2023-04-05 14:32                 ` Thomas Zimmermann
2023-04-05 16:02                   ` Daniel Vetter
2023-04-05 16:54                     ` Javier Martinez Canillas
2023-04-05 17:14                       ` Daniel Vetter
2023-04-05 17:43                         ` Javier Martinez Canillas
2023-04-05 17:46                         ` Patrik Jakobsson
2023-04-06  7:31                           ` Daniel Vetter
2023-04-06 11:16                             ` Patrik Jakobsson
2023-04-05  8:19 ` Thomas Zimmermann
2023-04-05  9:09   ` Daniel Vetter
2023-04-05 10:10 ` [Intel-gfx] ✓ Fi.CI.IGT: success for series starting with [1/8] " Patchwork
2023-04-06  7:14 ` [Intel-gfx] [PATCH 1/8] " Thomas Zimmermann
2023-04-06  8:38   ` Javier Martinez Canillas
2023-04-06  8:49     ` Thomas Zimmermann [this message]
2023-04-06  9:05       ` Javier Martinez Canillas
2023-04-06  9:05 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for series starting with [1/8] drm/gma500: Use drm_aperture_remove_conflicting_pci_framebuffers (rev2) Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f5f9fe8e-9df2-e201-b7f3-be717fa4bdb8@suse.de \
    --to=tzimmermann@suse.de \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=javierm@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox