* [PATCH v4] usb: gadget: aspeed: improve vhub port irq handling
@ 2020-04-09 20:40 rentao.bupt
2020-04-09 22:55 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 2+ messages in thread
From: rentao.bupt @ 2020-04-09 20:40 UTC (permalink / raw)
To: Felipe Balbi, Greg Kroah-Hartman, Joel Stanley, Andrew Jeffery,
Benjamin Herrenschmidt, Chunfeng Yun, Stephen Boyd, linux-usb,
linux-arm-kernel, linux-aspeed, linux-kernel, openbmc, taoren
Cc: Tao Ren
From: Tao Ren <rentao.bupt@gmail.com>
This patch evaluates vhub ports' irq mask before going through per-port
irq handling one by one, which helps to speed up irq handling in case
there is no port interrupt.
Signed-off-by: Tao Ren <rentao.bupt@gmail.com>
---
Changes in v4:
- use simple for() loop as it runs faster than for_each_set_bit()
loop on aspeed BMCs.
Changes in v3:
- assign istat to (unsigned long) bitmap before calling
"for_each_set_bit_from".
Changes in v2:
- use "for_each_set_bit" to speed up port irq handling.
drivers/usb/gadget/udc/aspeed-vhub/core.c | 12 +++++++-----
drivers/usb/gadget/udc/aspeed-vhub/vhub.h | 11 ++++++-----
2 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/drivers/usb/gadget/udc/aspeed-vhub/core.c b/drivers/usb/gadget/udc/aspeed-vhub/core.c
index f8d35dd60c34..fb36bad2c0b7 100644
--- a/drivers/usb/gadget/udc/aspeed-vhub/core.c
+++ b/drivers/usb/gadget/udc/aspeed-vhub/core.c
@@ -134,11 +134,11 @@ static irqreturn_t ast_vhub_irq(int irq, void *data)
}
/* Handle device interrupts */
- for (i = 0; i < vhub->max_ports; i++) {
- u32 dev_mask = VHUB_IRQ_DEVICE1 << i;
-
- if (istat & dev_mask)
- ast_vhub_dev_irq(&vhub->ports[i].dev);
+ if (istat & vhub->port_irq_mask) {
+ for (i = 0; i < vhub->max_ports; i++) {
+ if (istat & VHUB_DEV_IRQ(i))
+ ast_vhub_dev_irq(&vhub->ports[i].dev);
+ }
}
/* Handle top-level vHub EP0 interrupts */
@@ -332,6 +332,8 @@ static int ast_vhub_probe(struct platform_device *pdev)
spin_lock_init(&vhub->lock);
vhub->pdev = pdev;
+ vhub->port_irq_mask = GENMASK(VHUB_IRQ_DEV1_BIT + vhub->max_ports - 1,
+ VHUB_IRQ_DEV1_BIT);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
vhub->regs = devm_ioremap_resource(&pdev->dev, res);
diff --git a/drivers/usb/gadget/udc/aspeed-vhub/vhub.h b/drivers/usb/gadget/udc/aspeed-vhub/vhub.h
index fac79ef6d669..b80e3ddff797 100644
--- a/drivers/usb/gadget/udc/aspeed-vhub/vhub.h
+++ b/drivers/usb/gadget/udc/aspeed-vhub/vhub.h
@@ -51,14 +51,11 @@
#define VHUB_CTRL_UPSTREAM_CONNECT (1 << 0)
/* IER & ISR */
+#define VHUB_IRQ_DEV1_BIT 9
#define VHUB_IRQ_USB_CMD_DEADLOCK (1 << 18)
#define VHUB_IRQ_EP_POOL_NAK (1 << 17)
#define VHUB_IRQ_EP_POOL_ACK_STALL (1 << 16)
-#define VHUB_IRQ_DEVICE5 (1 << 13)
-#define VHUB_IRQ_DEVICE4 (1 << 12)
-#define VHUB_IRQ_DEVICE3 (1 << 11)
-#define VHUB_IRQ_DEVICE2 (1 << 10)
-#define VHUB_IRQ_DEVICE1 (1 << 9)
+#define VHUB_IRQ_DEVICE1 (1 << (VHUB_IRQ_DEV1_BIT))
#define VHUB_IRQ_BUS_RESUME (1 << 8)
#define VHUB_IRQ_BUS_SUSPEND (1 << 7)
#define VHUB_IRQ_BUS_RESET (1 << 6)
@@ -70,6 +67,9 @@
#define VHUB_IRQ_HUB_EP0_SETUP (1 << 0)
#define VHUB_IRQ_ACK_ALL 0x1ff
+/* Downstream device IRQ mask. */
+#define VHUB_DEV_IRQ(n) (VHUB_IRQ_DEVICE1 << (n))
+
/* SW reset reg */
#define VHUB_SW_RESET_EP_POOL (1 << 9)
#define VHUB_SW_RESET_DMA_CONTROLLER (1 << 8)
@@ -402,6 +402,7 @@ struct ast_vhub {
/* Per-port info */
struct ast_vhub_port *ports;
u32 max_ports;
+ u32 port_irq_mask;
/* Generic EP data structures */
struct ast_vhub_ep *epns;
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v4] usb: gadget: aspeed: improve vhub port irq handling
2020-04-09 20:40 [PATCH v4] usb: gadget: aspeed: improve vhub port irq handling rentao.bupt
@ 2020-04-09 22:55 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Herrenschmidt @ 2020-04-09 22:55 UTC (permalink / raw)
To: rentao.bupt, Felipe Balbi, Greg Kroah-Hartman, Joel Stanley,
Andrew Jeffery, Chunfeng Yun, Stephen Boyd, linux-usb,
linux-arm-kernel, linux-aspeed, linux-kernel, openbmc, taoren
On Thu, 2020-04-09 at 13:40 -0700, rentao.bupt@gmail.com wrote:
> From: Tao Ren <rentao.bupt@gmail.com>
>
> This patch evaluates vhub ports' irq mask before going through per-
> port
> irq handling one by one, which helps to speed up irq handling in case
> there is no port interrupt.
>
> Signed-off-by: Tao Ren <rentao.bupt@gmail.com>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
> Changes in v4:
> - use simple for() loop as it runs faster than for_each_set_bit()
> loop on aspeed BMCs.
> Changes in v3:
> - assign istat to (unsigned long) bitmap before calling
> "for_each_set_bit_from".
> Changes in v2:
> - use "for_each_set_bit" to speed up port irq handling.
>
> drivers/usb/gadget/udc/aspeed-vhub/core.c | 12 +++++++-----
> drivers/usb/gadget/udc/aspeed-vhub/vhub.h | 11 ++++++-----
> 2 files changed, 13 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/usb/gadget/udc/aspeed-vhub/core.c
> b/drivers/usb/gadget/udc/aspeed-vhub/core.c
> index f8d35dd60c34..fb36bad2c0b7 100644
> --- a/drivers/usb/gadget/udc/aspeed-vhub/core.c
> +++ b/drivers/usb/gadget/udc/aspeed-vhub/core.c
> @@ -134,11 +134,11 @@ static irqreturn_t ast_vhub_irq(int irq, void
> *data)
> }
>
> /* Handle device interrupts */
> - for (i = 0; i < vhub->max_ports; i++) {
> - u32 dev_mask = VHUB_IRQ_DEVICE1 << i;
> -
> - if (istat & dev_mask)
> - ast_vhub_dev_irq(&vhub->ports[i].dev);
> + if (istat & vhub->port_irq_mask) {
> + for (i = 0; i < vhub->max_ports; i++) {
> + if (istat & VHUB_DEV_IRQ(i))
> + ast_vhub_dev_irq(&vhub->ports[i].dev);
> + }
> }
>
> /* Handle top-level vHub EP0 interrupts */
> @@ -332,6 +332,8 @@ static int ast_vhub_probe(struct platform_device
> *pdev)
>
> spin_lock_init(&vhub->lock);
> vhub->pdev = pdev;
> + vhub->port_irq_mask = GENMASK(VHUB_IRQ_DEV1_BIT + vhub-
> >max_ports - 1,
> + VHUB_IRQ_DEV1_BIT);
>
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> vhub->regs = devm_ioremap_resource(&pdev->dev, res);
> diff --git a/drivers/usb/gadget/udc/aspeed-vhub/vhub.h
> b/drivers/usb/gadget/udc/aspeed-vhub/vhub.h
> index fac79ef6d669..b80e3ddff797 100644
> --- a/drivers/usb/gadget/udc/aspeed-vhub/vhub.h
> +++ b/drivers/usb/gadget/udc/aspeed-vhub/vhub.h
> @@ -51,14 +51,11 @@
> #define VHUB_CTRL_UPSTREAM_CONNECT (1 << 0)
>
> /* IER & ISR */
> +#define VHUB_IRQ_DEV1_BIT 9
> #define VHUB_IRQ_USB_CMD_DEADLOCK (1 << 18)
> #define VHUB_IRQ_EP_POOL_NAK (1 << 17)
> #define VHUB_IRQ_EP_POOL_ACK_STALL (1 << 16)
> -#define VHUB_IRQ_DEVICE5 (1 << 13)
> -#define VHUB_IRQ_DEVICE4 (1 << 12)
> -#define VHUB_IRQ_DEVICE3 (1 << 11)
> -#define VHUB_IRQ_DEVICE2 (1 << 10)
> -#define VHUB_IRQ_DEVICE1 (1 << 9)
> +#define VHUB_IRQ_DEVICE1 (1 <<
> (VHUB_IRQ_DEV1_BIT))
> #define VHUB_IRQ_BUS_RESUME (1 << 8)
> #define VHUB_IRQ_BUS_SUSPEND (1 << 7)
> #define VHUB_IRQ_BUS_RESET (1 << 6)
> @@ -70,6 +67,9 @@
> #define VHUB_IRQ_HUB_EP0_SETUP (1 << 0)
> #define VHUB_IRQ_ACK_ALL 0x1ff
>
> +/* Downstream device IRQ mask. */
> +#define VHUB_DEV_IRQ(n) (VHUB_IRQ_DEVIC
> E1 << (n))
> +
> /* SW reset reg */
> #define VHUB_SW_RESET_EP_POOL (1 << 9)
> #define VHUB_SW_RESET_DMA_CONTROLLER (1 << 8)
> @@ -402,6 +402,7 @@ struct ast_vhub {
> /* Per-port info */
> struct ast_vhub_port *ports;
> u32 max_ports;
> + u32 port_irq_mask;
>
> /* Generic EP data structures */
> struct ast_vhub_ep *epns;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-04-09 22:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-09 20:40 [PATCH v4] usb: gadget: aspeed: improve vhub port irq handling rentao.bupt
2020-04-09 22:55 ` Benjamin Herrenschmidt
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).