linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [V2][PATCH] drm: xlnx: zynqmp: release reset to DP controller before accessing DP registers
@ 2021-03-23  2:55 quanyang.wang
  2021-03-24  3:13 ` Laurent Pinchart
  0 siblings, 1 reply; 4+ messages in thread
From: quanyang.wang @ 2021-03-23  2:55 UTC (permalink / raw)
  To: Hyun Kwon, Laurent Pinchart, David Airlie, Daniel Vetter, Michal Simek
  Cc: dri-devel, linux-arm-kernel, linux-kernel, Quanyang Wang

From: Quanyang Wang <quanyang.wang@windriver.com>

When insmod zynqmp-dpsub.ko after rmmod it, system will hang with the
error log as below:

root@xilinx-zynqmp:~# insmod zynqmp-dpsub.ko
[   88.391289] [drm] Initialized zynqmp-dpsub 1.0.0 20130509 for fd4a0000.display on minor 0
[   88.529906] Console: switching to colour frame buffer device 128x48
[   88.549402] zynqmp-dpsub fd4a0000.display: [drm] fb0: zynqmp-dpsubdrm frame buffer device
[   88.571624] zynqmp-dpsub fd4a0000.display: ZynqMP DisplayPort Subsystem driver probed
root@xilinx-zynqmp:~# rmmod zynqmp_dpsub
[   94.023404] Console: switching to colour dummy device 80x25
root@xilinx-zynqmp:~# insmod zynqmp-dpsub.ko
	<hang here>

This is because that in zynqmp_dp_probe it tries to access some DP
registers while the DP controller is still in the reset state. When
running "rmmod zynqmp_dpsub", zynqmp_dp_reset(dp, true) in
zynqmp_dp_phy_exit is called to force the DP controller into the reset
state. Then insmod will call zynqmp_dp_probe to program the DP registers,
but at this moment the DP controller hasn't been brought out of the reset
state yet since the function zynqmp_dp_reset(dp, false) is called later and
this will result the system hang.

Releasing the reset to DP controller before any read/write operation to it
will fix this issue. And for symmetry, move zynqmp_dp_reset() call from
zynqmp_dp_phy_exit() to zynqmp_dp_remove().

Signed-off-by: Quanyang Wang <quanyang.wang@windriver.com>
---

V2:
According to Laurent's comments:
- add zynqmp_dp_reset(dp, true) in error path in zynqmp_dp_probe
- move the zynqmp_dp_reset() call from zynqmp_dp_phy_exit() to zynqmp_dp_remove() 

---
 drivers/gpu/drm/xlnx/zynqmp_dp.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp_dp.c
index 99158ee67d02..337adf0769ad 100644
--- a/drivers/gpu/drm/xlnx/zynqmp_dp.c
+++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c
@@ -402,10 +402,6 @@ static int zynqmp_dp_phy_init(struct zynqmp_dp *dp)
 		}
 	}
 
-	ret = zynqmp_dp_reset(dp, false);
-	if (ret < 0)
-		return ret;
-
 	zynqmp_dp_clr(dp, ZYNQMP_DP_PHY_RESET, ZYNQMP_DP_PHY_RESET_ALL_RESET);
 
 	/*
@@ -441,8 +437,6 @@ static void zynqmp_dp_phy_exit(struct zynqmp_dp *dp)
 				ret);
 	}
 
-	zynqmp_dp_reset(dp, true);
-
 	for (i = 0; i < dp->num_lanes; i++) {
 		ret = phy_exit(dp->phy[i]);
 		if (ret)
@@ -1682,9 +1676,13 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub, struct drm_device *drm)
 		return PTR_ERR(dp->reset);
 	}
 
+	ret = zynqmp_dp_reset(dp, false);
+	if (ret < 0)
+		return ret;
+
 	ret = zynqmp_dp_phy_probe(dp);
 	if (ret)
-		return ret;
+		goto err_reset;
 
 	/* Initialize the hardware. */
 	zynqmp_dp_write(dp, ZYNQMP_DP_TX_PHY_POWER_DOWN,
@@ -1696,7 +1694,7 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub, struct drm_device *drm)
 
 	ret = zynqmp_dp_phy_init(dp);
 	if (ret)
-		return ret;
+		goto err_reset;
 
 	zynqmp_dp_write(dp, ZYNQMP_DP_TRANSMITTER_ENABLE, 1);
 
@@ -1708,15 +1706,18 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub, struct drm_device *drm)
 					zynqmp_dp_irq_handler, IRQF_ONESHOT,
 					dev_name(dp->dev), dp);
 	if (ret < 0)
-		goto error;
+		goto err_phy_exit;
 
 	dev_dbg(dp->dev, "ZynqMP DisplayPort Tx probed with %u lanes\n",
 		dp->num_lanes);
 
 	return 0;
 
-error:
+err_phy_exit:
 	zynqmp_dp_phy_exit(dp);
+err_reset:
+	zynqmp_dp_reset(dp, true);
+
 	return ret;
 }
 
@@ -1734,4 +1735,5 @@ void zynqmp_dp_remove(struct zynqmp_dpsub *dpsub)
 	zynqmp_dp_write(dp, ZYNQMP_DP_INT_DS, 0xffffffff);
 
 	zynqmp_dp_phy_exit(dp);
+	zynqmp_dp_reset(dp, true);
 }
-- 
2.25.1


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

* Re: [V2][PATCH] drm: xlnx: zynqmp: release reset to DP controller before accessing DP registers
  2021-03-23  2:55 [V2][PATCH] drm: xlnx: zynqmp: release reset to DP controller before accessing DP registers quanyang.wang
@ 2021-03-24  3:13 ` Laurent Pinchart
  2021-08-06 10:37   ` Michal Simek
  0 siblings, 1 reply; 4+ messages in thread
From: Laurent Pinchart @ 2021-03-24  3:13 UTC (permalink / raw)
  To: quanyang.wang
  Cc: Hyun Kwon, David Airlie, Daniel Vetter, Michal Simek, dri-devel,
	linux-arm-kernel, linux-kernel

Hi Quanyang,

Thank you for the patch.

On Tue, Mar 23, 2021 at 10:55:01AM +0800, quanyang.wang@windriver.com wrote:
> From: Quanyang Wang <quanyang.wang@windriver.com>
> 
> When insmod zynqmp-dpsub.ko after rmmod it, system will hang with the
> error log as below:
> 
> root@xilinx-zynqmp:~# insmod zynqmp-dpsub.ko
> [   88.391289] [drm] Initialized zynqmp-dpsub 1.0.0 20130509 for fd4a0000.display on minor 0
> [   88.529906] Console: switching to colour frame buffer device 128x48
> [   88.549402] zynqmp-dpsub fd4a0000.display: [drm] fb0: zynqmp-dpsubdrm frame buffer device
> [   88.571624] zynqmp-dpsub fd4a0000.display: ZynqMP DisplayPort Subsystem driver probed
> root@xilinx-zynqmp:~# rmmod zynqmp_dpsub
> [   94.023404] Console: switching to colour dummy device 80x25
> root@xilinx-zynqmp:~# insmod zynqmp-dpsub.ko
> 	<hang here>
> 
> This is because that in zynqmp_dp_probe it tries to access some DP
> registers while the DP controller is still in the reset state. When
> running "rmmod zynqmp_dpsub", zynqmp_dp_reset(dp, true) in
> zynqmp_dp_phy_exit is called to force the DP controller into the reset
> state. Then insmod will call zynqmp_dp_probe to program the DP registers,
> but at this moment the DP controller hasn't been brought out of the reset
> state yet since the function zynqmp_dp_reset(dp, false) is called later and
> this will result the system hang.
> 
> Releasing the reset to DP controller before any read/write operation to it
> will fix this issue. And for symmetry, move zynqmp_dp_reset() call from
> zynqmp_dp_phy_exit() to zynqmp_dp_remove().
> 
> Signed-off-by: Quanyang Wang <quanyang.wang@windriver.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
> 
> V2:
> According to Laurent's comments:
> - add zynqmp_dp_reset(dp, true) in error path in zynqmp_dp_probe
> - move the zynqmp_dp_reset() call from zynqmp_dp_phy_exit() to zynqmp_dp_remove() 
> 
> ---
>  drivers/gpu/drm/xlnx/zynqmp_dp.c | 22 ++++++++++++----------
>  1 file changed, 12 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp_dp.c
> index 99158ee67d02..337adf0769ad 100644
> --- a/drivers/gpu/drm/xlnx/zynqmp_dp.c
> +++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c
> @@ -402,10 +402,6 @@ static int zynqmp_dp_phy_init(struct zynqmp_dp *dp)
>  		}
>  	}
>  
> -	ret = zynqmp_dp_reset(dp, false);
> -	if (ret < 0)
> -		return ret;
> -
>  	zynqmp_dp_clr(dp, ZYNQMP_DP_PHY_RESET, ZYNQMP_DP_PHY_RESET_ALL_RESET);
>  
>  	/*
> @@ -441,8 +437,6 @@ static void zynqmp_dp_phy_exit(struct zynqmp_dp *dp)
>  				ret);
>  	}
>  
> -	zynqmp_dp_reset(dp, true);
> -
>  	for (i = 0; i < dp->num_lanes; i++) {
>  		ret = phy_exit(dp->phy[i]);
>  		if (ret)
> @@ -1682,9 +1676,13 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub, struct drm_device *drm)
>  		return PTR_ERR(dp->reset);
>  	}
>  
> +	ret = zynqmp_dp_reset(dp, false);
> +	if (ret < 0)
> +		return ret;
> +
>  	ret = zynqmp_dp_phy_probe(dp);
>  	if (ret)
> -		return ret;
> +		goto err_reset;
>  
>  	/* Initialize the hardware. */
>  	zynqmp_dp_write(dp, ZYNQMP_DP_TX_PHY_POWER_DOWN,
> @@ -1696,7 +1694,7 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub, struct drm_device *drm)
>  
>  	ret = zynqmp_dp_phy_init(dp);
>  	if (ret)
> -		return ret;
> +		goto err_reset;
>  
>  	zynqmp_dp_write(dp, ZYNQMP_DP_TRANSMITTER_ENABLE, 1);
>  
> @@ -1708,15 +1706,18 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub, struct drm_device *drm)
>  					zynqmp_dp_irq_handler, IRQF_ONESHOT,
>  					dev_name(dp->dev), dp);
>  	if (ret < 0)
> -		goto error;
> +		goto err_phy_exit;
>  
>  	dev_dbg(dp->dev, "ZynqMP DisplayPort Tx probed with %u lanes\n",
>  		dp->num_lanes);
>  
>  	return 0;
>  
> -error:
> +err_phy_exit:
>  	zynqmp_dp_phy_exit(dp);
> +err_reset:
> +	zynqmp_dp_reset(dp, true);
> +
>  	return ret;
>  }
>  
> @@ -1734,4 +1735,5 @@ void zynqmp_dp_remove(struct zynqmp_dpsub *dpsub)
>  	zynqmp_dp_write(dp, ZYNQMP_DP_INT_DS, 0xffffffff);
>  
>  	zynqmp_dp_phy_exit(dp);
> +	zynqmp_dp_reset(dp, true);
>  }

-- 
Regards,

Laurent Pinchart

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

* Re: [V2][PATCH] drm: xlnx: zynqmp: release reset to DP controller before accessing DP registers
  2021-03-24  3:13 ` Laurent Pinchart
