Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2288634iof; Wed, 8 Jun 2022 01:31:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzV9dgWojW0EIYDjAakaV+3Yl5CMKgAdg3KNsZAfi6MvATnabS+A7VieMWH3mCisJKDSXns X-Received: by 2002:a05:6a00:882:b0:510:a043:d4bc with SMTP id q2-20020a056a00088200b00510a043d4bcmr33826232pfj.64.1654677076344; Wed, 08 Jun 2022 01:31:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654677076; cv=none; d=google.com; s=arc-20160816; b=JJx3mrDOVYz4XB1gSL4x4ODJ1oMfU6k4z5t9BZsrKsKrbxcW/uFsyl5kShxb34m26U kJLO8Ph4BbzCdMEj5rU/skF0bf9zGrrmddDvHXsi+i4X/kTGeMTnVIO238VXapBJdxQp Ryfxb3Kkxbq8G15wBlxJ/2a1pk+Wwi0OP4o8o0rsNtK6CxXET8U0jnxBblIJIoOXuB8U BV9R08NxNWNorzIp0PcHWuFEF9soMnM44PNK40cAZfYCA+3vmk77hqcVMIiihV/3qjUS wFTjunuHKeri9ykHpKmo7NXwNdkFDePSgRpHMFLKrEbc4AWN58Korm1U1e8zbrmpPP/Q 4Iug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vGLEroORN4uyZ8EeOuXmaeaEbiRaEI9LOC00uUX/zzw=; b=W8M5LEqhrVnHi/GOQr8byWjSErM/0BXWJm9gqIw/5Sm+D0nOyVwBzHxHgKyQ912THa gr4kn/0OWoUVw2ueKBEJmM3YIl6QHXgnvCgb5kHdob+6Q5vgUjE1FFB8LC6QpE7bC62Q vMTALyShoNSu8nIViOKkFNpW5gYr7zQPgwbRYhyPOvO76YuhAqYlm6kDdjWnc0UmU1Gq emeguS8G3fNNiOmfiusByXjV6GwWUd0kCA4qMyO1lv/fTxKDjeV4HjLFVa6qdhSzngqo he1+HCoxkW+JJPw60nAS1dw1WKREgyHWFNH9rL+1UAj+iuUf1gqw86k51Xh0kNLzbIN5 S/Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uVBLFLBa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u6-20020a17090282c600b0016180d0eecdsi25352356plz.52.2022.06.08.01.31.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 01:31:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uVBLFLBa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 61C2F59947; Wed, 8 Jun 2022 00:59:36 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346368AbiFGR1r (ORCPT + 99 others); Tue, 7 Jun 2022 13:27:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346347AbiFGRXn (ORCPT ); Tue, 7 Jun 2022 13:23:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02EF210A639; Tue, 7 Jun 2022 10:21:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 931746009B; Tue, 7 Jun 2022 17:21:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98B0FC385A5; Tue, 7 Jun 2022 17:21:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654622517; bh=lnFWTkPmB85aDeslaT/hBp9DroN6KQakjVzon6SCK3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uVBLFLBaNNvTELkyYmhF7aJMb/Jo6Oq98CXq64QxPBIIYFL623fp1RjUBpQS1niQK fJohdb8/NpFd+fCAbWDCfADZkJ7b9VblYVhtGgIAjLMzCsc9/jO3jPtssaWVz0Yej6 6gXxruNoNz2Wi57qeFjkDVG/upI/cCyCPkwNn9h0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ravi Bangoria , "Peter Zijlstra (Intel)" , Sasha Levin Subject: [PATCH 5.10 070/452] perf/amd/ibs: Cascade pmu init functions return value Date: Tue, 7 Jun 2022 18:58:47 +0200 Message-Id: <20220607164910.635944015@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164908.521895282@linuxfoundation.org> References: <20220607164908.521895282@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ravi Bangoria [ Upstream commit 39b2ca75eec8a33e2ffdb8aa0c4840ec3e3b472c ] IBS pmu initialization code ignores return value provided by callee functions. Fix it. Signed-off-by: Ravi Bangoria Signed-off-by: Peter Zijlstra (Intel) Link: https://lore.kernel.org/r/20220509044914.1473-2-ravi.bangoria@amd.com Signed-off-by: Sasha Levin --- arch/x86/events/amd/ibs.c | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c index ccc9ee1971e8..780d89d2ae32 100644 --- a/arch/x86/events/amd/ibs.c +++ b/arch/x86/events/amd/ibs.c @@ -764,9 +764,10 @@ static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name) return ret; } -static __init void perf_event_ibs_init(void) +static __init int perf_event_ibs_init(void) { struct attribute **attr = ibs_op_format_attrs; + int ret; /* * Some chips fail to reset the fetch count when it is written; instead @@ -778,7 +779,9 @@ static __init void perf_event_ibs_init(void) if (boot_cpu_data.x86 == 0x19 && boot_cpu_data.x86_model < 0x10) perf_ibs_fetch.fetch_ignore_if_zero_rip = 1; - perf_ibs_pmu_init(&perf_ibs_fetch, "ibs_fetch"); + ret = perf_ibs_pmu_init(&perf_ibs_fetch, "ibs_fetch"); + if (ret) + return ret; if (ibs_caps & IBS_CAPS_OPCNT) { perf_ibs_op.config_mask |= IBS_OP_CNT_CTL; @@ -791,15 +794,35 @@ static __init void perf_event_ibs_init(void) perf_ibs_op.cnt_mask |= IBS_OP_MAX_CNT_EXT_MASK; } - perf_ibs_pmu_init(&perf_ibs_op, "ibs_op"); + ret = perf_ibs_pmu_init(&perf_ibs_op, "ibs_op"); + if (ret) + goto err_op; + + ret = register_nmi_handler(NMI_LOCAL, perf_ibs_nmi_handler, 0, "perf_ibs"); + if (ret) + goto err_nmi; - register_nmi_handler(NMI_LOCAL, perf_ibs_nmi_handler, 0, "perf_ibs"); pr_info("perf: AMD IBS detected (0x%08x)\n", ibs_caps); + return 0; + +err_nmi: + perf_pmu_unregister(&perf_ibs_op.pmu); + free_percpu(perf_ibs_op.pcpu); + perf_ibs_op.pcpu = NULL; +err_op: + perf_pmu_unregister(&perf_ibs_fetch.pmu); + free_percpu(perf_ibs_fetch.pcpu); + perf_ibs_fetch.pcpu = NULL; + + return ret; } #else /* defined(CONFIG_PERF_EVENTS) && defined(CONFIG_CPU_SUP_AMD) */ -static __init void perf_event_ibs_init(void) { } +static __init int perf_event_ibs_init(void) +{ + return 0; +} #endif @@ -1069,9 +1092,7 @@ static __init int amd_ibs_init(void) x86_pmu_amd_ibs_starting_cpu, x86_pmu_amd_ibs_dying_cpu); - perf_event_ibs_init(); - - return 0; + return perf_event_ibs_init(); } /* Since we need the pci subsystem to init ibs we can't do this earlier: */ -- 2.35.1