Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp1764205rdb; Sat, 3 Feb 2024 23:50:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IHRhTe1Fm+UkqFwzdEFXOtitF5LUDDg3gT88skAkHOGJULLASFq69nnpxaa3B8BDJvLOEen X-Received: by 2002:a0c:d990:0:b0:68c:6649:51a6 with SMTP id y16-20020a0cd990000000b0068c664951a6mr3249329qvj.51.1707033030167; Sat, 03 Feb 2024 23:50:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707033030; cv=pass; d=google.com; s=arc-20160816; b=Dryo8AWkqSEp24nVcLGFEk6mHV/0IAuZYdQ+HKc68sDrMfTXiLKfR6qINylhGf6D2V kUhbRv6NzKs/7CCZFeSEpv7mxbEqA7IGJJiWFcxGj/fwmGuUpi8/y4sqwuGcdaDGSwqn GbujszdKXHv2xviYVahkOwVMofGcE+i5xB2hSckL8fCaWpc9aVcNTisT5Rmli/YoP1DH JDcf4hJiqXGgYaFk/xpVeP1g4QGKOXJa9e1tVJvlBV70ct77ICs5HNM0QbQd2/uJC6p1 R+BVTuFd7DdwOgC6igQyRgy8es7H32u43yfbsTco0VVJPQUGozYtBvNYghJMZ+91ELHd MlbA== 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=Bp6bISPO4B0yqgINFX9FsBrCw78goeNjdcGEujoMTGc=; b=N5qkq1oxiWKYOZ8+Uyfo7PIRVX+dMPRLGHOVi/bpqkiWvMjterxPSYoZBTPQP/Rt3F UdIQJhd1mVTa4D6zj8bcdBR9isl4+eLRGx3wK5CG6sZT1XwnqckgDBgTSI0M8H4E5RLR D+8jARk2vhae/px+Y6qFefVjMMOSYMwQUywkMbBI5YJp7gLI1wrJWOYOa5SN6DNLnO9/ bbn3hkNUzdhlCnUmw12/bvKpTRoQbkg7FS3Y5zOBGNqGrktovfHfXqJAFAibxRDdGYEI BLJO2vQpqE38nwt5U8wv7yzwX0yEUgbFNAHLPnYSzCn+pMRqvnjQCOL4u2U8kZ1t5iRY uPxA==; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51502-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com X-Forwarded-Encrypted: i=1; AJvYcCXbslH4f4YyFVHAa2D3mwsqeN4M13plS9LyqMlYJYtWN2KuvK6e+AlnDhNtaWduZuikpgTWk3jYAwyKFFmUCzZBbdetoyyehSzzl3iyiQ== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id b8-20020a0cc988000000b0067f8393c2adsi5714744qvk.560.2024.02.03.23.50.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Feb 2024 23:50:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51502-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51502-linux.lists.archive=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B8E681C21504 for ; Sun, 4 Feb 2024 07:50:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3740211713; Sun, 4 Feb 2024 07:49:41 +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 ; 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 To: , , , , , CC: , , , 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: List-Subscribe: List-Unsubscribe: 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) From: Junhao He 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/ hisi_pcie0_core1/rx_mrd_flux,bdf=1/ after the patch: hisi_pcie0_core1/rx_mrd_flux/ hisi_pcie0_core1/rx_mrd_flux,port=0/ 24,153 hisi_pcie0_core1/rx_mrd_flux,port=1/ hisi_pcie0_core1/rx_mrd_flux,bdf=0/ hisi_pcie0_core1/rx_mrd_flux,bdf=1/ Signed-off-by: Junhao He Signed-off-by: Yicong Yang --- 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; } -- 2.24.0