Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1836650ybh; Sun, 15 Mar 2020 12:15:47 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtCMfhRkLKodCEWQ/zDfMrrLsMxopTuLuFb4MMGik7IGsRf6vTDkBOurfyWAansa2lh3PTk X-Received: by 2002:aca:fcd6:: with SMTP id a205mr15072660oii.28.1584299746972; Sun, 15 Mar 2020 12:15:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584299746; cv=none; d=google.com; s=arc-20160816; b=YN7a6Et/SWyc2AcES4WA1zp7b+c5BnfTqKG9XHN7CrUwrYQRHcRsIRUBYflg6wrWDL gHmnQuYc0b6pFed/O6nsqihuCTFk7cSo2ILHSDlqDyGCBHb11C0SHH1vqFxhFupRPtuf oV+0hRaQlfTI6cE5am08IcVcUYGh9Jojcm+BIj/y4E8UnSLzhPxf7e60YTN4tBpUDEBQ aDVCnbtQUTk0aiu2wWNmtEuoOcjvb5+HlWOotInCkvKreeFywh2bHdP0k1MZV6flWAo1 XF0J5YA8yktqP0ZUYXHHqvkYBdylIHOSQyo6XED0QPqpNicgrhcWjivHLKHIicWNQwpi /3cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=QJPqyWkxe0FvdCujVYrv8IN7juT6CFWXSWYBT76q9+w=; b=G5SJfC0Z3Y6j55vwfORQT+dBBbXkoqhZ8WiJE/F3tfYtsuhRjZfUX7h0oywhrP/OZK p5VBfpHxfVM8uS001PNzrruRxdQY9uVLGqViCIZPwI/SMNQiK7GW1ixQ0BuVOyig5hBH 2waMgvxqR+Sfzrw0kyB05ahJ3yLmXqEWtd4U1nHNyUPPwJQnxkRyxFB02lW02WRIZjG5 jv3ZPIOg8BKr1Ck8tUh8+KsAyIjKKRS7MoTr9/aQ7AmiSkVYuuBsxngZ19FN1akcvQpO ucY23ou52n7ybNGD+ydUhuLXDc3LkU0jh4q1WeepzfZtkeYlUhptFwYPu3A1Ouu4tM96 LHww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sANpO3aj; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a206si7549431oii.132.2020.03.15.12.15.32; Sun, 15 Mar 2020 12:15:46 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sANpO3aj; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728993AbgCOTOk (ORCPT + 99 others); Sun, 15 Mar 2020 15:14:40 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:43532 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728608AbgCOTOk (ORCPT ); Sun, 15 Mar 2020 15:14:40 -0400 Received: by mail-pl1-f193.google.com with SMTP id f8so6887750plt.10; Sun, 15 Mar 2020 12:14:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=QJPqyWkxe0FvdCujVYrv8IN7juT6CFWXSWYBT76q9+w=; b=sANpO3ajZY3xjd0/k5q4rDelXESgjIkMWTO+p4kXH7fYWkGB7cYw4Qk3k1aKpvrfDw LI0ZMEDjgt8aoOkf7GtZkLwFrtingsW+Z0udRO1WLjWzmMp/tNFPv1jp/Or/dUgxo3Ux ikywRVWGd6NDrL+A2btSdotr41flUCEuAHWZE+cF5s6UPI+AZyry5DI01kEK29tFXEvw XS5k0uonygKubgiJR+2ibb/5miv39jalJ5gKmopKknFBrdnDJjp5lc75U+fsdO5UVOzt RAxAF5h5ioz0nhSs0cVRKPjtdNziOkxUd4QtZ9s6TWvlwHeImvMOv4fYRXz2vT1clUaT SuyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=QJPqyWkxe0FvdCujVYrv8IN7juT6CFWXSWYBT76q9+w=; b=UgEJ4saGzMJxtnZkY+DWrcDpxKTNUrpNp8rpro0p3mSZWHnVwMFNcXknbN+jjgF9JV 3BtF+iJohpTwsHfBl2v21sXeiPoi+CpIAI4VcSs1LJy5IZPWzLVTSkE5vpN8HZFGA5Wy 0DOh5Fn0rdP/OxAf/dJfayOeM0gPdBEiNQpuHj/lPV7EB+jc2y0eCAdBls5UsqbedHv6 fuVWgQ8UZR0vqs+kWAH1fXitPmkjH0xeI2WVW/zYLGIlRo8sqlEtbSHqI5Sbb7VHevVA ks6b8PxFHqqNQra9sXITg+9h9ohhVoNT6Ae4YG4NJCCXk3DT+ybT9T/SCl4ePc7shiGA lWEA== X-Gm-Message-State: ANhLgQ2nJRksF5W6W1L/ppBbZdje6TC3OFUBObEYsLBXiaq3uprPgZ3N x+6UxXB6tsNmw96zE8pdsSU= X-Received: by 2002:a17:90a:d081:: with SMTP id k1mr22621148pju.57.1584299678766; Sun, 15 Mar 2020 12:14:38 -0700 (PDT) Received: from taoren-ubuntu-R90MNF91.thefacebook.com (c-24-4-25-55.hsd1.ca.comcast.net. [24.4.25.55]) by smtp.gmail.com with ESMTPSA id z22sm41859247pgn.19.2020.03.15.12.14.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Mar 2020 12:14:37 -0700 (PDT) From: rentao.bupt@gmail.com To: Felipe Balbi , Greg Kroah-Hartman , Joel Stanley , Andrew Jeffery , Benjamin Herrenschmidt , 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 Cc: Tao Ren Subject: [PATCH v3] usb: gadget: aspeed: improve vhub port irq handling Date: Sun, 15 Mar 2020 12:14:30 -0700 Message-Id: <20200315191430.12379-1-rentao.bupt@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 | 8 +++----- 2 files changed, 12 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..555e8645fb1e 100644 --- a/drivers/usb/gadget/udc/aspeed-vhub/core.c +++ b/drivers/usb/gadget/udc/aspeed-vhub/core.c @@ -134,11 +134,15 @@ 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) { + unsigned long bitmap = istat; + 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, &bitmap, size) { + i = offset - VHUB_IRQ_DEV1_BIT; ast_vhub_dev_irq(&vhub->ports[i].dev); + } } /* Handle top-level vHub EP0 interrupts */ @@ -332,6 +336,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; -- 2.17.1