Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2098171ybl; Thu, 30 Jan 2020 11:19:17 -0800 (PST) X-Google-Smtp-Source: APXvYqy0MfyBK90CmPWG/7oQzofIZkzqKlE4DVGC2hpdOyBcWz8o90y2rMfLnmM4v33eF1y7zvf/ X-Received: by 2002:a05:6830:1185:: with SMTP id u5mr4400579otq.147.1580411957691; Thu, 30 Jan 2020 11:19:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580411957; cv=none; d=google.com; s=arc-20160816; b=JawuTRl7h4kOOexrk5DfuYzOAwTXTszLy2oXi+JNI6pyfa79ZHJlvx6/Ck1p7YAzVQ wQ8pzZ+OOjtGIPA9N//GZYqufje+ySflZCFEVEiT5IsmrEAH1jUfO/uO+YbIFfkMn1WN 2c5jWqaNR3kUx5Z1XUT6r4S7AU7CCPoSJEiFbTjttYAaX8i87Vg2TKqA8Cc3ib1ls3PG kYDTkpbsSgFYU3DTTj8bqWgPvAylZdbBdA8UetnF54rAYK1Rb56yiCD3GfEHPUjuD5ph vvOD/KoJdlbIi3YlSQYdvmVdY5zKS7yOa+orr/UJc+xL5XyapLoC0DRlSiSwI1KtzZta p3vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KRMTmBbzlaK/Sz6d+GUMQuqI63efdA4ATvwiRjgu18Q=; b=vWknrwyaWKfXvUejSc+sRMzE+0W9kZWj5KQpZ2bgdrRPwsgwMFzhpj9iYZ3dtqfU7J MpnXTdOrlATVFASsuuIkzGMdyl6POChI+Tz2op4KWxD/92OkJHH0K5Bxc8V2wZRnwUvT vmoJljDdO33Gu+Ow2TDwfSdlSzZsamBYDeHqyN+aPYsnrX0V8B442KsFVx3usSdKF22I HdgmEZ725MUJpBBNvoOnzl/2rHS5dBFxeABczcJhGhaBqb+sfMLqZF7ZyDPSm+7v3sw0 dXXheEI0EAJuk8rzhnywRlN1b8R2BDdJ+nAzNgsLIy1yAml2qETEqRW8nS7fUTSCdVsr 1tqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gpbP23U0; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a143si3126689oii.179.2020.01.30.11.19.05; Thu, 30 Jan 2020 11:19:17 -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=@kernel.org header.s=default header.b=gpbP23U0; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731046AbgA3Spd (ORCPT + 99 others); Thu, 30 Jan 2020 13:45:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:55146 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731028AbgA3Spc (ORCPT ); Thu, 30 Jan 2020 13:45:32 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 64AD92464B; Thu, 30 Jan 2020 18:45:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580409930; bh=YgsZRwJQo5NDjLt5Mz+9Gt6+Z3gsDcXgk385OZZSpSo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gpbP23U0EHUmwTYFE+0KJbUIZIuAYG8PQKWss0Ch3N5Pbs1Pz1SLodtJyr4uXzgHc wmlavmbdNgEjmTL5Cc3HgZPhxbJm4HeE+Cg4BrULqSPR1z+ffndpakmd4gIKpr1iM3 mcIMB7WSjHfIl4l0nYIvWKfyRht2mFcdMUwjiyq8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joakim Zhang , Will Deacon , Sasha Levin Subject: [PATCH 5.4 088/110] perf/imx_ddr: Add enhanced AXI ID filter support Date: Thu, 30 Jan 2020 19:39:04 +0100 Message-Id: <20200130183624.644827284@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200130183613.810054545@linuxfoundation.org> References: <20200130183613.810054545@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joakim Zhang [ Upstream commit 44f8bd014a94ed679ddb77d0b92350d4ac4f23a5 ] With DDR_CAP_AXI_ID_FILTER quirk, indicating HW supports AXI ID filter which only can get bursts from DDR transaction, i.e. DDR read/write requests. This patch add DDR_CAP_AXI_ID_ENHANCED_FILTER quirk, indicating HW supports AXI ID filter which can get bursts and bytes from DDR transaction at the same time. We hope PMU always return bytes in the driver due to it is more meaningful for users. Signed-off-by: Joakim Zhang Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- drivers/perf/fsl_imx8_ddr_perf.c | 63 +++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 21 deletions(-) diff --git a/drivers/perf/fsl_imx8_ddr_perf.c b/drivers/perf/fsl_imx8_ddr_perf.c index ce7345745b42c..2a3966d059e70 100644 --- a/drivers/perf/fsl_imx8_ddr_perf.c +++ b/drivers/perf/fsl_imx8_ddr_perf.c @@ -45,7 +45,8 @@ static DEFINE_IDA(ddr_ida); /* DDR Perf hardware feature */ -#define DDR_CAP_AXI_ID_FILTER 0x1 /* support AXI ID filter */ +#define DDR_CAP_AXI_ID_FILTER 0x1 /* support AXI ID filter */ +#define DDR_CAP_AXI_ID_FILTER_ENHANCED 0x3 /* support enhanced AXI ID filter */ struct fsl_ddr_devtype_data { unsigned int quirks; /* quirks needed for different DDR Perf core */ @@ -178,6 +179,36 @@ static const struct attribute_group *attr_groups[] = { NULL, }; +static bool ddr_perf_is_filtered(struct perf_event *event) +{ + return event->attr.config == 0x41 || event->attr.config == 0x42; +} + +static u32 ddr_perf_filter_val(struct perf_event *event) +{ + return event->attr.config1; +} + +static bool ddr_perf_filters_compatible(struct perf_event *a, + struct perf_event *b) +{ + if (!ddr_perf_is_filtered(a)) + return true; + if (!ddr_perf_is_filtered(b)) + return true; + return ddr_perf_filter_val(a) == ddr_perf_filter_val(b); +} + +static bool ddr_perf_is_enhanced_filtered(struct perf_event *event) +{ + unsigned int filt; + struct ddr_pmu *pmu = to_ddr_pmu(event->pmu); + + filt = pmu->devtype_data->quirks & DDR_CAP_AXI_ID_FILTER_ENHANCED; + return (filt == DDR_CAP_AXI_ID_FILTER_ENHANCED) && + ddr_perf_is_filtered(event); +} + static u32 ddr_perf_alloc_counter(struct ddr_pmu *pmu, int event) { int i; @@ -209,27 +240,17 @@ static void ddr_perf_free_counter(struct ddr_pmu *pmu, int counter) static u32 ddr_perf_read_counter(struct ddr_pmu *pmu, int counter) { - return readl_relaxed(pmu->base + COUNTER_READ + counter * 4); -} - -static bool ddr_perf_is_filtered(struct perf_event *event) -{ - return event->attr.config == 0x41 || event->attr.config == 0x42; -} + struct perf_event *event = pmu->events[counter]; + void __iomem *base = pmu->base; -static u32 ddr_perf_filter_val(struct perf_event *event) -{ - return event->attr.config1; -} - -static bool ddr_perf_filters_compatible(struct perf_event *a, - struct perf_event *b) -{ - if (!ddr_perf_is_filtered(a)) - return true; - if (!ddr_perf_is_filtered(b)) - return true; - return ddr_perf_filter_val(a) == ddr_perf_filter_val(b); + /* + * return bytes instead of bursts from ddr transaction for + * axid-read and axid-write event if PMU core supports enhanced + * filter. + */ + base += ddr_perf_is_enhanced_filtered(event) ? COUNTER_DPCR1 : + COUNTER_READ; + return readl_relaxed(base + counter * 4); } static int ddr_perf_event_init(struct perf_event *event) -- 2.20.1