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=-7.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no 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 DF23BC4363C for ; Mon, 21 Sep 2020 21:11:26 +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 75C2323A1D for ; Mon, 21 Sep 2020 21:11:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="dUAeBHhL"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="b3FZ7RTI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 75C2323A1D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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=Z8qX/Pkw0LR5njV2pX/3kunsYVdpcgtbVpWaxHFfNA8=; b=dUAeBHhLAbnkS52JTs4xE3tCo UP0MQjs7cLDP66PhQhlkon/4FS0l+TKEm6107OGUHG/8CDqlkjrGS5kS4T48i0/m9w6UvBw75+Dyz YEpr4BXdYotnrdwQzxALexmtUrEgJfFoDDGs93losObnxyDwx2t7RN99iXKAuKTMMGxvO3g0q5kaL NdH1SYQ9l26m3ViVWePJnRBoO90P/fYWQaTUrQt7wA3mnW4abzjc0bv0P9+qVXsXSTsEFxRLlMK+Z vu8oPXoEDPVcwOrejLkMDuEUxqaBF1mvJUVs3O3uM5QXqPvU9A40azJ+rd+W8rag2E6jZZWSwRW+s pcztWokoA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKT45-0006gO-5F; Mon, 21 Sep 2020 21:09:37 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKSrg-0008Ne-64 for linux-arm-kernel@lists.infradead.org; Mon, 21 Sep 2020 20:56:49 +0000 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C1FE823A5D; Mon, 21 Sep 2020 20:56:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600721806; bh=6GNNu54QdpsGtpmS9z89CwJPWx8RiSsj5vCUlmHaDpw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=b3FZ7RTItTHJTWD6Z4FML01Sc706qAUvRbEqLLDFs68nVailpm/jwa11naeUQnU44 SAFlvFIqD8nG3hWx+tpvLw7vbWe5I9z4XFP0rNyN2Ud+pEIB9nAX+XAFI6Zo5bLBhZ BI2jUXAaKgJm57GWWnskjMrHOBjB+clpSZJj23sU= Date: Mon, 21 Sep 2020 21:56:42 +0100 From: Will Deacon To: Joakim Zhang Subject: Re: [PATCH V2] perf/imx_ddr: Add stop event counters support for i.MX8MP Message-ID: <20200921205642.GC3811@willie-the-truck> References: <1599562054-1930-1-git-send-email-qiangqing.zhang@nxp.com> <20200921183602.GI3141@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200921183602.GI3141@willie-the-truck> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200921_165648_312301_0CFFDF0E X-CRM114-Status: GOOD ( 22.19 ) 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: mark.rutland@arm.com, robin.murphy@arm.com, linux-imx@nxp.com, 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, Sep 21, 2020 at 07:36:02PM +0100, Will Deacon wrote: > On Tue, Sep 08, 2020 at 06:47:34PM +0800, Joakim Zhang wrote: > > +static void ddr_perf_event_update(struct perf_event *event) > > +{ > > + struct ddr_pmu *pmu = to_ddr_pmu(event->pmu); > > + struct hw_perf_event *hwc = &event->hw; > > + u64 delta, prev_raw_count, new_raw_count; > > + int counter = hwc->idx; > > + int ret; > > + > > + if (counter == EVENT_CYCLES_COUNTER) { > > + do { > > + prev_raw_count = local64_read(&hwc->prev_count); > > + new_raw_count = ddr_perf_read_counter(pmu, counter); > > + } while (local64_cmpxchg(&hwc->prev_count, prev_raw_count, > > + new_raw_count) != prev_raw_count); > > + > > + delta = (new_raw_count - prev_raw_count) & 0xFFFFFFFF; > > + > > + local64_add(delta, &event->count); > > Why do we treat the cycle counter so differently here? Ah, please can you remind me: does the cycle counter stop on overflow, or does it continue to count? > > + } else { > > + /* > > + * For legacy SoCs: event counters continue counting when overflow, > > + * no need to clear the counter. > > + * For new SoCs: event counters stop counting when overflow, need > > + * clear counter to let it count again. > > + */ > > + ret = ddr_perf_counter_overflow(pmu, counter); > > + if (ret) > > + dev_warn(pmu->dev, "Event Counter%d overflow happened, data incorrect!!\n", counter); > > I don't understand this message: if the data is incorrect, why do we need > to handle overflow at all/, rather than putting the event into an error > state? Also, now I remember how this all works (we use the cycle counter to stop overflow of the event counter), then warning here is ok, but we should do something like: dev_warn_ratelimited(pmu->dev, "events lost due to counter overflow (config 0x%llx)\n", event->attr.config); instead. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel