Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp636169iog; Mon, 13 Jun 2022 09:35:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBFNYleO1gXtL7aC50x+SQCrMMXO99aNCSjkCzHDsmTNA9rsOVnbRfD1zetMcsK389g66X X-Received: by 2002:a62:a113:0:b0:51c:1b4c:38d1 with SMTP id b19-20020a62a113000000b0051c1b4c38d1mr175904pff.13.1655138159463; Mon, 13 Jun 2022 09:35:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655138159; cv=none; d=google.com; s=arc-20160816; b=ZPrLpg8GWCnZKcNqFhFsTH4VSn5ZAfHNCJeokGrOWsYWeqKfk6vGltwupj0eDH3152 fjAezeswsJ1wEVDQX/sc31Dzk5R4P55t3qf38HIbHYetQ2wxix36sgXif5dGqV1h98lX Y3wAPcBqD6E2K+48ifKx4jbFWn+qH26/ZRap0l4cBY1a+Wtm4fYRtMD5wgOdiNN8hjCv 2bS4bdOUy5euw8UloSkwWocCVkDuXe8GqNnGSI4zuxJq/wjf3fxAqOouIZBayb4nb3Bm GaKDIrazraHwSyecXrix3vC/swwmuqMW3POmB8VU1Nka3hG78wBpecTRrGTwJ8hwr84X LI0g== 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=tEUtDTOBLe+PXwupZzBU6X/08CUFBSOZ57TFDrYbzzs=; b=eX3qxGHQ/HLerLly6/mcbH61PCzZt3W04xAIN+jniN5+BrsjynC4xRcHmarkuWSnjf q/2leZw3vvFtjeqHNbt77fb+X73exN99VDrZOAxXNNbUoQN+NysBk4BqOSfj74QQbQJs HaqL0tNQQhKBmF57hoF+YTrqhBvnbbkUyLGE3a3kT9/Zf4iInjwbN2DlCN6aGnSxSDkj lWiXdeEOxBkdcxLWZJWBaP+YTeGE6+OSkywUjzVP5S6OWAzKMAu5QzYyNLtvXkn/UUe+ xT5/N27d8IIlLIk4GKcaSNVub8pj91N9KmBxv7aBPi20sMnqSfMP1KBQTYs1C0yKYeh0 7Nfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=e7qjBrmS; 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 z28-20020a630a5c000000b003fe49e8de38si11332286pgk.409.2022.06.13.09.35.47; Mon, 13 Jun 2022 09:35:59 -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=e7qjBrmS; 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 S1350780AbiFMMMg (ORCPT + 99 others); Mon, 13 Jun 2022 08:12:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359088AbiFMMJA (ORCPT ); Mon, 13 Jun 2022 08:09:00 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE5CF527E9; Mon, 13 Jun 2022 04:00:33 -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 sin.source.kernel.org (Postfix) with ESMTPS id 50D8DCE1176; Mon, 13 Jun 2022 11:00:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33F2FC34114; Mon, 13 Jun 2022 11:00:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655118022; bh=BuYpkRohhh6zgzbDCXf9vLh18Y+3V8DmdGwu0Fm7HNk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e7qjBrmScmpy1VpBVM8rHSf5BI4k0MiHuOjHmC90YbaEGrZ5n1EAwhGj3DBo/GvLh j7G7fXJVuiXOVI6ozg0HK8+iO4gxvwMpV0hHR8MX1bTExg5UIL05+3g0MI6uLDiNSD EMAI9k2zw7LUZnfWFJNwWo3LG61sX+xhM3T0enxE= 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 4.19 201/287] coresight: cpu-debug: Replace mutex with mutex_trylock on panic notifier Date: Mon, 13 Jun 2022 12:10:25 +0200 Message-Id: <20220613094929.958548258@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094923.832156175@linuxfoundation.org> References: <20220613094923.832156175@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 e8819d750938..a4eba09691b4 100644 --- a/drivers/hwtracing/coresight/coresight-cpu-debug.c +++ b/drivers/hwtracing/coresight/coresight-cpu-debug.c @@ -379,9 +379,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; @@ -400,7 +401,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