Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2262488iof; Wed, 8 Jun 2022 00:46:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyay6IjXBY/WQugpdvP8pFSyW65OJE+duwsNgJ2LMjWsgdpfQeZhWojFP2RGI3hO1dfl/cQ X-Received: by 2002:a17:902:e88b:b0:166:3f77:eb76 with SMTP id w11-20020a170902e88b00b001663f77eb76mr31639408plg.11.1654674413604; Wed, 08 Jun 2022 00:46:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654674413; cv=none; d=google.com; s=arc-20160816; b=hssIklksqr8+8hzxsIwKmw2y3xDR/Y1pbVm1OXS8E5oWSoVrFryo70NksvDlc8c03O SFV7uLgliyg8TkqRXkE5b61GEgLLXnmQAA1stSOrMc+kJfGi+AQlb7aazU+3UcfTdbu4 CwJP7MKSd5l61444aUpohU7nSsnQpWwuLGJUC22QYcOjibu7W992zOJdwXQDbyGaelyf lfEkgsBKkBoLsOt2axdiY5sKkB2y2kJpu8j/I0LC85CNKSpu7j2jCgPVuZYPzIX1Y+LE 6mbcpbnQDNwHGJN7opIqtzNuWUKDv7ybldTeqDzIr7uGujaDSUEnznVQbVNN1xOy0w8T iJdw== 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=dbhyE4boxKGRxbCZ0MWodYjnMN1e0psHQlFSza3AsdY=; b=HwkrUxywI9oI6zTe3ZrG54cnq7lWTDLc5GTim60u2rdzUnR5sKjzV34gPswu6gNBPs 9iEukhF+xRDZSIFm5mEn0vjA5fMHHB8atDwO7R4lewzuA94+AExEwq2j0iqIwOHM6zDi ghJphhPVoWU3HcdV7UhDX5p9UqLd6qBK13kz2kMCe/ZFBIQAnbPqiRTKo+ctaHTJz3j8 YOHY3+Zoa4bH5VIumIYU3onKR7g1+BMxYWZlgectJMdzbYrxCbZwg2EpZgaUdaU+n2BT zB98b/ctcQkGoSIMsv+2j59KrVijCDkxhwVP3tSR6y5YpXOD6mG93wMXxeeAHXEUO9b6 /0IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RkQ0cJeY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i14-20020a17090332ce00b00163ad368fe7si26971717plr.71.2022.06.08.00.46.38; Wed, 08 Jun 2022 00:46:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RkQ0cJeY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384160AbiFGWNk (ORCPT + 99 others); Tue, 7 Jun 2022 18:13:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379883AbiFGVLI (ORCPT ); Tue, 7 Jun 2022 17:11:08 -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 6D49D21629E; Tue, 7 Jun 2022 11:52:23 -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 E3D286156D; Tue, 7 Jun 2022 18:52:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04385C385A2; Tue, 7 Jun 2022 18:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654627942; bh=sbZJ/EgR/Q6h7bQ8bXYkdHk3sVPiz5d14IrGMh6M1ls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RkQ0cJeYiIpbknQTHCz34yPra8oATCa5cJLJ6yXuzls+XJ4BPvB4UCyo/6JpCnGSs cG+omIN2vPS9+1sePQf0VIk1R0wVC6y5TKH50EhZ5B/Zob52fXH2LUo0Mn9TqX/nYs jWWaG2JxYaqgBySILnUH7XFORVb/I+qB2N993wEo= 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.18 147/879] perf/amd/ibs: Cascade pmu init functions return value Date: Tue, 7 Jun 2022 18:54:25 +0200 Message-Id: <20220607165006.971472877@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@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=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 9739019d4b67..367ca899e6e8 100644 --- a/arch/x86/events/amd/ibs.c +++ b/arch/x86/events/amd/ibs.c @@ -759,9 +759,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 @@ -773,7 +774,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; @@ -786,15 +789,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 @@ -1064,9 +1087,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