@ 2021-08-06 10:37   ` Michal Simek
  2021-08-06 10:43     ` Laurent Pinchart
  0 siblings, 1 reply; 4+ messages in thread
From: Michal Simek @ 2021-08-06 10:37 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Quanyang Wang, Hyun Kwon, David Airlie, Daniel Vetter, dri-devel,
	linux-arm, LKML

Hi,

st 24. 3. 2021 v 4:15 odesílatel Laurent Pinchart
<laurent.pinchart@ideasonboard.com> napsal:
>
> Hi Quanyang,
>
> Thank you for the patch.
>
> On Tue, Mar 23, 2021 at 10:55:01AM +0800, quanyang.wang@windriver.com wrote:
> > From: Quanyang Wang <quanyang.wang@windriver.com>
> >
> > When insmod zynqmp-dpsub.ko after rmmod it, system will hang with the
> > error log as below:
> >
> > root@xilinx-zynqmp:~# insmod zynqmp-dpsub.ko
> > [   88.391289] [drm] Initialized zynqmp-dpsub 1.0.0 20130509 for fd4a0000.display on minor 0
> > [   88.529906] Console: switching to colour frame buffer device 128x48
> > [   88.549402] zynqmp-dpsub fd4a0000.display: [drm] fb0: zynqmp-dpsubdrm frame buffer device
> > [   88.571624] zynqmp-dpsub fd4a0000.display: ZynqMP DisplayPort Subsystem driver probed
> > root@xilinx-zynqmp:~# rmmod zynqmp_dpsub
> > [   94.023404] Console: switching to colour dummy device 80x25
> > root@xilinx-zynqmp:~# insmod zynqmp-dpsub.ko
> >       <hang here>
> >
> > This is because that in zynqmp_dp_probe it tries to access some DP
> > registers while the DP controller is still in the reset state. When
> > running "rmmod zynqmp_dpsub", zynqmp_dp_reset(dp, true) in
> > zynqmp_dp_phy_exit is called to force the DP controller into the reset
> > state. Then insmod will call zynqmp_dp_probe to program the DP registers,
> > but at this moment the DP controller hasn't been brought out of the reset
> > state yet since the function zynqmp_dp_reset(dp, false) is called later and
> > this will result the system hang.
> >
> > Releasing the reset to DP controller before any read/write operation to it
> > will fix this issue. And for symmetry, move zynqmp_dp_reset() call from
> > zynqmp_dp_phy_exit() to zynqmp_dp_remove().
> >
> > Signed-off-by: Quanyang Wang <quanyang.wang@windriver.com>
>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Can someone pick this patch?

