From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.0 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 484EBC433DF for ; Mon, 17 Aug 2020 22:57:44 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0FC622063A for ; Mon, 17 Aug 2020 22:57:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="RBrD043H"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="icCuRZwJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0FC622063A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pVzxH+x5u38eTOumYdbi4nufjh8+cpfHFWXCk3LHhLE=; b=RBrD043HU35Ko73LNelKsPOI3 SZVd8ZArIozDbuQ/TSXsMmZ6093efgM58RFkhYZWJDhVIfXvl6bi8IQxViu0qNMpPkiPVnCRR2s6D JeCaflPkcOdmIUwShIiU5eo5wQt1vYJZb9FFzko8BuGUPHcOQIGdSyGftt/jpqVEBqL1HQGe/gpWq gTrQsYBi/xayllaNYWyIqVaxJN7CsnrkqqjwISs3S8ohNHCh7/CI/mnNceAo01KJ3h58bR2GvESpk Mvetyb3hpxHbsXgJhL2f7Y1VTtE1Ambzr9mAg2uEn9r6f5BH97Svo58w/6rcmgiNALitLnALEBbHG ODEVB7Nng==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k7o39-0004fm-7H; Mon, 17 Aug 2020 22:56:19 +0000 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k7o37-0004f0-9n for linux-arm-kernel@lists.infradead.org; Mon, 17 Aug 2020 22:56:18 +0000 Received: by mail-pl1-x644.google.com with SMTP id u10so8286242plr.7 for ; Mon, 17 Aug 2020 15:56:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=u/EbLMfNqW+ecm7P7/+lVeVWoCyaxMA1ruHKaBP8G5U=; b=icCuRZwJpyEhTcs4ikvqOQkHvROTT02PWoLdjFa/HOzrnVkZU4wKLjhaMk2QwVvJ7U lk3Fp/gTh3pu2DtFl/jQGrUwY4obpqee+IiAVBiseYTfmHXpF/rtNXAPR2seeJEW4oDm 83ygyGZTTwRb1elwEL1DBcfsBRpLogJoAs1A/ZVEeNxNT5aOgPbGO9TudnxdRe/7cotA OKJOxkaeekdBKkxgX6mKcuoAmUCNrUmZrugwWf/PcROdFvfbr9fGx42no6wlRy1vVH4P f5TfhOTVuTtkd8O053Dlauq6IgUauPKNXhdRC7nBSxc6ADoyCTKc/rPvkCoxAr7sujN2 s32A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=u/EbLMfNqW+ecm7P7/+lVeVWoCyaxMA1ruHKaBP8G5U=; b=XktrTyTNuqN9n8sLnpcB4qiR2LMatTmUBPCyWhlqI9G7hyGsPobsxJ6uK3VHl4bwn1 3DCCPradg1/xvBA6h8JCQvugwSfwk/Cn5mrsgPPc0Nz3tnYYDLrXzzaW6W2HnUT9104w JEzbMoyFR4ItbddT7pOvaXM4Jw4nhE0mz6BtB9tzZ4Xg4QHbuoGe7kgVy47gil/trCaN mhR50BdttXinPPtWnvx8ehutXw0FLiX8/J+czQm7bsCL6u8TbiYb6OP8SQcB+gvlt8fU UwzHV5yWh8JIG32JOq2UKutly4ELWlGz60cQ9OG7E1w3nzm1I5k7El044jPza2WtL6+8 C+Tg== X-Gm-Message-State: AOAM533eK/3D4h/afsX9fCn6L61Duisx53TuXE4NceaI0/58y9QCxoA7 vczMn+f7JZ0frOB/NenU3OY= X-Google-Smtp-Source: ABdhPJwZOWpNpkc4L+im7w0gYyzBUii1B7VuE8AWuGTbb1fmdzKaKgA2ZF5fn7Pjx0DMkuwkW7f7sA== X-Received: by 2002:a17:90b:384b:: with SMTP id nl11mr14089528pjb.91.1597704971653; Mon, 17 Aug 2020 15:56:11 -0700 (PDT) Received: from taoren-ubuntu-R90MNF91 (c-73-252-146-110.hsd1.ca.comcast.net. [73.252.146.110]) by smtp.gmail.com with ESMTPSA id e142sm8475411pfh.108.2020.08.17.15.56.10 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 17 Aug 2020 15:56:11 -0700 (PDT) Date: Mon, 17 Aug 2020 15:56:04 -0700 From: Tao Ren To: Felipe Balbi Subject: Re: [PATCH] usb: gadget: aspeed: fixup vhub port irq handling Message-ID: <20200817225603.GA21228@taoren-ubuntu-R90MNF91> References: <20200528011154.30355-1-rentao.bupt@gmail.com> <875z9hz8k3.fsf@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <875z9hz8k3.fsf@kernel.org> User-Agent: Mutt/1.9.4 (2018-02-28) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200817_185617_361660_26986D3D X-CRM114-Status: GOOD ( 33.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aspeed@lists.ozlabs.org, taoren@fb.com, Andrew Jeffery , Greg Kroah-Hartman , openbmc@lists.ozlabs.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Stephen Boyd , Joel Stanley , Benjamin Herrenschmidt , Chunfeng Yun , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Aug 17, 2020 at 04:49:32PM +0300, Felipe Balbi wrote: > > Hi, > > rentao.bupt@gmail.com writes: > > From: Tao Ren > > > > This is a follow-on patch for commit a23be4ed8f48 ("usb: gadget: aspeed: > > improve vhub port irq handling"): for_each_set_bit() is replaced with > > simple for() loop because for() loop runs faster on ASPEED BMC. > > > > Signed-off-by: Tao Ren > > --- > > drivers/usb/gadget/udc/aspeed-vhub/core.c | 10 +++------- > > drivers/usb/gadget/udc/aspeed-vhub/vhub.h | 3 +++ > > 2 files changed, 6 insertions(+), 7 deletions(-) > > > > diff --git a/drivers/usb/gadget/udc/aspeed-vhub/core.c b/drivers/usb/gadget/udc/aspeed-vhub/core.c > > index cdf96911e4b1..be7bb64e3594 100644 > > --- a/drivers/usb/gadget/udc/aspeed-vhub/core.c > > +++ b/drivers/usb/gadget/udc/aspeed-vhub/core.c > > @@ -135,13 +135,9 @@ static irqreturn_t ast_vhub_irq(int irq, void *data) > > > > /* Handle device interrupts */ > > 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; > > - > > - for_each_set_bit_from(offset, &bitmap, size) { > > - i = offset - VHUB_IRQ_DEV1_BIT; > > - ast_vhub_dev_irq(&vhub->ports[i].dev); > > + for (i = 0; i < vhub->max_ports; i++) { > > + if (istat & VHUB_DEV_IRQ(i)) > > + ast_vhub_dev_irq(&vhub->ports[i].dev); > > how have you measured your statement above? for_each_set_bit() does > exactly what you did. Unless your architecture has an instruction which > helps finds the next set bit (like cls on ARM), which, then, makes it > much faster. I did some testing and result shows for() loop runs faster than for_each_set_bit() loop. Please refer to details below (discussion with Benjamin in the original patch) and kindly let me know your suggestions. > On Mon, 2020-04-06 at 23:02 -0700, Tao Ren wrote: > > I ran some testing on my ast2400 and ast2500 BMC and looks like the > > for() loop runs faster than for_each_set_bit_from() loop in my > > environment. I'm not sure if something needs to be revised in my test > > code, but please kindly share your suggestions: > > > > I use get_cycles() to calculate execution time of 2 different loops, and > > ast_vhub_dev_irq() is replaced with barrier() to avoid "noise"; below > > are the results: > > > > - when downstream port number is 5 and only 1 irq bit is set, it takes > > ~30 cycles to finish for_each_set_bit() loop, and 20-25 cycles to > > finish the for() loop. > > > > - if downstream port number is 5 and all 5 bits are set, then > > for_each_set_bit() loop takes ~50 cycles and for() loop takes ~25 > > cycles. > > > > - when I increase downsteam port number to 16 and set 1 irq bit, the > > for_each_set_bit() loop takes ~30 cycles and for() loop takes 25 > > cycles. It's a little surprise to me because I thought for() loop > > would cost 60+ cycles (3 times of the value when port number is 5). > > > > - if downstream port number is 16 and all irq status bits are set, > > then for_each_set_bit() loop takes 60-70 cycles and for() loop takes > > 30+ cycles. Cheers, Tao _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel