Re: [PATCH v2] drm/simpledrm: Add support for multiple "power-domains"

2023-09-18 Thread Neal Gompa
gt; +   return 0;
> +
> +   sdev->pwr_dom_devs = devm_kcalloc(dev, sdev->pwr_dom_count,
> +  sizeof(*sdev->pwr_dom_devs),
> +  GFP_KERNEL);
> +   if (!sdev->pwr_dom_devs)
> +   return -ENOMEM;
> +
> +   sdev->pwr_dom_links = devm_kcalloc(dev, sdev->pwr_dom_count,
> +   sizeof(*sdev->pwr_dom_links),
> +   GFP_KERNEL);
> +   if (!sdev->pwr_dom_links)
> +   return -ENOMEM;
> +
> +   for (i = 0; i < sdev->pwr_dom_count; i++) {
> +   sdev->pwr_dom_devs[i] = dev_pm_domain_attach_by_id(dev, i);
> +   if (IS_ERR(sdev->pwr_dom_devs[i])) {
> +   int ret = PTR_ERR(sdev->pwr_dom_devs[i]);
> +   if (ret == -EPROBE_DEFER) {
> +   simpledrm_device_detach_genpd(sdev);
> +   return ret;
> +   }
> +   drm_warn(>dev,
> +"pm_domain_attach_by_id(%u) failed: %d\n", 
> i, ret);
> +   continue;
> +   }
> +
> +   sdev->pwr_dom_links[i] = device_link_add(dev,
> +
> sdev->pwr_dom_devs[i],
> +DL_FLAG_STATELESS |
> +DL_FLAG_PM_RUNTIME |
> +DL_FLAG_RPM_ACTIVE);
> +   if (!sdev->pwr_dom_links[i])
> +   drm_warn(>dev, "failed to link power-domain 
> %d\n", i);
> +   }
> +
> +   return devm_add_action_or_reset(dev, simpledrm_device_detach_genpd, 
> sdev);
> +}
> +#else
> +static int simpledrm_device_attach_genpd(struct simpledrm_device *sdev)
> +{
> +   return 0;
> +}
> +#endif
> +
>  /*
>   * Modesetting
>   */
> @@ -651,6 +753,9 @@ static struct simpledrm_device 
> *simpledrm_device_create(struct drm_driver *drv,
> if (ret)
> return ERR_PTR(ret);
> ret = simpledrm_device_init_regulators(sdev);
> +   if (ret)
> +   return ERR_PTR(ret);
> +   ret = simpledrm_device_attach_genpd(sdev);
> if (ret)
> return ERR_PTR(ret);
>
>
> ---
> base-commit: 15d30b46573d75f5cb58cfacded8ebab9c76a2b0
> change-id: 20230910-simpledrm-multiple-power-domains-f41efa6ad9bc
>
> Best regards,
> --
> Janne Grunau 
>
>

Reviewed-by: Neal Gompa 


-- 
真実はいつも一つ!/ Always, there's only one truth!


Re: [RFC PATCH] drm/aperture: Add param to disable conflicting framebuffers removal

2021-10-25 Thread Neal Gompa
On Mon, Oct 25, 2021 at 8:28 AM Javier Martinez Canillas
 wrote:
>
> Hello Michel,
>
> On 10/25/21 12:45, Michel Dänzer wrote:
> > On 2021-10-24 22:32, Javier Martinez Canillas wrote:
> >> Hello Ville,
> >>
> >> On 10/22/21 21:12, Ville Syrjälä wrote:
> >>> On Fri, Oct 22, 2021 at 04:40:40PM +0200, Javier Martinez Canillas wrote:
>  The simpledrm driver allows to use the frame buffer that was set-up by 
>  the
>  firmware. This gives early video output before the platform DRM driver is
>  probed and takes over.
> 
>  But it would be useful to have a way to disable this take over by the 
>  real
>  DRM drivers. For example, there may be bugs in the DRM drivers that could
>  cause the display output to not work correctly.
> 
>  For those cases, it would be good to keep the simpledrm driver instead 
>  and
>  at least get a working display as set-up by the firmware.
> 
>  Let's add a drm.remove_fb boolean kernel command line parameter, that 
>  when
>  set to false will prevent the conflicting framebuffers to being removed.
> 
>  Since the drivers call drm_aperture_remove_conflicting_framebuffers() 
>  very
>  early in their probe callback, this will cause the drivers' probe to 
>  fail.
> >>>
> >>> Why is that better than just modprobe.blacklisting those drivers?
> >>
> >> Because would allow to deny list all native (as Thomas called it) DRM 
> >> drivers
> >> and only allow the simpledrm driver to be probed. This is useful for 
> >> distros,
> >> since could add a "Basic graphics mode" to the boot menu entries, that 
> >> could
> >> boot the kernel passing a "drm.disable_native_drivers=1" cmdline option.
> >>
> >> That way, if there's any problem with a given DRM driver, the distro may be
> >> installed and booted using the simpledrm driver and troubleshoot why a 
> >> native
> >> DRM driver is not working. Or try updating the kernel package, etc.
> >
> > For troubleshooting, it'll be helpful if this new parameter can be enabled 
> > for the boot via the kernel command line, then disabled again after 
> > boot-up. One simple possibility for this would be allowing the parameter to 
> > be changed via /sys/module
>
> That's already the case with the current patch, i.e:
>
> $ grep -o drm.* /proc/cmdline
> drm.disable_native_drivers=1
>
> $ cat /proc/fb
> 0 simpledrm
>
> $ modprobe virtio_gpu
>
> $ dmesg
> [  125.731549] [drm] pci: virtio-vga detected at :00:01.0
> [  125.732410] virtio_gpu: probe of virtio0 failed with error -16
>
> $ echo 0 > /sys/module/drm/parameters/disable_native_drivers
>
> $ modprobe virtio_gpu
>
> $ dmesg
> [  187.889136] [drm] pci: virtio-vga detected at :00:01.0
> [  187.894578] Console: switching to colour dummy device 80x25
> [  187.897090] virtio-pci :00:01.0: vgaarb: deactivate vga console
> [  187.899983] [drm] features: -virgl +edid -resource_blob -host_visible
> [  187.907176] [drm] number of scanouts: 1
> [  187.907714] [drm] number of cap sets: 0
> [  187.914108] [drm] Initialized virtio_gpu 0.1.0 0 for virtio0 on minor 1
> [  187.930807] Console: switching to colour frame buffer device 128x48
> [  187.938737] virtio_gpu virtio0: [drm] fb0: virtio_gpu frame buffer device
>
> $ cat /proc/fb
> 0 virtio_gpu
>
> /drm/parameters/, which I suspect doesn't work with the patch as is 
> (due to the 0600 permissions).
> >
> >
>
> I followed the convention used by other drm module parameters, hence the
> 0600. Do you mean that for this parameter we should be less restrictive ?
>

I would think that the 600 permissions would still permit it, since
the root user can still access and manipulate it.


-- 
真実はいつも一つ!/ Always, there's only one truth!


Re: [RFC PATCH] drm/aperture: Add param to disable conflicting framebuffers removal

2021-10-24 Thread Neal Gompa
On Sun, Oct 24, 2021 at 4:40 PM Javier Martinez Canillas
 wrote:
>
> Hello Thomas,
>
> Thanks a lot for your feedback.
>
> On 10/22/21 21:05, Thomas Zimmermann wrote:
>
> > There's still the question of the semantics of this parameter. It's a
> > bit fuzzy.
> >
> > If you use 'disable_handover' (as you mentioned in another mail), it
> > would mean that only the handover itself is disabled. So if simpledrm is
> > not bound to the device, then a native driver should load. That would be
> > hard to implement with the current code base, where we have to take old
> > fbdev drivers into account.
> >
> > (And to be pedantic, we don't really do a handover of the device. We
> > hot-unplug the generic platform device, so that the driver for the
> > native device can operate the HW without interference.)
> >
> > Simpledrm only acquires an aperture, but never removes a driver. If
> > there is a driver already, simpledrm would fail. Only native drivers try > 
> > to remove drivers and would trigger the test. So your patch is more
> > something like 'disable_native_drivers'.
> >
> > I'd go with 'disable_native_drivers', or maybe 'disable_device_handover'
>
> That works for me and "drm.disable_native_drivers" is also what Neal meant
> with his "drm.noplatformdrv", but yours is much easier to remember / type.
>

I'm good with that too. :)

-- 
真実はいつも一つ!/ Always, there's only one truth!


Re: [RFC PATCH] drm/aperture: Add param to disable conflicting framebuffers removal

2021-10-22 Thread Neal Gompa
On Fri, Oct 22, 2021 at 11:16 AM Javier Martinez Canillas
 wrote:
>
> Hello Neal,
>
> Thanks for your feedback.
>
> On 10/22/21 16:56, Neal Gompa wrote:
> > On Fri, Oct 22, 2021 at 10:40 AM Javier Martinez Canillas
> >  wrote:
> >>
> >> The simpledrm driver allows to use the frame buffer that was set-up by the
> >> firmware. This gives early video output before the platform DRM driver is
> >> probed and takes over.
> >>
> >> But it would be useful to have a way to disable this take over by the real
> >> DRM drivers. For example, there may be bugs in the DRM drivers that could
> >> cause the display output to not work correctly.
> >>
> >> For those cases, it would be good to keep the simpledrm driver instead and
> >> at least get a working display as set-up by the firmware.
> >>
> >> Let's add a drm.remove_fb boolean kernel command line parameter, that when
> >> set to false will prevent the conflicting framebuffers to being removed.
> >>
> >> Since the drivers call drm_aperture_remove_conflicting_framebuffers() very
> >> early in their probe callback, this will cause the drivers' probe to fail.
> >>
> >> Thanks to Neal Gompa for the suggestion and Thomas Zimmermann for the idea
> >> on how this could be implemented.
> >>
> >> Suggested-by: Neal Gompa 
> >> Signed-off-by: Javier Martinez Canillas 
> >> ---
> >> Hello,
> >>
> >> I'm sending this as an RFC because I wasn't sure about the correct name for
> >> this module parameter, and also if 'remove_fb=0' is intitutive or instead a
> >> parameter that's enabled is preferred (i.e: 'disable_fb_removal=1').
> >>
> >
> > In general, I think the patch is fine, but it might make sense to name
> > the parameter after the *effect* rather than the *action*. That is,
> > the effect of this option is that we don't probe and hand over to a
> > more appropriate hardware DRM driver.
> >
> > Since the effect (in DRM terms) is that we don't use platform DRM
> > modules, perhaps we could name the option one of these:
> >
> > * drm.noplatformdrv
> > * drm.simpledrv
> > * drm.force_simple
> >
>
> or maybe drm.disable_handover ? Naming is hard...
>

That would make sense for a parameter named by the action. If we want
to go that route, then I'd be fine with that. My goal is to have
something people understand.

> > I'm inclined to say we should use the drm.* namespace for the cmdline
> > option because that makes it clear what subsystem it affects. The
> > legacy "nomodeset" option kind of sucked because it didn't really tell
> > you what that meant, and I'd rather not repeat that mistake.
> >
>
> Yes, agreed. In fact, that is the case for this patch since the param is
> in the drm module. I just forgot to mention the namespace in the last
> paragraph of the comment.
>

Good to know. :)