Thanks,
Michal

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

* Re: [V2][PATCH] drm: xlnx: zynqmp: release reset to DP controller before accessing DP registers
  2021-08-06 10:37   ` Michal Simek
@ 2021-08-06 10:43     ` Laurent Pinchart
  0 siblings, 0 replies; 4+ messages in thread
From: Laurent Pinchart @ 2021-08-06 10:43 UTC (permalink / raw)
  To: Michal Simek
  Cc: Quanyang Wang, Hyun Kwon, David Airlie, Daniel Vetter, dri-devel,
	linux-arm, LKML

Hi Michale,

On Fri, Aug 06, 2021 at 12:37:07PM +0200, Michal Simek wrote:
> st 24. 3. 2021 v 4:15 odesílatel Laurent Pinchart napsal:
> > On Tue, Mar 23, 2021 at 10:55:01AM +0800, quanyang.wang@windriver.com wrote:
> > > From: Quanyang Wang <quanyang.wang@windriver.com>
> > >
> > > When insmod zynqmp-dpsub.ko after rmmod it, system will hang with the
> > > error log as below:
> > >
> > > root@xilinx-zynqmp:~# insmod zynqmp-dpsub.ko
> > > [   88.391289] [drm] Initialized zynqmp-dpsub 1.0.0 20130509 for fd4a0000.display on minor 0
> > > [   88.529906] Console: switching to colour frame buffer device 128x48
> > > [   88.549402] zynqmp-dpsub fd4a0000.display: [drm] fb0: zynqmp-dpsubdrm frame buffer device
> > > [   88.571624] zynqmp-dpsub fd4a0000.display: ZynqMP DisplayPort Subsystem driver probed
> > > root@xilinx-zynqmp:~# rmmod zynqmp_dpsub
> > > [   94.023404] Console: switching to colour dummy device 80x25
> > > root@xilinx-zynqmp:~# insmod zynqmp-dpsub.ko
> > >       <hang here>
> > >
> > > This is because that in zynqmp_dp_probe it tries to access some DP
> > > registers while the DP controller is still in the reset state. When
> > > running "rmmod zynqmp_dpsub", zynqmp_dp_reset(dp, true) in
> > > zynqmp_dp_phy_exit is called to force the DP controller into the reset
> > > state. Then insmod will call zynqmp_dp_probe to program the DP registers,
> > > but at this moment the DP controller hasn't been brought out of the reset
> > > state yet since the function zynqmp_dp_reset(dp, false) is called later and
> > > this will result the system hang.
> > >
> > > Releasing the reset to DP controller before any read/write operation to it
> > > will fix this issue. And for symmetry, move zynqmp_dp_reset() call from
> > > zynqmp_dp_phy_exit() to zynqmp_dp_remove().
> > >
> > > Signed-off-by: Quanyang Wang <quanyang.wang@windriver.com>
> >
> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> Can someone pick this patch?

I have it in my tree with a set of other changes, I intend to send a
pull request today.

-- 
Regards,

Laurent Pinchart

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

end of thread, other threads:[~2021-08-06 10:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-23  2:55 [V2][PATCH] drm: xlnx: zynqmp: release reset to DP controller before accessing DP registers quanyang.wang
2021-03-24  3:13 ` Laurent Pinchart
2021-08-06 10:37   ` Michal Simek
2021-08-06 10:43     ` Laurent Pinchart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).