From patchwork Tue May 10 10:26:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tanmay Jagdale X-Patchwork-Id: 12844771 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 58ECAC433FE for ; Tue, 10 May 2022 10:28:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=oEb/6VoFM9HhOtNbM9/jQS64RnYJ88ye+x5QusvUvLY=; b=smuHalNgPoHJPc Xl8culj99W114/jRQbX0nOa+JhSqeNbgYd9DuylIfj7m6JHER4vwllOah77iia/ITlNy5AEiQNJzt dAWPQwS0+AuBRloZpixiTZ5A9VSSHajDEbvyh/bamCeHsNi4DtMKKWuegeJO1JAnHfRxclgUPAk2v apxV60XHdYKUSQahK1YayMHiQRT/vmRtjRoXA0inHIwWXEbz9pHsTx9ObaTO8xS1m4/FoZJFaZYU1 p1EJd/vG6hhTBS+3PmCb8RFez2pvR1Dz684KvPu+jmxrGhimdfrUo9u3IW6vJzB0SdS0kGBeY8QdC 13tUp9C1GG0y/1duJaNw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1noN5c-001BWF-JR; Tue, 10 May 2022 10:27:36 +0000 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174] helo=mx0b-0016f401.pphosted.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1noN5S-001BNs-AB for linux-arm-kernel@lists.infradead.org; Tue, 10 May 2022 10:27:27 +0000 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24AA83di031186; Tue, 10 May 2022 03:27:17 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=0Hl5ghIdZdkU4k6qCypCHdoG8Gw3tiISfSLVKrcPEf8=; b=S2Vgv/3Gcx2Vzvy8+SAhnxk/3gmlqLl9jkK7IEjz4y8iMSxnrw0aO9dAc4Oo1gYiLiRS Oj/clCnWBhXheRKybjiOOxT4a85w0beNKcEGrb4O9AgWUpmPvhzmZgsFayHABvR3ZQi7 EvBwR82CdvAA+AJjv/NMUbOCWoFonMdg1+YpcUgAQQoUJxFTLiFLBUy0anKCFSMtWiNE JuKzf9UAbZNmFiB08Z0LKAhdx2Wduv1CA06WP3MppFLarjajxztV9vpBRG/vTTl/A7ZW ixNCXNxfoCBpg5aSU2Er8IsUfMGtTkDVwsWUtYGLHhIdezUV7NYqdgkmaofWXgEdOshU Vw== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3fyp1br1ta-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 10 May 2022 03:27:16 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 10 May 2022 03:27:15 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 10 May 2022 03:27:15 -0700 Received: from BG-SER530.marvell.com (BG-SER530.marvell.com [10.28.8.21]) by maili.marvell.com (Postfix) with ESMTP id E4D203F70A2; Tue, 10 May 2022 03:27:12 -0700 (PDT) From: Tanmay Jagdale To: , CC: , , , , , Tanmay Jagdale Subject: [PATCH] perf/marvell_cn10k: Fix tad_pmu_event_init() to check pmu type first Date: Tue, 10 May 2022 15:56:57 +0530 Message-ID: <20220510102657.487539-1-tanmay@marvell.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Proofpoint-GUID: jD1xn7UF0fqxBDyQrEgZmMuwCVBYL4gC X-Proofpoint-ORIG-GUID: jD1xn7UF0fqxBDyQrEgZmMuwCVBYL4gC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-10_01,2022-05-10_01,2022-02-23_01 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220510_032726_417894_A1F1D2C9 X-CRM114-Status: GOOD ( 15.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Make sure to check the pmu type first and then check event->attr.disabled. Doing so would avoid reading the disabled attribute of an event that is not handled by TAD PMU. Signed-off-by: Tanmay Jagdale --- drivers/perf/marvell_cn10k_tad_pmu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/perf/marvell_cn10k_tad_pmu.c b/drivers/perf/marvell_cn10k_tad_pmu.c index ee67305f822d..282d3a071a67 100644 --- a/drivers/perf/marvell_cn10k_tad_pmu.c +++ b/drivers/perf/marvell_cn10k_tad_pmu.c @@ -146,12 +146,12 @@ static int tad_pmu_event_init(struct perf_event *event) { struct tad_pmu *tad_pmu = to_tad_pmu(event->pmu); - if (!event->attr.disabled) - return -EINVAL; - if (event->attr.type != event->pmu->type) return -ENOENT; + if (!event->attr.disabled) + return -EINVAL; + if (event->state != PERF_EVENT_STATE_OFF) return -EINVAL;