[PATCH 13/13] platform/raspberrypi: vchiq: Register vc-sm-cma as a platform driver

Jai Luthra posted 13 patches 3 months, 1 week ago
There is a newer version of this series
[PATCH 13/13] platform/raspberrypi: vchiq: Register vc-sm-cma as a platform driver
Posted by Jai Luthra 3 months, 1 week ago
From: Dave Stevenson <dave.stevenson@raspberrypi.com>

Register the vc-sm-cma driver as a platform driver under vchiq.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
---
 drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c b/drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c
index 6a7b96d3dae6275a483ef15dc619c5510454765e..09d33bec46ec45175378fff8dd1084d0a8a12dd6 100644
--- a/drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c
+++ b/drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c
@@ -63,6 +63,7 @@
  * the interface.
  */
 static struct vchiq_device *bcm2835_audio;
+static struct vchiq_device *vcsm_cma;
 
 static const struct vchiq_platform_info bcm2835_info = {
 	.cache_line_size = 32,
@@ -1421,6 +1422,7 @@ static int vchiq_probe(struct platform_device *pdev)
 
 	vchiq_debugfs_init(&mgmt->state);
 
+	vcsm_cma = vchiq_device_register(&pdev->dev, "vcsm-cma");
 	bcm2835_audio = vchiq_device_register(&pdev->dev, "bcm2835-audio");
 
 	return 0;
@@ -1431,6 +1433,7 @@ static void vchiq_remove(struct platform_device *pdev)
 	struct vchiq_drv_mgmt *mgmt = dev_get_drvdata(&pdev->dev);
 
 	vchiq_device_unregister(bcm2835_audio);
+	vchiq_device_unregister(vcsm_cma);
 	vchiq_debugfs_deinit();
 	vchiq_deregister_chrdev();
 	vchiq_platform_uninit(mgmt);

-- 
2.51.0
Re: [PATCH 13/13] platform/raspberrypi: vchiq: Register vc-sm-cma as a platform driver
Posted by Krzysztof Kozlowski 3 months, 1 week ago
On 31/10/2025 18:27, Jai Luthra wrote:
> From: Dave Stevenson <dave.stevenson@raspberrypi.com>
> 
> Register the vc-sm-cma driver as a platform driver under vchiq.
> 
> Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
> Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
> ---
>  drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c b/drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c
> index 6a7b96d3dae6275a483ef15dc619c5510454765e..09d33bec46ec45175378fff8dd1084d0a8a12dd6 100644
> --- a/drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c
> +++ b/drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c
> @@ -63,6 +63,7 @@
>   * the interface.
>   */
>  static struct vchiq_device *bcm2835_audio;
> +static struct vchiq_device *vcsm_cma;

Please don't write singletons. How do you handle probe of two devices?

>  
>  static const struct vchiq_platform_info bcm2835_info = {
>  	.cache_line_size = 32,
> @@ -1421,6 +1422,7 @@ static int vchiq_probe(struct platform_device *pdev)


Best regards,
Krzysztof
Re: [PATCH 13/13] platform/raspberrypi: vchiq: Register vc-sm-cma as a platform driver
Posted by Jai Luthra 3 months, 1 week ago
Quoting Krzysztof Kozlowski (2025-11-02 15:03:55)
> On 31/10/2025 18:27, Jai Luthra wrote:
> > From: Dave Stevenson <dave.stevenson@raspberrypi.com>
> > 
> > Register the vc-sm-cma driver as a platform driver under vchiq.
> > 
> > Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
> > Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
> > ---
> >  drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c b/drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c
> > index 6a7b96d3dae6275a483ef15dc619c5510454765e..09d33bec46ec45175378fff8dd1084d0a8a12dd6 100644
> > --- a/drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c
> > +++ b/drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c
> > @@ -63,6 +63,7 @@
> >   * the interface.
> >   */
> >  static struct vchiq_device *bcm2835_audio;
> > +static struct vchiq_device *vcsm_cma;
> 
> Please don't write singletons. How do you handle probe of two devices?

This driver instantiates all the devices under the vchiq bus during its
probe.

The VCHIQ firmware doesn't support device enumeration, hence we have to
list out the supported devices here.

> 
> >  
> >  static const struct vchiq_platform_info bcm2835_info = {
> >       .cache_line_size = 32,
> > @@ -1421,6 +1422,7 @@ static int vchiq_probe(struct platform_device *pdev)
> 
> 
> Best regards,
> Krzysztof

Thanks,
Jai
Re: [PATCH 13/13] platform/raspberrypi: vchiq: Register vc-sm-cma as a platform driver
Posted by Jai Luthra 3 months, 1 week ago
Quoting Jai Luthra (2025-11-03 19:27:41)
> Quoting Krzysztof Kozlowski (2025-11-02 15:03:55)
> > On 31/10/2025 18:27, Jai Luthra wrote:
> > > From: Dave Stevenson <dave.stevenson@raspberrypi.com>
> > > 
> > > Register the vc-sm-cma driver as a platform driver under vchiq.
> > > 
> > > Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
> > > Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
> > > ---
> > >  drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c | 3 +++
> > >  1 file changed, 3 insertions(+)
> > > 
> > > diff --git a/drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c b/drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c
> > > index 6a7b96d3dae6275a483ef15dc619c5510454765e..09d33bec46ec45175378fff8dd1084d0a8a12dd6 100644
> > > --- a/drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c
> > > +++ b/drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c
> > > @@ -63,6 +63,7 @@
> > >   * the interface.
> > >   */
> > >  static struct vchiq_device *bcm2835_audio;
> > > +static struct vchiq_device *vcsm_cma;
> > 
> > Please don't write singletons. How do you handle probe of two devices?
> 
> This driver instantiates all the devices under the vchiq bus during its
> probe.
> 
> The VCHIQ firmware doesn't support device enumeration, hence we have to
> list out the supported devices here.

And as Laurent just pointed out to me, yes these shouldn't be globally
defined singletons.

I'll move them inside struct vchiq_drv_mgmt in v2.

> 
> > 
> > >  
> > >  static const struct vchiq_platform_info bcm2835_info = {
> > >       .cache_line_size = 32,
> > > @@ -1421,6 +1422,7 @@ static int vchiq_probe(struct platform_device *pdev)
> > 
> > 
> > Best regards,
> > Krzysztof
> 
> Thanks,
> Jai
Re: [PATCH 13/13] platform/raspberrypi: vchiq: Register vc-sm-cma as a platform driver
Posted by Krzysztof Kozlowski 3 months, 1 week ago
On 03/11/2025 14:57, Jai Luthra wrote:
> Quoting Krzysztof Kozlowski (2025-11-02 15:03:55)
>> On 31/10/2025 18:27, Jai Luthra wrote:
>>> From: Dave Stevenson <dave.stevenson@raspberrypi.com>
>>>
>>> Register the vc-sm-cma driver as a platform driver under vchiq.
>>>
>>> Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
>>> Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
>>> ---
>>>  drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c | 3 +++
>>>  1 file changed, 3 insertions(+)
>>>
>>> diff --git a/drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c b/drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c
>>> index 6a7b96d3dae6275a483ef15dc619c5510454765e..09d33bec46ec45175378fff8dd1084d0a8a12dd6 100644
>>> --- a/drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c
>>> +++ b/drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c
>>> @@ -63,6 +63,7 @@
>>>   * the interface.
>>>   */
>>>  static struct vchiq_device *bcm2835_audio;
>>> +static struct vchiq_device *vcsm_cma;
>>
>> Please don't write singletons. How do you handle probe of two devices?
> 
> This driver instantiates all the devices under the vchiq bus during its
> probe.
> 
> The VCHIQ firmware doesn't support device enumeration, hence we have to
> list out the supported devices here.


You did not answer the problem. So if you respond like this, then: fine,
instantiate as you wish but since it is in the probe, you still do not
need singleton.

NAK for the singleton pattern.

Best regards,
Krzysztof