--
真実はいつも一つ!/ Always, there's only one truth!


Re: [RFC PATCH] drm/aperture: Add param to disable conflicting framebuffers removal

2021-10-22 Thread Neal Gompa
On Fri, Oct 22, 2021 at 10:40 AM Javier Martinez Canillas
 wrote:
>
> The simpledrm driver allows to use the frame buffer that was set-up by the
> firmware. This gives early video output before the platform DRM driver is
> probed and takes over.
>
> But it would be useful to have a way to disable this take over by the real
> DRM drivers. For example, there may be bugs in the DRM drivers that could
> cause the display output to not work correctly.
>
> For those cases, it would be good to keep the simpledrm driver instead and
> at least get a working display as set-up by the firmware.
>
> Let's add a drm.remove_fb boolean kernel command line parameter, that when
> set to false will prevent the conflicting framebuffers to being removed.
>
> Since the drivers call drm_aperture_remove_conflicting_framebuffers() very
> early in their probe callback, this will cause the drivers' probe to fail.
>
> Thanks to Neal Gompa for the suggestion and Thomas Zimmermann for the idea
> on how this could be implemented.
>
> Suggested-by: Neal Gompa 
> Signed-off-by: Javier Martinez Canillas 
> ---
> Hello,
>
> I'm sending this as an RFC because I wasn't sure about the correct name for
> this module parameter, and also if 'remove_fb=0' is intitutive or instead a
> parameter that's enabled is preferred (i.e: 'disable_fb_removal=1').
>

In general, I think the patch is fine, but it might make sense to name
the parameter after the *effect* rather than the *action*. That is,
the effect of this option is that we don't probe and hand over to a
more appropriate hardware DRM driver.

Since the effect (in DRM terms) is that we don't use platform DRM
modules, perhaps we could name the option one of these:

* drm.noplatformdrv
* drm.simpledrv
* drm.force_simple

I'm inclined to say we should use the drm.* namespace for the cmdline
option because that makes it clear what subsystem it affects. The
legacy "nomodeset" option kind of sucked because it didn't really tell
you what that meant, and I'd rather not repeat that mistake.




--
真実はいつも一つ!/ Always, there's only one truth!