public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 2/2] firmware: stratix10-svc: fix bug in saving controller data
@ 2023-06-21  2:49 tien.sung.ang
  2023-06-21  5:29 ` Dinh Nguyen
  0 siblings, 1 reply; 2+ messages in thread
From: tien.sung.ang @ 2023-06-21  2:49 UTC (permalink / raw)
  To: Dinh Nguyen; +Cc: linux-kernel, Ang Tien Sung

From: Ang Tien Sung <tien.sung.ang@intel.com>

Fix the incorrect usage of platform_set_drvdata and dev_set_drvdata.
They both are of the same data and overrides each other. This resulted
in the rmmod of the svc driver to fail and throw a kernel panic
for kthread_stop and fifo free.

Fixes: b5dc75c915cd ("firmware: stratix10-svc: extend svc to support new RSU features")

Signed-off-by: Ang Tien Sung <tien.sung.ang@intel.com>
---
 drivers/firmware/stratix10-svc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/firmware/stratix10-svc.c b/drivers/firmware/stratix10-svc.c
index ca713f39107e..60e08987c402 100644
--- a/drivers/firmware/stratix10-svc.c
+++ b/drivers/firmware/stratix10-svc.c
@@ -130,6 +130,7 @@ struct stratix10_svc_data {
  * @complete_status: state for completion
  * @invoke_fn: function to issue secure monitor call or hypervisor call
  * @sdm_lock: a mutex lock to allow only one pending sdm message per client
+ * @svc: manages the list of client svc drivers
  *
  * This struct is used to create communication channels for service clients, to
  * handle secure monitor or hypervisor call.
@@ -144,6 +145,7 @@ struct stratix10_svc_controller {
 	svc_invoke_fn *invoke_fn;
 	/* Enforces atomic command sending to SDM */
 	struct mutex *sdm_lock;
+	struct stratix10_svc *svc;
 };
 
 /**
@@ -1252,6 +1254,7 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)
 		ret = -ENOMEM;
 		goto err_free_kfifo;
 	}
+	controller->svc = svc;
 
 	svc->stratix10_svc_rsu = platform_device_alloc(STRATIX10_RSU, 0);
 	if (!svc->stratix10_svc_rsu) {
@@ -1279,8 +1282,6 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)
 		goto err_unregister_dev;
 	}
 
-	dev_set_drvdata(dev, svc);
-
 	pr_info("Intel Service Layer Driver Initialized\n");
 
 	return 0;
@@ -1296,8 +1297,8 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)
 
 static int stratix10_svc_drv_remove(struct platform_device *pdev)
 {
-	struct stratix10_svc *svc = dev_get_drvdata(&pdev->dev);
 	struct stratix10_svc_controller *ctrl = platform_get_drvdata(pdev);
+	struct stratix10_svc *svc = ctrl->svc;
 
 	platform_device_unregister(svc->intel_svc_fcs);
 	platform_device_unregister(svc->stratix10_svc_rsu);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v1 2/2] firmware: stratix10-svc: fix bug in saving controller data
  2023-06-21  2:49 [PATCH v1 2/2] firmware: stratix10-svc: fix bug in saving controller data tien.sung.ang
@ 2023-06-21  5:29 ` Dinh Nguyen
  0 siblings, 0 replies; 2+ messages in thread
From: Dinh Nguyen @ 2023-06-21  5:29 UTC (permalink / raw)
  To: tien.sung.ang; +Cc: linux-kernel



On 6/20/23 21:49, tien.sung.ang@intel.com wrote:
> From: Ang Tien Sung <tien.sung.ang@intel.com>
> 
> Fix the incorrect usage of platform_set_drvdata and dev_set_drvdata.
> They both are of the same data and overrides each other. This resulted
> in the rmmod of the svc driver to fail and throw a kernel panic
> for kthread_stop and fifo free.
> 
> Fixes: b5dc75c915cd ("firmware: stratix10-svc: extend svc to support new RSU features")
> 

Remove the newline.
> Signed-off-by: Ang Tien Sung <tien.sung.ang@intel.com>
> ---
>   drivers/firmware/stratix10-svc.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/firmware/stratix10-svc.c b/drivers/firmware/stratix10-svc.c
> index ca713f39107e..60e08987c402 100644
> --- a/drivers/firmware/stratix10-svc.c
> +++ b/drivers/firmware/stratix10-svc.c
> @@ -130,6 +130,7 @@ struct stratix10_svc_data {
>    * @complete_status: state for completion
>    * @invoke_fn: function to issue secure monitor call or hypervisor call
>    * @sdm_lock: a mutex lock to allow only one pending sdm message per client
> + * @svc: manages the list of client svc drivers
>    *
>    * This struct is used to create communication channels for service clients, to
>    * handle secure monitor or hypervisor call.
> @@ -144,6 +145,7 @@ struct stratix10_svc_controller {
>   	svc_invoke_fn *invoke_fn;
>   	/* Enforces atomic command sending to SDM */
>   	struct mutex *sdm_lock;
> +	struct stratix10_svc *svc;
>   };
>   
>   /**
> @@ -1252,6 +1254,7 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)
>   		ret = -ENOMEM;
>   		goto err_free_kfifo;
>   	}
> +	controller->svc = svc;
>   
>   	svc->stratix10_svc_rsu = platform_device_alloc(STRATIX10_RSU, 0);
>   	if (!svc->stratix10_svc_rsu) {
> @@ -1279,8 +1282,6 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)
>   		goto err_unregister_dev;
>   	}
>   
> -	dev_set_drvdata(dev, svc);
> -
>   	pr_info("Intel Service Layer Driver Initialized\n");
>   
>   	return 0;
> @@ -1296,8 +1297,8 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)
>   
>   static int stratix10_svc_drv_remove(struct platform_device *pdev)
>   {
> -	struct stratix10_svc *svc = dev_get_drvdata(&pdev->dev);
>   	struct stratix10_svc_controller *ctrl = platform_get_drvdata(pdev);
> +	struct stratix10_svc *svc = ctrl->svc;
>   
>   	platform_device_unregister(svc->intel_svc_fcs);
>   	platform_device_unregister(svc->stratix10_svc_rsu);

Please base this patch first! I'm not sure about your first patch yet.

Thanks,
Dinh

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-21  5:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-21  2:49 [PATCH v1 2/2] firmware: stratix10-svc: fix bug in saving controller data tien.sung.ang
2023-06-21  5:29 ` Dinh Nguyen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox