mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Prashanth K <prashanth.k@oss.qualcomm.com>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/3] usb: dwc3: Remove of dep->regs
Date: Fri, 9 Jan 2026 00:53:29 +0000	[thread overview]
Message-ID: <20260109005328.m4llx2okriuhuvo4@synopsys.com> (raw)
In-Reply-To: <20260105115325.1765176-2-prashanth.k@oss.qualcomm.com>

On Mon, Jan 05, 2026, Prashanth K wrote:
> Remove dep->regs from struct dwc3_ep and reuse dwc->regs instead.
> Thus eliminating redundant iomem addresses and making register
> access more consistent across the driver.
> 
> Signed-off-by: Prashanth K <prashanth.k@oss.qualcomm.com>
> ---
>  drivers/usb/dwc3/core.h    | 10 ++++------
>  drivers/usb/dwc3/debugfs.c | 12 ++++--------
>  drivers/usb/dwc3/gadget.c  | 12 ++++++------
>  drivers/usb/dwc3/gadget.h  |  2 +-
>  4 files changed, 15 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
> index a5fc92c4ffa3..23188b910528 100644
> --- a/drivers/usb/dwc3/core.h
> +++ b/drivers/usb/dwc3/core.h
> @@ -165,10 +165,10 @@
>  #define DWC3_DCFG1		0xc740 /* DWC_usb32 only */
>  
>  #define DWC3_DEP_BASE(n)	(0xc800 + ((n) * 0x10))
> -#define DWC3_DEPCMDPAR2		0x00
> -#define DWC3_DEPCMDPAR1		0x04
> -#define DWC3_DEPCMDPAR0		0x08
> -#define DWC3_DEPCMD		0x0c
> +#define DWC3_DEPCMDPAR2(n)	(DWC3_DEP_BASE(n) + 0x00)
> +#define DWC3_DEPCMDPAR1(n)	(DWC3_DEP_BASE(n) + 0x04)
> +#define DWC3_DEPCMDPAR0(n)	(DWC3_DEP_BASE(n) + 0x08)
> +#define DWC3_DEPCMD(n)		(DWC3_DEP_BASE(n) + 0x0c)
>  
>  #define DWC3_DEV_IMOD(n)	(0xca00 + ((n) * 0x4))
>  
> @@ -749,8 +749,6 @@ struct dwc3_ep {
>  	struct list_head	pending_list;
>  	struct list_head	started_list;
>  
> -	void __iomem		*regs;
> -
>  	struct dwc3_trb		*trb_pool;
>  	dma_addr_t		trb_pool_dma;
>  	struct dwc3		*dwc;
> diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c
> index d18bf5e32cc8..0b45ff16f575 100644
> --- a/drivers/usb/dwc3/debugfs.c
> +++ b/drivers/usb/dwc3/debugfs.c
> @@ -36,23 +36,19 @@
>  #define dump_ep_register_set(n)			\
>  	{					\
>  		.name = "DEPCMDPAR2("__stringify(n)")",	\
> -		.offset = DWC3_DEP_BASE(n) +	\
> -			DWC3_DEPCMDPAR2,	\
> +		.offset = DWC3_DEPCMDPAR2(n),	\
>  	},					\
>  	{					\
>  		.name = "DEPCMDPAR1("__stringify(n)")",	\
> -		.offset = DWC3_DEP_BASE(n) +	\
> -			DWC3_DEPCMDPAR1,	\
> +		.offset = DWC3_DEPCMDPAR1(n),	\
>  	},					\
>  	{					\
>  		.name = "DEPCMDPAR0("__stringify(n)")",	\
> -		.offset = DWC3_DEP_BASE(n) +	\
> -			DWC3_DEPCMDPAR0,	\
> +		.offset = DWC3_DEPCMDPAR0(n),	\
>  	},					\
>  	{					\
>  		.name = "DEPCMD("__stringify(n)")",	\
> -		.offset = DWC3_DEP_BASE(n) +	\
> -			DWC3_DEPCMD,		\
> +		.offset = DWC3_DEPCMD(n),		\
>  	}
>  
>  
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index bc3fe31638b9..f08560af1701 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -320,6 +320,7 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned int cmd,
>  
>  	int			cmd_status = 0;
>  	int			ret = -EINVAL;
> +	u8			epnum = dep->number;
>  
>  	/*
>  	 * When operating in USB 2.0 speeds (HS/FS), if GUSB2PHYCFG.ENBLSLPM or
> @@ -355,9 +356,9 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned int cmd,
>  	 * improve performance.
>  	 */
>  	if (DWC3_DEPCMD_CMD(cmd) != DWC3_DEPCMD_UPDATETRANSFER) {
> -		dwc3_writel(dep->regs, DWC3_DEPCMDPAR0, params->param0);
> -		dwc3_writel(dep->regs, DWC3_DEPCMDPAR1, params->param1);
> -		dwc3_writel(dep->regs, DWC3_DEPCMDPAR2, params->param2);
> +		dwc3_writel(dwc->regs, DWC3_DEPCMDPAR0(epnum), params->param0);
> +		dwc3_writel(dwc->regs, DWC3_DEPCMDPAR1(epnum), params->param1);
> +		dwc3_writel(dwc->regs, DWC3_DEPCMDPAR2(epnum), params->param2);
>  	}
>  
>  	/*
> @@ -381,7 +382,7 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned int cmd,
>  	else
>  		cmd |= DWC3_DEPCMD_CMDACT;
>  
> -	dwc3_writel(dep->regs, DWC3_DEPCMD, cmd);
> +	dwc3_writel(dwc->regs, DWC3_DEPCMD(epnum), cmd);
>  
>  	if (!(cmd & DWC3_DEPCMD_CMDACT) ||
>  		(DWC3_DEPCMD_CMD(cmd) == DWC3_DEPCMD_ENDTRANSFER &&
> @@ -391,7 +392,7 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned int cmd,
>  	}
>  
>  	do {
> -		reg = dwc3_readl(dep->regs, DWC3_DEPCMD);
> +		reg = dwc3_readl(dwc->regs, DWC3_DEPCMD(epnum));
>  		if (!(reg & DWC3_DEPCMD_CMDACT)) {
>  			cmd_status = DWC3_DEPCMD_STATUS(reg);
>  
> @@ -3381,7 +3382,6 @@ static int dwc3_gadget_init_endpoint(struct dwc3 *dwc, u8 epnum)
>  	dep->dwc = dwc;
>  	dep->number = epnum;
>  	dep->direction = direction;
> -	dep->regs = dwc->regs + DWC3_DEP_BASE(epnum);
>  	dwc->eps[epnum] = dep;
>  	dep->combo_num = 0;
>  	dep->start_cmd_status = 0;
> diff --git a/drivers/usb/dwc3/gadget.h b/drivers/usb/dwc3/gadget.h
> index d73e735e4081..c3aa9638b7a5 100644
> --- a/drivers/usb/dwc3/gadget.h
> +++ b/drivers/usb/dwc3/gadget.h
> @@ -132,7 +132,7 @@ static inline void dwc3_gadget_ep_get_transfer_index(struct dwc3_ep *dep)
>  {
>  	u32			res_id;
>  
> -	res_id = dwc3_readl(dep->regs, DWC3_DEPCMD);
> +	res_id = dwc3_readl(dep->dwc->regs, DWC3_DEPCMD(dep->number));
>  	dep->resource_index = DWC3_DEPCMD_GET_RSC_IDX(res_id);
>  }
>  
> -- 
> 2.34.1
> 

Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>

Thanks,
Thinh

  reply	other threads:[~2026-01-09  0:53 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-05 11:53 [PATCH v2 0/3] Add the DWC3 instance name in traces Prashanth K
2026-01-05 11:53 ` [PATCH v2 1/3] usb: dwc3: Remove of dep->regs Prashanth K
2026-01-09  0:53   ` Thinh Nguyen [this message]
2026-01-05 11:53 ` [PATCH v2 2/3] usb: dwc3: Add dwc pointer to dwc3_readl/writel Prashanth K
2026-01-09  0:54   ` Thinh Nguyen
2026-01-05 11:53 ` [PATCH v2 3/3] usb: dwc3: Log dwc3 instance name in traces Prashanth K
2026-01-05 12:43   ` Greg Kroah-Hartman
2026-01-06  9:58   ` Greg Kroah-Hartman
2026-01-07  6:03     ` Prashanth K
2026-01-07  6:40       ` Greg Kroah-Hartman
2026-01-07  9:05         ` Prashanth K
2026-01-09  1:18   ` Thinh Nguyen
2026-01-09 10:04     ` Prashanth K
2026-01-13  1:38       ` Thinh Nguyen
2026-01-05 12:44 ` [PATCH v2 0/3] Add the DWC3 " Greg Kroah-Hartman
2026-01-05 16:11   ` Thinh Nguyen
2026-01-05 16:27     ` Greg Kroah-Hartman
2026-01-05 17:01       ` Thinh Nguyen
2026-01-05 19:59         ` Greg Kroah-Hartman
2026-01-05 21:16           ` Thinh Nguyen
2026-01-06  5:50             ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260109005328.m4llx2okriuhuvo4@synopsys.com \
    --to=thinh.nguyen@synopsys.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=prashanth.k@oss.qualcomm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®