Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp6217671ybf; Thu, 5 Mar 2020 15:49:53 -0800 (PST) X-Google-Smtp-Source: ADFU+vvUt7TGZtneS7/AaKe1oBagdtiwo7il4mPQKA6BhRj8RFm2/WjVJxIT/ctQCwsYGFcIgb4Q X-Received: by 2002:a05:6808:9ba:: with SMTP id e26mr682778oig.156.1583452192952; Thu, 05 Mar 2020 15:49:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583452192; cv=none; d=google.com; s=arc-20160816; b=HrpDKh5r0oYxU+qDBumaoBb7ovY8Murza9Sb87lWMxYveLHSfEY1Yl9rSymIFrASq6 WyoX9SX52uucZ5z7SvB/SSdM2u2o2c8XB0lyiuHxIhglufYgfUX+Qv9FrSv+fVLMNMtY MjMUE7qHit0nl8vQOsVRkdkXpDroYxhdQQVuPptCfea4bM+2zi7rKdH+OXRTRIe/MLyx OYpI3ZXjIhG4YGTmpChhllf9CFU1vhkj8ch8KunUDd3hUHfkV43D3fMRHvBiwZfOr+64 vD+ReTbS6ehYKB9auc5yq2KIqeSSGAQxiFpd86X0J5Pvh1297sX1ifPcB0qh/gWeENrF BQTA== 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=z2HXeME5Gk76DY5Zvh5p+H88p8YEhHXH5Ad0akNZ4Go=; b=lWCjW8GEmqOC4d9dg5VR8yTSNnSOMqGYVoPlqxaVi49zODE03dZW/4Bv/wSwppaX8r metFLgK+fBeJT3LrPndIxn/LNCAR/WQcoRVC9Rs+Do4+QtmSom6y4qzH2nN8guDOkJxP X/FDMc1xPMVG5fW1KAMeisMhEHrwwy4DXer5Zojk4aODDNFm/BUhKlZg+Xdt9X+th5BZ S5y3WNfkrHH9pRrN+0pk1yfajfefZQbJNuxeD8AGPudzmHmgoYXPrtsZxfBqRJOjUUox t25ibJQP/LSLg2UHmoCXeCpnxhYRyJ/YtQJ0vCRf1uY4ucsf2wHMYgNIjj1S88jmE7m/ bhkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=i7M9+ENa; 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 t26si258405otc.205.2020.03.05.15.49.40; Thu, 05 Mar 2020 15:49:52 -0800 (PST) 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=i7M9+ENa; 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 S1726259AbgCEXr6 (ORCPT + 99 others); Thu, 5 Mar 2020 18:47:58 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:39656 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726128AbgCEXr5 (ORCPT ); Thu, 5 Mar 2020 18:47:57 -0500 Received: by mail-pg1-f193.google.com with SMTP id s2so186602pgv.6; Thu, 05 Mar 2020 15:47:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=z2HXeME5Gk76DY5Zvh5p+H88p8YEhHXH5Ad0akNZ4Go=; b=i7M9+ENaqIDSGbdccu/70MshUdaM1GY6nsyiIOXyVdqlfp9GO06/CNeuQdJClQ1T6f 5jbaLtuZpia8nMNur+hSQ6ow4hDRQwvgoF8qc+Bryi/Nr/upfoM54W3KzGR8ZN2FOYgk xnljo4UgHyDYzQCkhGO1LwezK5GZxjQFAVX3QIHKHV4wh/fHQwalTOOQ/1fAL2SanSNb uIr/xP/KzI6mZdLcbL0ZrG9k0V9AYHqlu8Z+DKlKQL3hl5CWc7XpM8Jr9lx4ag8HIlt4 lg/fRzNEcVzS6qC+h49hpllj4NQJ8xACHPV3OeRjR+OQV0sG1lzyONqNqt24oNq3sVe+ podA== 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=z2HXeME5Gk76DY5Zvh5p+H88p8YEhHXH5Ad0akNZ4Go=; b=P6cvc0hOtajfrUKYGk5vTkl/G/FnCMI53gLVx+P682v0f3kjLDE88QwXCGPf25rrX7 EpRoaQGTNJBRJojphBIZrPvCwqXVIlUK6wjMqyV0Lo/p0JkmRZZHGtxZilutYFZIlOSa IEyBhCL04JlaezjoTwJ/GP3UVMrSsRt4Y1Yj6m+leVlsZs3T+H/Y8RLoBAII43WgaAFb wbiR2F7U3GRSq5rVsn1pREvsaeRnf/XnTLyV8AA4ftA+s3tu5luVpslV2G7FZ5+Kbd3x 8zCuRVkF6NdVYmZQaBWxaE+m2c3h17AdS9kijyj6aodBg94KT4z+co+LBTOH/o+VNFeO PsxQ== X-Gm-Message-State: ANhLgQ2Qc17PCwEdegeSG87xUKQhXdyBoh0LaqKGTUsoR+6WAltQpRAs LgWEJ/z1F3Di0100Jue9fkY= X-Received: by 2002:a63:8042:: with SMTP id j63mr581107pgd.224.1583452074966; Thu, 05 Mar 2020 15:47:54 -0800 (PST) Received: from taoren-ubuntu-R90MNF91.thefacebook.com ([2620:10d:c090:500::5:788]) by smtp.gmail.com with ESMTPSA id s21sm4490620pfd.99.2020.03.05.15.47.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Mar 2020 15:47:54 -0800 (PST) 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 v2] usb: gadget: aspeed: improve vhub port irq handling Date: Thu, 5 Mar 2020 15:47:46 -0800 Message-Id: <20200305234746.1002-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 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) { + 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; -- 2.17.1