Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp28653ybh; Tue, 10 Mar 2020 18:33:39 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuxYE1YRToHaSE9JDyjubtS6nvfYR5fRknWOdhwSrwUbMUMheJmV31/65mxDzwg+dpFVqBQ X-Received: by 2002:a9d:61d6:: with SMTP id h22mr483686otk.6.1583890419392; Tue, 10 Mar 2020 18:33:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583890419; cv=none; d=google.com; s=arc-20160816; b=C+ABrQ+RLVJAtoUWtZuIM45eXoNwDg6jyWGAcMbWUqTHuvC4zyEyup0+o50SX7cD53 oNOxm2pAkzr9vy7VlqWdf61Mi+KHhofQcqf12hhyPNXgXvKvtzhoOzIDm8HCsVwXHEvB amNwjbo0YtdZzw55G5qAaW5D6oWjnzsVMTdgRQYFzRPu5CJpJjGMqouOvfLgJtoGwSr6 PdnALEZjgVPs5rpTxxND9aJvFcqet25UwyeUSmz+ULjCiTSQ4T/RD/DkspT4uA4xpE/8 jd0du76P0ee/Y/s3f8Tt5WEQklQxEGLDJiMtzu4OIxzhOSpTWupvgmsH8lhDYN0cK1e8 47VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:to:from:subject:message-id; bh=u8QK1RaCJOYlimAMmC7+9j3+m+AP7tVpWod1MoKTpI4=; b=r4k52A1av+pxiCelFl3tvdh/YvjcRYYvLXAQgb4h8g1MciWNAGKwBdF8swBrOBD2O7 c7kgchEgRWmqnpSOmTdfstuT4liWDPe9+SPnhHZkLcQjlI0nusS29IyxE/nLYG7N7NQQ m9XErHryYvdnjbfPRE0gI1ofidq0c9EsRUNpvD7RDQRYA5ZUGqrTKGcHLkc6voquRRGO wKWMcX9PKTuOAa3zsUNHoqlTuoKQMRHvVSLsCYY1NDQIsbOrG/q6ib6so0UeZfqQZNxv cwLBEMLSxvLQMqw0T2+tqPk2h7HSCyHDqxxFD3bQlh3LGBwInOPRWtA1TZvZ/T7me8zI mNgw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l23si316192oii.20.2020.03.10.18.33.26; Tue, 10 Mar 2020 18:33:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727837AbgCKBce (ORCPT + 99 others); Tue, 10 Mar 2020 21:32:34 -0400 Received: from kernel.crashing.org ([76.164.61.194]:47064 "EHLO kernel.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727484AbgCKBcd (ORCPT ); Tue, 10 Mar 2020 21:32:33 -0400 Received: from localhost (gate.crashing.org [63.228.1.57]) (authenticated bits=0) by kernel.crashing.org (8.14.7/8.14.7) with ESMTP id 02B1VNCw010399 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 10 Mar 2020 20:31:27 -0500 Message-ID: <481e9b7d40c51505518a34ddc2515d3200dbf158.camel@kernel.crashing.org> Subject: Re: [PATCH v2] usb: gadget: aspeed: improve vhub port irq handling From: Benjamin Herrenschmidt To: rentao.bupt@gmail.com, Felipe Balbi , Greg Kroah-Hartman , Joel Stanley , Andrew Jeffery , Chunfeng Yun , Stephen Boyd , linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, taoren@fb.com Date: Wed, 11 Mar 2020 12:31:22 +1100 In-Reply-To: <20200305234746.1002-1-rentao.bupt@gmail.com> References: <20200305234746.1002-1-rentao.bupt@gmail.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2020-03-05 at 15:47 -0800, rentao.bupt@gmail.com wrote: > From: Tao Ren > > 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 > --- > Changes in v2: > - use "for_each_set_bit" to speed up port irq handling. > > drivers/usb/gadget/udc/aspeed-vhub/core.c | 11 ++++++++--- > drivers/usb/gadget/udc/aspeed-vhub/vhub.h | 8 +++----- > 2 files changed, 11 insertions(+), 8 deletions(-) > > diff --git a/drivers/usb/gadget/udc/aspeed-vhub/core.c b/drivers/usb/gadget/udc/aspeed-vhub/core.c > index f8d35dd60c34..af2dbd405361 100644 > --- a/drivers/usb/gadget/udc/aspeed-vhub/core.c > +++ b/drivers/usb/gadget/udc/aspeed-vhub/core.c > @@ -134,11 +134,14 @@ 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 & vhub->port_irq_mask) { > + int offset = VHUB_IRQ_DEV1_BIT; > + int size = VHUB_IRQ_DEV1_BIT + vhub->max_ports; > > - if (istat & dev_mask) > + for_each_set_bit_from(offset, (unsigned long *)&istat, size) That type cast is very bad. It will not work on big endian for example (yes this driver isn't used on big endian today but still). Please assign istat to an unsigned long (or make it unsigned long to begin with). > + i = offset - VHUB_IRQ_DEV1_BIT; > ast_vhub_dev_irq(&vhub->ports[i].dev); > + } > } > > /* Handle top-level vHub EP0 interrupts */ > @@ -332,6 +335,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..23a1ac91f8d2 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) > @@ -402,6 +399,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;