Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3057427imm; Mon, 10 Sep 2018 10:18:35 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaFTFKJl6fVvJbRMk8/DHBde/cTJH7JchFHzMuz29t6dRcY9Q/kuZAZhkhmVQa6mC16ZIXx X-Received: by 2002:a63:2906:: with SMTP id p6-v6mr23646168pgp.204.1536599915555; Mon, 10 Sep 2018 10:18:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536599915; cv=none; d=google.com; s=arc-20160816; b=Jj9+SO1AbtVTHs7LaKAKGykkpRGi61rYtjxUKUnqULx6vWl9/ZxBZ4aA87jOIaK9jr 9vT/0g7fWU0vlQPDiiVC9aEcuoEwcLhyVCkwb6drrNZDZ+ZvvSjvQHKoE7e0n26V4ppr XzezK02gp2IGUWcPLlMCdjoRuI4RtPZxQU3RtGISZ2PT4/bR0q4wNlfHG2dWVJumANWP jcmk42ZBedp9MaMwAMVeYp0htH2kUrk9+PHnITnTrRokyeewDyZgcdt6fsAfCktizHp3 YegIm76Vl2b236sf24+ijeVSVwLosCWG7DrqK2LAj2bNlGYmo2aQvJbr4X+RsOjqVjnU oqHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=qVLiwjP9SKl4jZxY2AkSujZSfyE/upl+/yiMB1QzDek=; b=bRhVPp9y/ftebWZdQxifPL2iaRMYqMNtXYmll1nE/3P4oKwGYKzhnDg0kNdTlIZqZe PDkcZ3enNsSVPUhliXfTCretATIelyhUMY1ZmRiCfmhs0ImscgUX5ysizSEIh01zHqte ERBVLTKchuHqZFqV3ej3oFtLPc8LDdfQcCqFq73KgqiI265RTbi2zPB4kA+zlhkB+H02 BQ6dGSGhEIBTqGk7MUbt0aorgWaimew0RmTF97od+oHd3+E4glenYatKOwnXxBZwiKL8 z+qUKFd9kTvOUMiCAOkYjDaCFbpwIvHR6NHcvHG1dE2jC9KVTnBHxZr2xBpiJtioWofW hxEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Kjg3heJs; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x37-v6si19174637pgl.544.2018.09.10.10.18.20; Mon, 10 Sep 2018 10:18:35 -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=@linaro.org header.s=google header.b=Kjg3heJs; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729031AbeIJWMn (ORCPT + 99 others); Mon, 10 Sep 2018 18:12:43 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:33970 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728012AbeIJWMm (ORCPT ); Mon, 10 Sep 2018 18:12:42 -0400 Received: by mail-lf1-f68.google.com with SMTP id c29-v6so18124726lfj.1 for ; Mon, 10 Sep 2018 10:17:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qVLiwjP9SKl4jZxY2AkSujZSfyE/upl+/yiMB1QzDek=; b=Kjg3heJsDeBjKyJbb/2E8J2f+mi8P5trkxnLdx7Zm0BTewIMhEu2DlA4Hkq88qwQ56 uE+zCW3UwvoZ2OlEmMT8JBHG3kOpqwVGy3hz9avfC7dN2zFMDL0pDzijxVTi4oocWf3x +Non2twI3Fv2e/Vwn4kRqwD2IhlpASD1gdJFU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qVLiwjP9SKl4jZxY2AkSujZSfyE/upl+/yiMB1QzDek=; b=n32SsFVQuTTPy3OHFtnkenNmzZeO1zis05UuQa6fFp0QWHhB20i+pLLEdvPXb2MLFb 6QMoqJT1uCFlOWeSgTQcqM0Fm/FG2PmRcRZ0nUmAMzjVhQXVn8B42ob0eHLZYhc9aHaJ 18GGlfHMDsGC1C69ioRgag5hMb4M0Vb9n0n50VWjytsyhp4HhXKjaeFRCZ219hYDVCXn iK6PE6PuYEOGOHuOAaZsioB+sYYOQGh2JliVc3wFBIDgPvN0IOIPdz5o0DUEKBYmlz7d cltBRm2V9ruTUBM89elE84hl4gs0YB7LaCVjCPUJHjwxXCq9Lz+hx/nGeft7/20IoO9k Tnvg== X-Gm-Message-State: APzg51Anrfn9uPj5zzcvfXpLi9jioXEdPspWC3eiJUPLWCXCM6TeZn8M sYW50JhlZ0u+RUQHpq40edXJdCq25uiGmmIE1Zf2PQ== X-Received: by 2002:a19:d38b:: with SMTP id k133-v6mr12949787lfg.43.1536599855689; Mon, 10 Sep 2018 10:17:35 -0700 (PDT) MIME-Version: 1.0 References: <1536142147-21323-1-git-send-email-leo.yan@linaro.org> In-Reply-To: <1536142147-21323-1-git-send-email-leo.yan@linaro.org> From: Mathieu Poirier Date: Mon, 10 Sep 2018 11:17:24 -0600 Message-ID: Subject: Re: [PATCH] coresight: tmc: Refactor loops in etb dump To: Leo Yan Cc: Alexander Shishkin , linux-arm-kernel , Linux Kernel Mailing List , coresight@lists.linaro.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 5 Sep 2018 at 04:09, Leo Yan wrote: > > In ETB dump function tmc_etb_dump_hw() it has nested loops. The second > level loop is to iterate index in the range [0 .. drvdata->memwidth); > but the index isn't really used in the code, thus the second level > loop is useless. > > This patch is to remove the second level loop; the refactor also reduces > indentation and we can use 'break' to replace 'goto' tag. > > Cc: Mathieu Poirier > Signed-off-by: Leo Yan > --- > drivers/hwtracing/coresight/coresight-tmc-etf.c | 17 +++++++---------- > 1 file changed, 7 insertions(+), 10 deletions(-) > > diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c > index 9c599c9..8b34161 100644 > --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c > +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c > @@ -34,23 +34,20 @@ static void tmc_etb_dump_hw(struct tmc_drvdata *drvdata) > { > char *bufp; > u32 read_data, lost; > - int i; > > /* Check if the buffer wrapped around. */ > lost = readl_relaxed(drvdata->base + TMC_STS) & TMC_STS_FULL; > bufp = drvdata->buf; > drvdata->len = 0; > while (1) { > - for (i = 0; i < drvdata->memwidth; i++) { > - read_data = readl_relaxed(drvdata->base + TMC_RRD); > - if (read_data == 0xFFFFFFFF) > - goto done; > - memcpy(bufp, &read_data, 4); > - bufp += 4; > - drvdata->len += 4; > - } > + read_data = readl_relaxed(drvdata->base + TMC_RRD); > + if (read_data == 0xFFFFFFFF) > + break; > + memcpy(bufp, &read_data, 4); > + bufp += 4; > + drvdata->len += 4; I implemented these loops in accordance with the reference manual, which is advising to read one ETB memory word at a time. But taking a step back getting rid of the inner loop yields exactly the same result. So I'll go ahead and apply your patch. Thanks, Mathieu > } > -done: > + > if (lost) > coresight_insert_barrier_packet(drvdata->buf); > return; > -- > 2.7.4 >