Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1589029rdb; Mon, 8 Jan 2024 04:23:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IEPfFyGHIAjrUYmDsZh231tN8cAq0b7PMHq8WFKa0sK5ktntEA+B988SGChyGoPfbXORbC1 X-Received: by 2002:ae9:c30f:0:b0:781:a651:df40 with SMTP id n15-20020ae9c30f000000b00781a651df40mr8340044qkg.9.1704716608439; Mon, 08 Jan 2024 04:23:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704716608; cv=none; d=google.com; s=arc-20160816; b=g5bh0650EZ2iu2DDPGemjKtNXsJ2tfVah+AuYXqzZl5r+C5MW2ehuPty9pl0Rm/xQe eEAGKVKHzefWkyB7Hby5wQymfHT5v0xFXK9J20tiri8jbkJMs8nSRYve3lqlGIjbJgLL YDNANVKLh3liIGhCdCCIdFzTIKOgYSnm7PJHuZ8RaIyjdL5bL1gMeqNyIHdlKeRbXLUV Nq1lNazh4bbn+G064NnMlqvbmvRGqGJVp7JB06n7zVG6tZPMml6C417xNTPzDxwov2Hu FRPg0+J/3QINRDrkdZlLw37Ru4QG3LLGMJJKnbK+ADq9izrzEYac58iHG8g78btOF0ay cJiQ== 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=rq+p2LTPHHV9n8YEeLeTw07BaL5c8DCXhZTFZDUbhwY=; fh=7oD/n4X/Y6obJ5sNiygalPM+GdhXQm11o24u5QVjj2U=; b=wrmLtx74CwP6Qa75L6zEt+qOkLPmbL6lSc8PdzBJGkJYuu9vJWQmlGw6o9Y5XdPw33 Wv2HPG+ZGUE/SIePkCVCIE6+xfdyygDBTITwjRt6nbGQiBXwgsd8ODrsv8Uy/lfE/k9w ABrMRKMq6Dgtu8CVdsCav7PlwtQZ2ErxPnMG1X9s+HhJWbe8bPfAaNruOBv3oNJquJy1 Lleozv/0OV9PhR623cAIihYi8agKxgesS9V1Q5nkZADkInUxXbsUAiez/tdUNSiH1QAO 3XfRhGsYeHSJrBbesk+JTMy77pFBHD0xZ4T3iEcfC3jJDI+qgrL9TnR/nHXCfgjjgCmB Wt8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-19491-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19491-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id q8-20020a05620a0d8800b0078114cc3893si8127079qkl.37.2024.01.08.04.23.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 04:23:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19491-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; spf=pass (google.com: domain of linux-kernel+bounces-19491-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19491-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 3562A1C22356 for ; Mon, 8 Jan 2024 12:23:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 33F25405C1; Mon, 8 Jan 2024 12:23:22 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (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 7353C405C5 for ; Mon, 8 Jan 2024 12:23:18 +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.88.163]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4T7tTj174cz1Q7sX; Mon, 8 Jan 2024 20:21:45 +0800 (CST) Received: from kwepemm600003.china.huawei.com (unknown [7.193.23.202]) by mail.maildlp.com (Postfix) with ESMTPS id B9A401800C7; Mon, 8 Jan 2024 20:23:15 +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 20:23:15 +0800 From: Yang Jihong To: , , , , , CC: , , , Subject: [PATCH v2] hwtracing: hisi_ptt: Move type check to the beginning of hisi_ptt_pmu_event_init() Date: Mon, 8 Jan 2024 12:19:06 +0000 Message-ID: <20240108121906.3514820-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: dggems705-chm.china.huawei.com (10.3.19.182) 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. Fixes: ff0de066b463 ("hwtracing: hisi_ptt: Add trace function support for HiSilicon PCIe Tune and Trace device") Signed-off-by: Yang Jihong --- Changes since v1: - Add fixes tag. 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