From patchwork Mon Jan 8 11:20:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Jihong X-Patchwork-Id: 185912 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp955166dyq; Mon, 8 Jan 2024 03:25:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IF27lFLDtnnlLQuAe0GWM0yYXU5fAF+8q1LEc/Cz0J6zKCpnDSBnhwhZMUZ9GlDChqyETvu X-Received: by 2002:a92:c547:0:b0:35d:5995:1d71 with SMTP id a7-20020a92c547000000b0035d59951d71mr5547365ilj.54.1704713149292; Mon, 08 Jan 2024 03:25:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704713149; cv=none; d=google.com; s=arc-20160816; b=v1p6bmkhtYpYT44VADCtVw2vn5T5nPFDoSIascvEB18vqQQ3Pubw6FMshBU2HecLXk TDtGxSVVuV36qmAhCsSExwJ5QRCDw13TIMs1sZhWzb0okNm28C1YPLC9EXOyph5VFxvi pSNK98c3zdcxx7s3/zcOcWGGZB+htUSE8lrbnYTgVbXbXk3TJ7Z738OT4n2+srRDr5ax Ih9L5672ziYmU4PnrMYGYhJ/+b+ognf3YEs2qHYdUTg7StmDF7s0ibznjbvrLU8tLF5a exrRB3tH+i0M+GLD1oeCWqrB7bW/nHPFWaBf0/MsmthRY833ufvJELX2oWM3qt5vFtFZ CiNw== 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19416-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id l7-20020a6542c7000000b005cd84b844e7si5719949pgp.406.2024.01.08.03.25.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 03:25:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19416-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-19416-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19416-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 146972825FB for ; Mon, 8 Jan 2024 11:25:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 17D2A321AC; Mon, 8 Jan 2024 11:24:42 +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 X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemm600003.china.huawei.com (7.193.23.202) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787521295226578929 X-GMAIL-MSGID: 1787521295226578929 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;