Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1761129ybh; Fri, 13 Mar 2020 07:00:52 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt97FbPzewMlKyq+M3pamysgvEu/YeEJABrdjaF/6rFryajbCOAp8FiKcnaGYQ/0D9yYcAN X-Received: by 2002:a9d:21c5:: with SMTP id s63mr10689000otb.142.1584108051755; Fri, 13 Mar 2020 07:00:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584108051; cv=none; d=google.com; s=arc-20160816; b=FpY43AjFzcjXPd3fmblIn0HgwGIq+Dql3GQo41/rjLGpYV04vNEFxl3ryxJzIpUWl/ s7mxSyNoIQXwOH4xWAVF0aRZBia7KNZ2Z4D4dRquslcXEDLi60JTzXuzRxgFVbjcbmkN t1ozF/5rZM9GHOyhdZiorh9UlXJfFAISFUOKjybVPFKBeXSaJwwaNJYxzCwPoBHIo/0F 2rijUfUbt891BZsBha1J/nXWRpOIvws6cA8r18yJj+aofXr8B02AvufM9wr2MmS7M8TH elCVJXSiIGouZLgmz5ooL/KASoOIBPNOHkpxO4czbiYBrWUnwUWTamROkw0n5Xj/6Qic g2Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=1tmYtpHC3mM5UG7GpbTInCOhcckEdF4/bNRn7YhFUz0=; b=OiSZ3lhiiqz4tBUt1x+Oe97TJHMkECw7grOC3IMfn5jmOVw+sF6R+Sx1rHYnzZ/Xkp GpqdulfmEPOfK9HlpXr3b7ms4xfV7AZqap6ygCYoc8LbYsNVuvtQvdjD/DdRUQjG3mHY K/ovbY/htzfQ22cbhXfUCDADHwHBcj4wVJ4kcfBiV1AWVFIPBJ6Q2u4kBct5YAFijsAN O0Q/dIsXMNqNqaRJaew50VgAtX3hnw7vspISY4tRxaXUIeJximbYjUA54aplDkY6AhF9 LuQ8ycrAyXpS5uzQdd/RICg3Mg3o5VDP2ilK995/+y+3yQN+ZsinNYU9PLpCCY2Y54wh DXOg== ARC-Authentication-Results: i=1; mx.google.com; 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 j23si1192396otp.31.2020.03.13.07.00.36; Fri, 13 Mar 2020 07:00:51 -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; 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 S1726826AbgCMN7o (ORCPT + 99 others); Fri, 13 Mar 2020 09:59:44 -0400 Received: from foss.arm.com ([217.140.110.172]:55748 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726674AbgCMN7o (ORCPT ); Fri, 13 Mar 2020 09:59:44 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B429730E; Fri, 13 Mar 2020 06:59:43 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 975403F67D; Fri, 13 Mar 2020 06:59:42 -0700 (PDT) Date: Fri, 13 Mar 2020 13:59:40 +0000 From: Mark Rutland To: Robin Murphy Cc: Qi Liu , will@kernel.org, bhelgaas@google.com, linux-pci@vger.kernel.org, linuxarm@huawei.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH RFC] perf:Add driver for HiSilicon PCIe PMU Message-ID: <20200313135940.GK42546@lakrids.cambridge.arm.com> References: <1584014816-1908-1-git-send-email-liuqi115@huawei.com> <49a04327-b58b-3103-f992-97e8838c41df@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <49a04327-b58b-3103-f992-97e8838c41df@arm.com> User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 13, 2020 at 01:23:53PM +0000, Robin Murphy wrote: > On 2020-03-12 12:06 pm, Qi Liu wrote: > > From: Qi liu [...] > > +#define HISI_PCIE_EVENT_SHIFT_M GENMASK(15, 0) > > +#define HISI_PCIE_SUBEVENT_SHIFT_M GENMASK(31, 16) > > +#define HISI_PCIE_SUBEVENT_SHIFT_S 16 > > +#define HISI_PCIE_PORT_SHIFT_M GENMASK(7, 0) > > +#define HISI_PCIE_FUNC_SHIFT_M GENMASK(15, 8) > > +#define HISI_PCIE_FUNC_SHIFT_S 8 > > So "SHIFT_S" means "shift" and "SHIFT_M" actually means "mask"? That's > unnecessarily confusing. Furthermore it might be helpful if there was a more > obvious distinction between hardware register fields and config fields. Also, If you use the FIELD_GET() and FIELD_PREP() helpers, you only need to define the mask. See . > > +int hisi_pcie_pmu_event_init(struct perf_event *event) > > +{ > > + struct hisi_pcie_pmu *pcie_pmu = to_pcie_pmu(event->pmu); > > + struct hw_perf_event *hwc = &event->hw; > > + u32 subevent_id, event_id, func_id, port_id; > > + > > + if (event->attr.type != event->pmu->type) > > + return -ENOENT; > > + > > + /* > > + * We do not support sampling as the counters are all shared by all > > + * CPU cores in a CPU die(SCCL). Also we do not support attach to a > > Do the PCIe counters have anything to do with CPU clusters at all? > > > + * task(per-process mode) > > + */ > > + if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK) > > + return -EOPNOTSUPP; > > + > > + /* > > + * The uncore counters not specific to any CPU, so cannot > > + * support per-task > > + */ > > + if (event->cpu < 0) > > + return -EINVAL; > > + > > + /* > > + * Validate if the events in group does not exceed the > > + * available counters in hardware. > > + */ > > + if (!hisi_validate_event_group(event)) > > + return -EINVAL; > > + > > + event_id = event->attr.config && HISI_PCIE_EVENT_SHIFT_M; > > Really? Are you sure you've tested this properly? If you had: #define HISI_PCI_EVENT_ID GENMASK(15, 0) #define HISI_PCI_SUBEVENT_ID GENMASK(31, 16) ... here you could do: event_id = FIELD_GET(HISI_PCI_EVENT_ID, event->attr.config); > > > + subevent_id = (event->attr.config && HISI_PCIE_SUBEVENT_SHIFT_M) > > + >> HISI_PCIE_SUBEVENT_SHIFT_S; ... and: subevent_id = FIELD_GET(HISI_PCI_SUBEVENT_ID, event->attr.config); ... and so on for other fields. Thanks, Mark.