diff mbox series

[v3] usb: cdns3: gadget.c: Set fast access bit

Message ID 20240424073911.1943-1-r-gunasekaran@ti.com
State Accepted, archived
Commit 83eed2cba32ad8c683bd42e0ad5426589f630bd2
Delegated to: Mattijs Korpershoek
Headers show
Series [v3] usb: cdns3: gadget.c: Set fast access bit | expand

Commit Message

Ravi Gunasekaran April 24, 2024, 7:39 a.m. UTC
From: Aswath Govindraju <a-govindraju@ti.com>

When the device port is in a low power state [U3/L2/Not Connected],
accesses to usb device registers may take a long time. This could lead to
potential core hang when the controller registers are accessed after the
port is disabled by setting DEVDS field. Setting the fast register access
bit ensures that the PHY clock is keeping up in active state.

Therefore, set fast access bit to ensure the accesses to device registers
are quick even in low power states.

commit b5148d946f45 ("usb: cdns3: gadget: set fast access bit") in the
upstream kernel is taken as reference.

Signed-off-by: Aswath Govindraju <a-govindraju@ti.com>
Signed-off-by: Ravi Gunasekaran <r-gunasekaran@ti.com>
Reviewed-by: Roger Quadros <rogerq@kernel.org>
Reviewed-by: Marek Vasut <marex@denx.de>
---
Changes since v2:
----------------
* Updated the commit description with reference to upstream kernel commit
* Picked up Marek's Reviewed-by tag from v2

Changes since v1:
-----------------
* Rebased to tip of -next
* Added Reviewed-by tag

v2: https://lore.kernel.org/all/20240423082420.32336-1-r-gunasekaran@ti.com/
v1: https://lore.kernel.org/u-boot/20230505121353.23486-1-r-gunasekaran@ti.com/

 drivers/usb/cdns3/gadget.c | 4 ++++
 1 file changed, 4 insertions(+)


base-commit: bc39e06778168a34bb4e0a34fbee4edbde4414d8

Comments

Marek Vasut April 24, 2024, 12:15 p.m. UTC | #1
On 4/24/24 9:39 AM, Ravi Gunasekaran wrote:
> From: Aswath Govindraju <a-govindraju@ti.com>
> 
> When the device port is in a low power state [U3/L2/Not Connected],
> accesses to usb device registers may take a long time. This could lead to
> potential core hang when the controller registers are accessed after the
> port is disabled by setting DEVDS field. Setting the fast register access
> bit ensures that the PHY clock is keeping up in active state.
> 
> Therefore, set fast access bit to ensure the accesses to device registers
> are quick even in low power states.
> 
> commit b5148d946f45 ("usb: cdns3: gadget: set fast access bit") in the
> upstream kernel is taken as reference.
> 
> Signed-off-by: Aswath Govindraju <a-govindraju@ti.com>
> Signed-off-by: Ravi Gunasekaran <r-gunasekaran@ti.com>
> Reviewed-by: Roger Quadros <rogerq@kernel.org>
> Reviewed-by: Marek Vasut <marex@denx.de>
> ---
> Changes since v2:
> ----------------
> * Updated the commit description with reference to upstream kernel commit
> * Picked up Marek's Reviewed-by tag from v2
> 
> Changes since v1:
> -----------------
> * Rebased to tip of -next
> * Added Reviewed-by tag
> 
> v2: https://lore.kernel.org/all/20240423082420.32336-1-r-gunasekaran@ti.com/
> v1: https://lore.kernel.org/u-boot/20230505121353.23486-1-r-gunasekaran@ti.com/
> 
>   drivers/usb/cdns3/gadget.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c
> index 7aa0c6b2be..d11175dc5b 100644
> --- a/drivers/usb/cdns3/gadget.c
> +++ b/drivers/usb/cdns3/gadget.c
> @@ -2325,6 +2325,9 @@ static void cdns3_gadget_config(struct cdns3_device *priv_dev)
>   	writel(USB_IEN_INIT, &regs->usb_ien);
>   	writel(USB_CONF_CLK2OFFDS | USB_CONF_L1DS, &regs->usb_conf);
>   
> +	/* Set the Fast access bit */
> +	writel(PUSB_PWR_FST_REG_ACCESS, &priv_dev->regs->usb_pwr);
> +
>   	cdns3_configure_dmult(priv_dev, NULL);
>   
>   	cdns3_gadget_pullup(&priv_dev->gadget, 1);
> @@ -2383,6 +2386,7 @@ static int cdns3_gadget_udc_stop(struct usb_gadget *gadget)
>   
>   	/* disable interrupt for device */
>   	writel(0, &priv_dev->regs->usb_ien);
> +	writel(0, &priv_dev->regs->usb_pwr);
>   	writel(USB_CONF_DEVDS, &priv_dev->regs->usb_conf);
>   
>   	return ret;
> 
> base-commit: bc39e06778168a34bb4e0a34fbee4edbde4414d8

Since this is gadget stuff, +CC Mattijs , that should go through their tree.

Thanks!
Mattijs Korpershoek April 24, 2024, 1:25 p.m. UTC | #2
Hi Ravi,

Thank you for the patch.

On mer., avril 24, 2024 at 14:15, Marek Vasut <marex@denx.de> wrote:

