Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp636510iog; Mon, 13 Jun 2022 09:36:28 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sRwz4Y5Ap6R9NvzZMOHgHtI9OCyJmSPGyoq3kUQCSwXXRulMlJwZW59hwj0TtbcLrNtP7e X-Received: by 2002:aa7:8008:0:b0:51a:cae3:7563 with SMTP id j8-20020aa78008000000b0051acae37563mr206258pfi.16.1655138188594; Mon, 13 Jun 2022 09:36:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655138188; cv=none; d=google.com; s=arc-20160816; b=Ptl/1C22xOumdY0ubYsR+kYTeLUf7ovd8tT1WWQqPaMeexSXREAZcQBqUo2WfR3Qae vGR0RXu3ePFMQXNkaXVWMjbJIgqBK9O3RuXNXnVarJYkYh0HDl9UNj+yB1oJaGv5iMp/ a2XEYovOu8dqJvhqse4E1Cj9/Z2YqjlcaEQt6lkbUlSP9ZXjVS3V6tB21zDhaAf8AERO qQyoUsYPzG4wEvGeF5P5gZ03VrIwaMR9slhGCHvhgOEAfOdz0gkH15raIJiOUd6tHusc H9tHFUXAEE7j7jn0K5GexB36KRnHheQUh6PiHdTpJFIsrRUbioOM7OxrFH2RvVvc3m8m guug== 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=WtVXNwUDvzjNSKmhxUBDaMBdFwAQFoZLz73ViiWsKc4=; b=duPGLY59+17IxNkA6ZGQZI9oIEcfG3AjB7d9KTzVKOvvR5so82vGRN1OCjTYsHtDVC Pai1DjCLFeBeOQQ7r1BHjACCzZQ2aTecP2Wr42NepuBIAS88S5jgFpUEXpFTCeJDs0bv nxS+aW9ISmBiUQ67gYokNcygdCah5tiyrWGqB+SkseSbqIUHJUkYuwyFcvc6QnhbNePF mBJQ3XYQzcdNKUwGe/IIp7C6dLQtE4Jt68l7vH8k5CNeVwzUg3t2x/vj7M98b03XvO+t FMeCWAUuWdH1g3sIpCDi6cm0eubpmjmEWYvobTJRfPrE0qtxWJm2Yk9U/8Q9sDDonmQg yLog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NxDoz3li; 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 p10-20020a17090a428a00b001e88d83b58esi12904909pjg.111.2022.06.13.09.36.15; Mon, 13 Jun 2022 09:36:28 -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=NxDoz3li; 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 S1357596AbiFMM7G (ORCPT + 99 others); Mon, 13 Jun 2022 08:59:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357954AbiFMMyu (ORCPT ); Mon, 13 Jun 2022 08:54:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D840C35846; Mon, 13 Jun 2022 04:13:44 -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 7607160B6B; Mon, 13 Jun 2022 11:13:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84C3FC3411C; Mon, 13 Jun 2022 11:13:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655118823; bh=KqkjIvkx5HlX5i4jYc8pDhcK00H0SUYu29p7uFCi2Ws=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NxDoz3liuOttmLdtGd4ulNEo9n9nqXak+Rp8hueG5v9iXtvoatNiQBjA8yjuEVpGB ZOtCS9J+Qcr/+cH+DWfqwwhereEEhcRgdvrfle4XESjtTmDvroInrk/9iWkOdhhMGC ydR1mI0wyBHacuMzLMu335/EqVnzmOXWbdmLu3cg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Leo Yan , Mathieu Poirier , Mike Leach , Suzuki K Poulose , "Guilherme G. Piccoli" , Sasha Levin Subject: [PATCH 5.15 040/247] coresight: cpu-debug: Replace mutex with mutex_trylock on panic notifier Date: Mon, 13 Jun 2022 12:09:02 +0200 Message-Id: <20220613094924.162601458@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094922.843438024@linuxfoundation.org> References: <20220613094922.843438024@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: Guilherme G. Piccoli [ Upstream commit 1adff542d67a2ed1120955cb219bfff8a9c53f59 ] The panic notifier infrastructure executes registered callbacks when a panic event happens - such callbacks are executed in atomic context, with interrupts and preemption disabled in the running CPU and all other CPUs disabled. That said, mutexes in such context are not a good idea. This patch replaces a regular mutex with a mutex_trylock safer approach; given the nature of the mutex used in the driver, it should be pretty uncommon being unable to acquire such mutex in the panic path, hence no functional change should be observed (and if it is, that would be likely a deadlock with the regular mutex). Fixes: 2227b7c74634 ("coresight: add support for CPU debug module") Cc: Leo Yan Cc: Mathieu Poirier Cc: Mike Leach Cc: Suzuki K Poulose Signed-off-by: Guilherme G. Piccoli Reviewed-by: Suzuki K Poulose Signed-off-by: Suzuki K Poulose Link: https://lore.kernel.org/r/20220427224924.592546-10-gpiccoli@igalia.com Signed-off-by: Sasha Levin --- drivers/hwtracing/coresight/coresight-cpu-debug.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-cpu-debug.c b/drivers/hwtracing/coresight/coresight-cpu-debug.c index 00de46565bc4..c60442970c2a 100644 --- a/drivers/hwtracing/coresight/coresight-cpu-debug.c +++ b/drivers/hwtracing/coresight/coresight-cpu-debug.c @@ -380,9 +380,10 @@ static int debug_notifier_call(struct notifier_block *self, int cpu; struct debug_drvdata *drvdata; - mutex_lock(&debug_lock); + /* Bail out if we can't acquire the mutex or the functionality is off */ + if (!mutex_trylock(&debug_lock)) + return NOTIFY_DONE; - /* Bail out if the functionality is disabled */ if (!debug_enable) goto skip_dump; @@ -401,7 +402,7 @@ static int debug_notifier_call(struct notifier_block *self, skip_dump: mutex_unlock(&debug_lock); - return 0; + return NOTIFY_DONE; } static struct notifier_block debug_notifier = { -- 2.35.1