Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp448194iog; Mon, 13 Jun 2022 06:10:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyovqVhg37z2NiSUYBZZmftHznKVQKjN9Yus2ijspLpDeplWpHUTNWyeOpZTT0FurioNSeR X-Received: by 2002:a17:906:72c5:b0:711:d2cb:28b0 with SMTP id m5-20020a17090672c500b00711d2cb28b0mr34789398ejl.229.1655125732239; Mon, 13 Jun 2022 06:08:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125732; cv=none; d=google.com; s=arc-20160816; b=zDzAMLo7vCyfi4bULYnMlePEMubOLwYdRjPY5dm+RpAFPjhmWBi9Dx4S2arPVI8P9T jny0eXysBeqCJ7PP7rIuUfj2jcCPIhaQ1JVoC9LHBlSdTaJIWtzrK/cX0kKx6DdS4xgB I4E/UI0JCtgY5Q/AuHfBn62Q2/AuZlWzOBMDaLsFhFQSztNTIwHuj6Ha1OgiJNByZ7OH UB2IJi0+fzu+3xA+4HS2DoY4thUnLQ/a4ezlx9djieYR8ChK6uLENJbAyqgx6poBm/20 J772qQqlLUufRuhYPySp6sTOUS4DiWarcO0KJcoVA4BmJKKSBzsbFqh/5N8odGAsYdaQ ESRg== 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=21oTdqY0WkenbFwKIWD82YTFiq26MHwY1AsPeBjmuCo=; b=Uakr92h6tzug/eEnEt9ue2G4Xnd8xCoFlRr8gFr/9b0lDLP8ElTeK1MWhNPce9hfaj u+JXge2VISUm2DWpjTKv7Fz0JMjgYQQe7o7kLVT6ra+atBcnnGz8hgtCjh87oT49iZ6C eQJYnVVwD5e3ZrNJCUICKBale9QgRKvJatjhNGhT7pJcThiEmHyKmRMzOhkZswzl97DL q88aRWzDBToKNHcqdfZomZC6ByLles3toxLlKf/W3CalObrX1HKoqJgNzzYXxl900dTG xGgbqAfeJ6nOz3MwS4NxnvKQa1v3qNBuxFBAqrA3SMKRfySDdevhFlGZttM5DFtSyvb0 VR4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HT9M73gU; 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 c12-20020a50f60c000000b0042bccec3bacsi8346062edn.94.2022.06.13.06.08.22; Mon, 13 Jun 2022 06:08:52 -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=HT9M73gU; 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 S1354519AbiFMLhJ (ORCPT + 99 others); Mon, 13 Jun 2022 07:37:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354775AbiFMLaH (ORCPT ); Mon, 13 Jun 2022 07:30:07 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28D543F883; Mon, 13 Jun 2022 03:45:40 -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 ams.source.kernel.org (Postfix) with ESMTPS id A8144B80D3F; Mon, 13 Jun 2022 10:45:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C67DC385A5; Mon, 13 Jun 2022 10:45:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655117137; bh=dbYW1G1XHi9kOOSHtZgBJpuzq61XOfENbc+JceeultI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HT9M73gUaNecgfBQNQTebouEugGJ9W4QClWAP3CyqJo/A7o9nP/tkf6QtM0x1dOJL DYYRw99r97N1L6hZ1Pe0wBDIw6KkuQgkRD2K5nmL+Bvkr8mowYWOeeglvQecktE6Nc wIM7eqi7NfVYf/tECzFPkXvm6fK+78JtGSwp4O4w= 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.4 302/411] coresight: cpu-debug: Replace mutex with mutex_trylock on panic notifier Date: Mon, 13 Jun 2022 12:09:35 +0200 Message-Id: <20220613094937.810485181@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@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 96544b348c27..ebe34fd6adb0 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