Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1563217rdb; Mon, 8 Jan 2024 03:26:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IGEq9LBfsmO/ZH+ygk3/CFcH15lNJyRXf87275rRIB+9Xj4bFBdgJ7m0CZgGucTes4sEV49 X-Received: by 2002:a17:903:110d:b0:1d4:2e75:9b65 with SMTP id n13-20020a170903110d00b001d42e759b65mr1299365plh.108.1704713217456; Mon, 08 Jan 2024 03:26:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704713217; cv=none; d=google.com; s=arc-20160816; b=hO/yLCeSntKa+B3PCwpcQg7v4Q4lqvTZYfLrghr38bvS7fV/+ji6PU1Q7gL1svHLV5 L2BYgy9QB9JePMEeWohVvFFr2HrVKImeTZmR+yBJ5mNsaNsBjVBwqT70+Wt93ZUa05/X zZzqf/iaL35X+awS5O0jp141mNoa+StBxCf+4sdnF0PoqKF3EhFqOVG9duKqyBGJmjOj gpl15CSO2O+yBLFw2UTi71WnRGwpiHAHgYYiRCAUfD3QGSY90IoDLguILHx7V9HOkGxZ Hi2fSx4f1xaEy78N+VcUDXpmiApDRYJbg0netuvBQWGncBr4R6DWWt0lygWTPWZYqXFn y4qA== ARC-Message-Signature: i=1; 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:message-id:date:subject:cc:to :from; bh=egoVozkMfbhnxljmGVEuYFB8TOxE8z+0encIR6VN2cE=; fh=rq8fHjZTYNSDwmC3qQQfurP/T0/6PMbI1Vlc/hCgeHA=; b=HUZaZ2+kHsa28oxrQL54xNykAoit0nuQO3Xyvhf7hh1rqfCqLsa6WeXLBG7LgdqEh2 emLK+XKT2AKMiL1SeA2+onI0ic0MUKgoOHJiL/+NmupUP+Cc/yOiJPclhPctUkVGlbrQ bm3JpuCcj0sUWx2nphgQaW/mx4+3EuQU5u6/ezQAPPmXYAx5jn1+qc4DDUYXYvemh5py JPG5KkbC/qFjtij55a3CA5KHcsUD4RAEU+eMIGViZKB3iDyL4nQD9HOpknaEsBzBs5/m jcOIxpTsLp2bdC0XXYYYzKlpu+6Z259gfTB3I3mQyZ9hRZT3m/1H46Hib0hTeu7PhH9E Gjbg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-19416-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19416-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id h14-20020a170902ac8e00b001d4bd2037b0si5827595plr.152.2024.01.08.03.26.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 03:26:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19416-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-19416-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19416-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 34941B22473 for ; Mon, 8 Jan 2024 11:25:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 178DE2E826; Mon, 8 Jan 2024 11:24:41 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (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 82AE12E650 for ; Mon, 8 Jan 2024 11:24:37 +0000 (UTC) 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.162.112]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4T7s9z3RMXz29jrx; Mon, 8 Jan 2024 19:23:03 +0800 (CST) Received: from kwepemm600003.china.huawei.com (unknown [7.193.23.202]) by mail.maildlp.com (Postfix) with ESMTPS id AFC641404F7; Mon, 8 Jan 2024 19:24:33 +0800 (CST) Received: from ubuntu2204.huawei.com (10.67.174.22) by kwepemm600003.china.huawei.com (7.193.23.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 8 Jan 2024 19:24:33 +0800 From: Yang Jihong To: , , , CC: , , Subject: [PATCH] hwtracing: hisi_ptt: Move type check to the beginning of hisi_ptt_pmu_event_init() Date: Mon, 8 Jan 2024 11:20:24 +0000 Message-ID: <20240108112024.3514498-1-yangjihong1@huawei.com> X-Mailer: git-send-email 2.34.1 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: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemm600003.china.huawei.com (7.193.23.202) When perf_init_event() calls perf_try_init_event() to init pmu driver, searches for the next pmu driver only when the return value is -ENOENT. Therefore, hisi_ptt_pmu_event_init() needs to check the type at the beginning of the function. Otherwise, in the case of perf-task mode, perf_try_init_event() returns -EOPNOTSUPP and skips subsequent pmu drivers, causes perf_init_event() to fail. Signed-off-by: Yang Jihong --- drivers/hwtracing/ptt/hisi_ptt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/hwtracing/ptt/hisi_ptt.c b/drivers/hwtracing/ptt/hisi_ptt.c index a991ecb7515a..24a1f7797aeb 100644 --- a/drivers/hwtracing/ptt/hisi_ptt.c +++ b/drivers/hwtracing/ptt/hisi_ptt.c @@ -995,6 +995,9 @@ static int hisi_ptt_pmu_event_init(struct perf_event *event) int ret; u32 val; + if (event->attr.type != hisi_ptt->hisi_ptt_pmu.type) + return -ENOENT; + if (event->cpu < 0) { dev_dbg(event->pmu->dev, "Per-task mode not supported\n"); return -EOPNOTSUPP; @@ -1003,9 +1006,6 @@ static int hisi_ptt_pmu_event_init(struct perf_event *event) if (event->attach_state & PERF_ATTACH_TASK) return -EOPNOTSUPP; - if (event->attr.type != hisi_ptt->hisi_ptt_pmu.type) - return -ENOENT; - ret = hisi_ptt_trace_valid_filter(hisi_ptt, event->attr.config); if (ret < 0) return ret; -- 2.34.1