lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260109005328.m4llx2okriuhuvo4@synopsys.com>
Date: Fri, 9 Jan 2026 00:53:29 +0000
From: Thinh Nguyen <Thinh.Nguyen@...opsys.com>
To: Prashanth K <prashanth.k@....qualcomm.com>
CC: Thinh Nguyen <Thinh.Nguyen@...opsys.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        "linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 1/3] usb: dwc3: Remove of dep->regs

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@....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@...opsys.com>

Thanks,
Thinh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