Message ID | 20240204074527.47110-5-yangyicong@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-51502-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp240916dyb; Sat, 3 Feb 2024 23:50:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IHUsQvagaDkhM6cdE/CpT9fcKNE+oZnzNElwmlUQ+YnLvvAWc8tBGgOA1Ab33tLhb8D0swb X-Received: by 2002:a17:907:7705:b0:a37:91f6:3cd8 with SMTP id kw5-20020a170907770500b00a3791f63cd8mr406342ejc.55.1707033045044; Sat, 03 Feb 2024 23:50:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707033045; cv=pass; d=google.com; s=arc-20160816; b=pNEZwiuB1EMWqItxniTgCX/HzqiSm7CqLNSXCEiqNcpL4tLA/5Pb7hI5T9UTOI4qiI /BNbVqrvWMvJ7d1JwM1wvDlGLsnMv2ZoQELmIzs4lylgJJI6g7YMYL7c1ddIHtkg6SkF Fw0PHnbKaNXPJLdGVpqzTyK76xlJp2cHt33Ou9fkvkI5omGXsw/AN6q4B36JjkqxrDlC pQv782qT2DrVuMML/HZ7oZAiNmzVabweKG5E5wx6WWRn5YWQ0+0dtSJ6KskH+KHvfuku PcqM9RdrZnaVx3Nom6XzPRsV5WzXumxT6amhJhoJuTGqJW7X28dv2HEqBhvvbVaa+ROL kxbg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=ys8TEnjJYSXuVe3FNV3kVNgwDzQMcPMQDDx/yJjw2uw=; fh=e6S+h4YeHdtYAdAyDuG0wlB4r6ioJt/f6NnAqVsjqpE=; b=K0iCq3IUiXNZYOHxrjIqMPv2OmuVcerCTE3rAsdy2LVEvMfWQST8KZdzz6w9FJ7ICU EJtXVGrZ+5gbIzUolKdtMFe2TSZsRO8Tl4k2QNF/Kw1XQcjovsI5G8YdW2/VfhxZmWjZ i02rhro6F7xaWrGlqXez8o15NqM909FJgvCCf4DiSLFiQLDK5+iLUycW+WWuXSs6tipK eFzZ6KkSyoIjkFhc1dBVP5lAw4oajT/Rx1NBgOSlQYrCwnLAZqlECDrVxToUlwOSvtFI lNlKJOcQFid3LkE5v1kgAJ3qVgmBsYqafpfzqAiwbBoEzhtkG2G8f4PaHfnoJUtAKRnS TCiw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-51502-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51502-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com X-Forwarded-Encrypted: i=1; AJvYcCVJbgHHz4o5NQNUy3X456o4tnLEKL76qjk7TI3ol2KodzeZfXAFEgR0PfF2p4ZcAIwubUwHE2HGns14hJ6xeFlAN1G+yw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id lz12-20020a170906fb0c00b00a37a2d7e997si108151ejb.95.2024.02.03.23.50.44 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Feb 2024 23:50:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51502-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-51502-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51502-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A63D21F22784 for <ouuuleilei@gmail.com>; Sun, 4 Feb 2024 07:50:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6FFBD134B1; Sun, 4 Feb 2024 07:49:42 +0000 (UTC) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0802DE570 for <linux-kernel@vger.kernel.org>; Sun, 4 Feb 2024 07:49:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707032980; cv=none; b=d/050lzLU+Zzmc9Mk5lwfXVjbXbcfYI2sCUf9LjNayf10fZ+0m7KLnEm2Vjb7nvKgbTOJeJvGXJWEQEvm86UFdQ//WtrgIFaAMWckrRq3c2os3Lh4QIpJ6ysrR0sOhauXDkJRByCVrQXOOMbztj0pZcZyODcLOBsgF/spFd2eAI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707032980; c=relaxed/simple; bh=V2dplIcXwgwtYYeVnBhwj0TNKdw7NOt1svmTLt/jfe4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BjNgSkxRn8BOWhCGLxxY5qGBiv3eqKGOR4AtVBk3FvZ+En067rUJG9lCLy1VDh6K9bDMumHSNUyNMqM2FA2OD/rlrG//oXyZuilGseGX0n5Yw8xX353YBnT3hVYDm0ZOG6xDAVOa8ZuPAGjFBPyMNP2P83tz9pC5LEckUqHdiMk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4TSM3y2rk3z1FJpd; Sun, 4 Feb 2024 15:45:02 +0800 (CST) Received: from canpemm500009.china.huawei.com (unknown [7.192.105.203]) by mail.maildlp.com (Postfix) with ESMTPS id A60A71A016B; Sun, 4 Feb 2024 15:49:35 +0800 (CST) Received: from localhost.localdomain (10.50.165.33) by canpemm500009.china.huawei.com (7.192.105.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Sun, 4 Feb 2024 15:49:35 +0800 From: Yicong Yang <yangyicong@huawei.com> To: <jonathan.cameron@huawei.com>, <will@kernel.org>, <mark.rutland@arm.com>, <hejunhao3@huawei.com>, <linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org> CC: <yangyicong@hisilicon.com>, <linuxarm@huawei.com>, <prime.zeng@hisilicon.com>, <fanghao11@huawei.com> Subject: [PATCH 4/7] drivers/perf: hisi_pcie: Check the target filter properly Date: Sun, 4 Feb 2024 15:45:24 +0800 Message-ID: <20240204074527.47110-5-yangyicong@huawei.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20240204074527.47110-1-yangyicong@huawei.com> References: <20240204074527.47110-1-yangyicong@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500009.china.huawei.com (7.192.105.203) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789953882319514467 X-GMAIL-MSGID: 1789953882319514467 |
Series |
None
|
|
Commit Message
Yicong Yang
Feb. 4, 2024, 7:45 a.m. UTC
From: Junhao He <hejunhao3@huawei.com> The PMU can monitor traffic of certain target Root Port or downstream target Endpoint. User can specify the target filter by the "port" or "bdf" option respectively. The PMU can only monitor the Root Port or Endpoint on the same PCIe core so the value of "port" or "bdf" should be valid and will be checked by the driver. Currently at least and only one of "port" and "bdf" option must be set. If "port" filter is not set or is set explicitly to zero (default), driver will regard the user specifies a "bdf" option since "port" option is a bitmask of the target Root Ports and zero is not a valid value. If user not explicitly set "port" or "bdf" filter, the driver uses "bdf" default value (zero) to set target filter, but driver will skip the check of bdf=0, although it's a valid value (meaning 0000:000:00.0). Then the user just gets zero. Therefore, we need to check if both "port" and "bdf" are invalid, then return failure and report warning. Testing: before the patch: 0 hisi_pcie0_core1/rx_mrd_flux/ 0 hisi_pcie0_core1/rx_mrd_flux,port=0/ 24,124 hisi_pcie0_core1/rx_mrd_flux,port=1/ 0 hisi_pcie0_core1/rx_mrd_flux,bdf=0/ <not supported> hisi_pcie0_core1/rx_mrd_flux,bdf=1/ after the patch: <not supported> hisi_pcie0_core1/rx_mrd_flux/ <not supported> hisi_pcie0_core1/rx_mrd_flux,port=0/ 24,153 hisi_pcie0_core1/rx_mrd_flux,port=1/ <not supported> hisi_pcie0_core1/rx_mrd_flux,bdf=0/ <not supported> hisi_pcie0_core1/rx_mrd_flux,bdf=1/ Signed-off-by: Junhao He <hejunhao3@huawei.com> Signed-off-by: Yicong Yang <yangyicong@hisilicon.com> --- drivers/perf/hisilicon/hisi_pcie_pmu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Comments
On Sun, 4 Feb 2024 15:45:24 +0800 Yicong Yang <yangyicong@huawei.com> wrote: > From: Junhao He <hejunhao3@huawei.com> > > The PMU can monitor traffic of certain target Root Port or downstream > target Endpoint. User can specify the target filter by the "port" or > "bdf" option respectively. The PMU can only monitor the Root Port or > Endpoint on the same PCIe core so the value of "port" or "bdf" should > be valid and will be checked by the driver. > > Currently at least and only one of "port" and "bdf" option must be set. > If "port" filter is not set or is set explicitly to zero (default), > driver will regard the user specifies a "bdf" option since "port" option > is a bitmask of the target Root Ports and zero is not a valid > value. > > If user not explicitly set "port" or "bdf" filter, the driver uses "bdf" > default value (zero) to set target filter, but driver will skip the > check of bdf=0, although it's a valid value (meaning 0000:000:00.0). > Then the user just gets zero. > > Therefore, we need to check if both "port" and "bdf" are invalid, then > return failure and report warning. > > Testing: > before the patch: > 0 hisi_pcie0_core1/rx_mrd_flux/ > 0 hisi_pcie0_core1/rx_mrd_flux,port=0/ > 24,124 hisi_pcie0_core1/rx_mrd_flux,port=1/ > 0 hisi_pcie0_core1/rx_mrd_flux,bdf=0/ > <not supported> hisi_pcie0_core1/rx_mrd_flux,bdf=1/ Nice to include an example that works for bdf hisi_pcie0_core1/rx_mrd_flux,bdf=1,port=0 or something like that? > > after the patch: > <not supported> hisi_pcie0_core1/rx_mrd_flux/ > <not supported> hisi_pcie0_core1/rx_mrd_flux,port=0/ > 24,153 hisi_pcie0_core1/rx_mrd_flux,port=1/ > <not supported> hisi_pcie0_core1/rx_mrd_flux,bdf=0/ > <not supported> hisi_pcie0_core1/rx_mrd_flux,bdf=1/ > > Signed-off-by: Junhao He <hejunhao3@huawei.com> > Signed-off-by: Yicong Yang <yangyicong@hisilicon.com> Clearly the current situation is wrong, but perhaps we can have a more intuitive scheme (could be added as a follow up patch) and have the driver figure out which port the bdf lies below? Maybe that's a job for userspace tooling rather than the driver, but the driver already has verification code and it wouldn't be hard to not just check the rp is ours, but also set the filter to specify that rp, or maybe just set the mask to include them all? Jonathan > --- > drivers/perf/hisilicon/hisi_pcie_pmu.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/perf/hisilicon/hisi_pcie_pmu.c b/drivers/perf/hisilicon/hisi_pcie_pmu.c > index 83be3390686c..b91f03c02c57 100644 > --- a/drivers/perf/hisilicon/hisi_pcie_pmu.c > +++ b/drivers/perf/hisilicon/hisi_pcie_pmu.c > @@ -306,10 +306,10 @@ static bool hisi_pcie_pmu_valid_filter(struct perf_event *event, > if (hisi_pcie_get_trig_len(event) > HISI_PCIE_TRIG_MAX_VAL) > return false; > > - if (requester_id) { > - if (!hisi_pcie_pmu_valid_requester_id(pcie_pmu, requester_id)) > - return false; > - } > + /* Need to explicitly set filter of "port" or "bdf" */ > + if (!hisi_pcie_get_port(event) && > + !hisi_pcie_pmu_valid_requester_id(pcie_pmu, requester_id)) > + return false; > > return true; > }
On 2024/2/8 20:29, Jonathan Cameron wrote: > On Sun, 4 Feb 2024 15:45:24 +0800 > Yicong Yang <yangyicong@huawei.com> wrote: > >> From: Junhao He <hejunhao3@huawei.com> >> >> The PMU can monitor traffic of certain target Root Port or downstream >> target Endpoint. User can specify the target filter by the "port" or >> "bdf" option respectively. The PMU can only monitor the Root Port or >> Endpoint on the same PCIe core so the value of "port" or "bdf" should >> be valid and will be checked by the driver. >> >> Currently at least and only one of "port" and "bdf" option must be set. >> If "port" filter is not set or is set explicitly to zero (default), >> driver will regard the user specifies a "bdf" option since "port" option >> is a bitmask of the target Root Ports and zero is not a valid >> value. >> >> If user not explicitly set "port" or "bdf" filter, the driver uses "bdf" >> default value (zero) to set target filter, but driver will skip the >> check of bdf=0, although it's a valid value (meaning 0000:000:00.0). >> Then the user just gets zero. >> >> Therefore, we need to check if both "port" and "bdf" are invalid, then >> return failure and report warning. >> >> Testing: >> before the patch: >> 0 hisi_pcie0_core1/rx_mrd_flux/ >> 0 hisi_pcie0_core1/rx_mrd_flux,port=0/ >> 24,124 hisi_pcie0_core1/rx_mrd_flux,port=1/ >> 0 hisi_pcie0_core1/rx_mrd_flux,bdf=0/ >> <not supported> hisi_pcie0_core1/rx_mrd_flux,bdf=1/ > > Nice to include an example that works for bdf > hisi_pcie0_core1/rx_mrd_flux,bdf=1,port=0 > or something like that? >> >> after the patch: >> <not supported> hisi_pcie0_core1/rx_mrd_flux/ >> <not supported> hisi_pcie0_core1/rx_mrd_flux,port=0/ >> 24,153 hisi_pcie0_core1/rx_mrd_flux,port=1/ >> <not supported> hisi_pcie0_core1/rx_mrd_flux,bdf=0/ >> <not supported> hisi_pcie0_core1/rx_mrd_flux,bdf=1/ >> >> Signed-off-by: Junhao He <hejunhao3@huawei.com> >> Signed-off-by: Yicong Yang <yangyicong@hisilicon.com> > > Clearly the current situation is wrong, but perhaps we can > have a more intuitive scheme (could be added as a follow up patch) > and have the driver figure out which port the bdf lies below? > > Maybe that's a job for userspace tooling rather than the driver, but > the driver already has verification code and it wouldn't be hard > to not just check the rp is ours, but also set the filter to specify > that rp, or maybe just set the mask to include them all? > To do a check should be simple, we can decode the bdf and find the target endpoint and related root port for doing the check. Another example is what we've done in hisi_ptt that we maintian a list of supported root ports and endpoints, but that will be a bit more complex. > Jonathan > > >> --- >> drivers/perf/hisilicon/hisi_pcie_pmu.c | 8 ++++---- >> 1 file changed, 4 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/perf/hisilicon/hisi_pcie_pmu.c b/drivers/perf/hisilicon/hisi_pcie_pmu.c >> index 83be3390686c..b91f03c02c57 100644 >> --- a/drivers/perf/hisilicon/hisi_pcie_pmu.c >> +++ b/drivers/perf/hisilicon/hisi_pcie_pmu.c >> @@ -306,10 +306,10 @@ static bool hisi_pcie_pmu_valid_filter(struct perf_event *event, >> if (hisi_pcie_get_trig_len(event) > HISI_PCIE_TRIG_MAX_VAL) >> return false; >> >> - if (requester_id) { >> - if (!hisi_pcie_pmu_valid_requester_id(pcie_pmu, requester_id)) >> - return false; >> - } >> + /* Need to explicitly set filter of "port" or "bdf" */ >> + if (!hisi_pcie_get_port(event) && >> + !hisi_pcie_pmu_valid_requester_id(pcie_pmu, requester_id)) >> + return false; >> >> return true; >> } > > . >
On 2024/2/21 17:46, Yicong Yang wrote: > On 2024/2/8 20:29, Jonathan Cameron wrote: >> On Sun, 4 Feb 2024 15:45:24 +0800 >> Yicong Yang <yangyicong@huawei.com> wrote: >> >>> From: Junhao He <hejunhao3@huawei.com> >>> >>> The PMU can monitor traffic of certain target Root Port or downstream >>> target Endpoint. User can specify the target filter by the "port" or >>> "bdf" option respectively. The PMU can only monitor the Root Port or >>> Endpoint on the same PCIe core so the value of "port" or "bdf" should >>> be valid and will be checked by the driver. >>> >>> Currently at least and only one of "port" and "bdf" option must be set. >>> If "port" filter is not set or is set explicitly to zero (default), >>> driver will regard the user specifies a "bdf" option since "port" option >>> is a bitmask of the target Root Ports and zero is not a valid >>> value. >>> >>> If user not explicitly set "port" or "bdf" filter, the driver uses "bdf" >>> default value (zero) to set target filter, but driver will skip the >>> check of bdf=0, although it's a valid value (meaning 0000:000:00.0). >>> Then the user just gets zero. >>> >>> Therefore, we need to check if both "port" and "bdf" are invalid, then >>> return failure and report warning. >>> >>> Testing: >>> before the patch: >>> 0 hisi_pcie0_core1/rx_mrd_flux/ >>> 0 hisi_pcie0_core1/rx_mrd_flux,port=0/ >>> 24,124 hisi_pcie0_core1/rx_mrd_flux,port=1/ >>> 0 hisi_pcie0_core1/rx_mrd_flux,bdf=0/ >>> <not supported> hisi_pcie0_core1/rx_mrd_flux,bdf=1/ >> Nice to include an example that works for bdf >> hisi_pcie0_core1/rx_mrd_flux,bdf=1,port=0 >> or something like that? >>> after the patch: >>> <not supported> hisi_pcie0_core1/rx_mrd_flux/ >>> <not supported> hisi_pcie0_core1/rx_mrd_flux,port=0/ >>> 24,153 hisi_pcie0_core1/rx_mrd_flux,port=1/ >>> <not supported> hisi_pcie0_core1/rx_mrd_flux,bdf=0/ >>> <not supported> hisi_pcie0_core1/rx_mrd_flux,bdf=1/ >>> >>> Signed-off-by: Junhao He <hejunhao3@huawei.com> >>> Signed-off-by: Yicong Yang <yangyicong@hisilicon.com> >> Clearly the current situation is wrong, but perhaps we can >> have a more intuitive scheme (could be added as a follow up patch) >> and have the driver figure out which port the bdf lies below? >> >> Maybe that's a job for userspace tooling rather than the driver, but >> the driver already has verification code and it wouldn't be hard >> to not just check the rp is ours, but also set the filter to specify >> that rp, or maybe just set the mask to include them all? >> > To do a check should be simple, we can decode the bdf and find the target > endpoint and related root port for doing the check. The function hisi_pcie_pmu_valid_requester_id() already does this. It can get the RP of the bdf, then check whether the RP is within the RP range of the PCIe PMU. > Another example is what we've done in hisi_ptt that we maintian a list of > supported root ports and endpoints, but that will be a bit more complex. > >> Jonathan >> >> >>> --- >>> drivers/perf/hisilicon/hisi_pcie_pmu.c | 8 ++++---- >>> 1 file changed, 4 insertions(+), 4 deletions(-) >>> >>> diff --git a/drivers/perf/hisilicon/hisi_pcie_pmu.c b/drivers/perf/hisilicon/hisi_pcie_pmu.c >>> index 83be3390686c..b91f03c02c57 100644 >>> --- a/drivers/perf/hisilicon/hisi_pcie_pmu.c >>> +++ b/drivers/perf/hisilicon/hisi_pcie_pmu.c >>> @@ -306,10 +306,10 @@ static bool hisi_pcie_pmu_valid_filter(struct perf_event *event, >>> if (hisi_pcie_get_trig_len(event) > HISI_PCIE_TRIG_MAX_VAL) >>> return false; >>> >>> - if (requester_id) { >>> - if (!hisi_pcie_pmu_valid_requester_id(pcie_pmu, requester_id)) >>> - return false; >>> - } >>> + /* Need to explicitly set filter of "port" or "bdf" */ >>> + if (!hisi_pcie_get_port(event) && >>> + !hisi_pcie_pmu_valid_requester_id(pcie_pmu, requester_id)) >>> + return false; >>> >>> return true; >>> } >> . >>
On 2024/2/8 20:29, Jonathan Cameron wrote: > On Sun, 4 Feb 2024 15:45:24 +0800 > Yicong Yang <yangyicong@huawei.com> wrote: > >> From: Junhao He <hejunhao3@huawei.com> >> >> The PMU can monitor traffic of certain target Root Port or downstream >> target Endpoint. User can specify the target filter by the "port" or >> "bdf" option respectively. The PMU can only monitor the Root Port or >> Endpoint on the same PCIe core so the value of "port" or "bdf" should >> be valid and will be checked by the driver. >> >> Currently at least and only one of "port" and "bdf" option must be set. >> If "port" filter is not set or is set explicitly to zero (default), >> driver will regard the user specifies a "bdf" option since "port" option >> is a bitmask of the target Root Ports and zero is not a valid >> value. >> >> If user not explicitly set "port" or "bdf" filter, the driver uses "bdf" >> default value (zero) to set target filter, but driver will skip the >> check of bdf=0, although it's a valid value (meaning 0000:000:00.0). >> Then the user just gets zero. >> >> Therefore, we need to check if both "port" and "bdf" are invalid, then >> return failure and report warning. >> >> Testing: >> before the patch: >> 0 hisi_pcie0_core1/rx_mrd_flux/ >> 0 hisi_pcie0_core1/rx_mrd_flux,port=0/ >> 24,124 hisi_pcie0_core1/rx_mrd_flux,port=1/ >> 0 hisi_pcie0_core1/rx_mrd_flux,bdf=0/ >> <not supported> hisi_pcie0_core1/rx_mrd_flux,bdf=1/ > Nice to include an example that works for bdf > hisi_pcie0_core1/rx_mrd_flux,bdf=1,port=0 > or something like that? Yes, I will do that. These combined parameter test cases have been validated. >> after the patch: >> <not supported> hisi_pcie0_core1/rx_mrd_flux/ >> <not supported> hisi_pcie0_core1/rx_mrd_flux,port=0/ >> 24,153 hisi_pcie0_core1/rx_mrd_flux,port=1/ >> <not supported> hisi_pcie0_core1/rx_mrd_flux,bdf=0/ >> <not supported> hisi_pcie0_core1/rx_mrd_flux,bdf=1/ >> >> Signed-off-by: Junhao He <hejunhao3@huawei.com> >> Signed-off-by: Yicong Yang <yangyicong@hisilicon.com> > Clearly the current situation is wrong, but perhaps we can > have a more intuitive scheme (could be added as a follow up patch) > and have the driver figure out which port the bdf lies below? > > Maybe that's a job for userspace tooling rather than the driver, but > the driver already has verification code and it wouldn't be hard > to not just check the rp is ours, but also set the filter to specify > that rp, or maybe just set the mask to include them all? > > Jonathan > > >> --- >> drivers/perf/hisilicon/hisi_pcie_pmu.c | 8 ++++---- >> 1 file changed, 4 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/perf/hisilicon/hisi_pcie_pmu.c b/drivers/perf/hisilicon/hisi_pcie_pmu.c >> index 83be3390686c..b91f03c02c57 100644 >> --- a/drivers/perf/hisilicon/hisi_pcie_pmu.c >> +++ b/drivers/perf/hisilicon/hisi_pcie_pmu.c >> @@ -306,10 +306,10 @@ static bool hisi_pcie_pmu_valid_filter(struct perf_event *event, >> if (hisi_pcie_get_trig_len(event) > HISI_PCIE_TRIG_MAX_VAL) >> return false; >> >> - if (requester_id) { >> - if (!hisi_pcie_pmu_valid_requester_id(pcie_pmu, requester_id)) >> - return false; >> - } >> + /* Need to explicitly set filter of "port" or "bdf" */ >> + if (!hisi_pcie_get_port(event) && >> + !hisi_pcie_pmu_valid_requester_id(pcie_pmu, requester_id)) >> + return false; >> >> return true; >> } >
diff --git a/drivers/perf/hisilicon/hisi_pcie_pmu.c b/drivers/perf/hisilicon/hisi_pcie_pmu.c index 83be3390686c..b91f03c02c57 100644 --- a/drivers/perf/hisilicon/hisi_pcie_pmu.c +++ b/drivers/perf/hisilicon/hisi_pcie_pmu.c @@ -306,10 +306,10 @@ static bool hisi_pcie_pmu_valid_filter(struct perf_event *event, if (hisi_pcie_get_trig_len(event) > HISI_PCIE_TRIG_MAX_VAL) return false; - if (requester_id) { - if (!hisi_pcie_pmu_valid_requester_id(pcie_pmu, requester_id)) - return false; - } + /* Need to explicitly set filter of "port" or "bdf" */ + if (!hisi_pcie_get_port(event) && + !hisi_pcie_pmu_valid_requester_id(pcie_pmu, requester_id)) + return false; return true; }