> On 4/24/24 9:39 AM, Ravi Gunasekaran wrote:
>> From: Aswath Govindraju <a-govindraju@ti.com>
>> 
>> When the device port is in a low power state [U3/L2/Not Connected],
>> accesses to usb device registers may take a long time. This could lead to
>> potential core hang when the controller registers are accessed after the
>> port is disabled by setting DEVDS field. Setting the fast register access
>> bit ensures that the PHY clock is keeping up in active state.
>> 
>> Therefore, set fast access bit to ensure the accesses to device registers
>> are quick even in low power states.
>> 
>> commit b5148d946f45 ("usb: cdns3: gadget: set fast access bit") in the
>> upstream kernel is taken as reference.
>> 
>> Signed-off-by: Aswath Govindraju <a-govindraju@ti.com>
>> Signed-off-by: Ravi Gunasekaran <r-gunasekaran@ti.com>
>> Reviewed-by: Roger Quadros <rogerq@kernel.org>
>> Reviewed-by: Marek Vasut <marex@denx.de>
>> ---
>> Changes since v2:
>> ----------------
>> * Updated the commit description with reference to upstream kernel commit
>> * Picked up Marek's Reviewed-by tag from v2
>> 
>> Changes since v1:
>> -----------------
>> * Rebased to tip of -next
>> * Added Reviewed-by tag
>> 
>> v2: https://lore.kernel.org/all/20240423082420.32336-1-r-gunasekaran@ti.com/
>> v1: https://lore.kernel.org/u-boot/20230505121353.23486-1-r-gunasekaran@ti.com/
>> 
>>   drivers/usb/cdns3/gadget.c | 4 ++++
>>   1 file changed, 4 insertions(+)
>> 
>> diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c
>> index 7aa0c6b2be..d11175dc5b 100644
>> --- a/drivers/usb/cdns3/gadget.c
>> +++ b/drivers/usb/cdns3/gadget.c
>> @@ -2325,6 +2325,9 @@ static void cdns3_gadget_config(struct cdns3_device *priv_dev)
>>   	writel(USB_IEN_INIT, &regs->usb_ien);
>>   	writel(USB_CONF_CLK2OFFDS | USB_CONF_L1DS, &regs->usb_conf);
>>   
>> +	/* Set the Fast access bit */
>> +	writel(PUSB_PWR_FST_REG_ACCESS, &priv_dev->regs->usb_pwr);
>> +
>>   	cdns3_configure_dmult(priv_dev, NULL);
>>   
>>   	cdns3_gadget_pullup(&priv_dev->gadget, 1);
>> @@ -2383,6 +2386,7 @@ static int cdns3_gadget_udc_stop(struct usb_gadget *gadget)
>>   
>>   	/* disable interrupt for device */
>>   	writel(0, &priv_dev->regs->usb_ien);
>> +	writel(0, &priv_dev->regs->usb_pwr);
>>   	writel(USB_CONF_DEVDS, &priv_dev->regs->usb_conf);
>>   
>>   	return ret;
>> 
>> base-commit: bc39e06778168a34bb4e0a34fbee4edbde4414d8
>
> Since this is gadget stuff, +CC Mattijs , that should go through their tree.
>
> Thanks!

Thank you Marek for CC'ing me, I missed this patch.

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Mattijs Korpershoek April 25, 2024, 7:50 a.m. UTC | #3
Hi,

On Wed, 24 Apr 2024 13:09:11 +0530, Ravi Gunasekaran wrote:
> When the device port is in a low power state [U3/L2/Not Connected],
> accesses to usb device registers may take a long time. This could lead to
> potential core hang when the controller registers are accessed after the
> port is disabled by setting DEVDS field. Setting the fast register access
> bit ensures that the PHY clock is keeping up in active state.
> 
> Therefore, set fast access bit to ensure the accesses to device registers
> are quick even in low power states.
> 
> [...]

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-dfu (u-boot-dfu)

[1/1] usb: cdns3: gadget.c: Set fast access bit
      https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/3f831439c2dddcb84634195263e619d742e196a3

--
Mattijs
diff mbox series

Patch

diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c
index 7aa0c6b2be..d11175dc5b 100644
--- a/drivers/usb/cdns3/gadget.c
+++ b/drivers/usb/cdns3/gadget.c
@@ -2325,6 +2325,9 @@  static void cdns3_gadget_config(struct cdns3_device *priv_dev)
 	writel(USB_IEN_INIT, &regs->usb_ien);
 	writel(USB_CONF_CLK2OFFDS | USB_CONF_L1DS, &regs->usb_conf);
 
+	/* Set the Fast access bit */
+	writel(PUSB_PWR_FST_REG_ACCESS, &priv_dev->regs->usb_pwr);
+
 	cdns3_configure_dmult(priv_dev, NULL);
 
 	cdns3_gadget_pullup(&priv_dev->gadget, 1);
@@ -2383,6 +2386,7 @@  static int cdns3_gadget_udc_stop(struct usb_gadget *gadget)
 
 	/* disable interrupt for device */
 	writel(0, &priv_dev->regs->usb_ien);
+	writel(0, &priv_dev->regs->usb_pwr);
 	writel(USB_CONF_DEVDS, &priv_dev->regs->usb_conf);
 
 	return ret;