Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp927280rwe; Thu, 1 Sep 2022 09:37:32 -0700 (PDT) X-Google-Smtp-Source: AA6agR4Jx6+ihX5x8gqHpd6lk8APaNiBTZ+4t+iQoj3G5RwxQ9rRHMkt5sLlj/3fzojplsfq4Woz X-Received: by 2002:a17:906:ee89:b0:73d:70c5:1a4e with SMTP id wt9-20020a170906ee8900b0073d70c51a4emr23308575ejb.683.1662050252613; Thu, 01 Sep 2022 09:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662050252; cv=none; d=google.com; s=arc-20160816; b=GUuWSDmB0/dA28IP1q/KmoEFPQNQV79hYosQz79oiTY6TnNoZU1wokfhmjznkB29Fm pKQars2iNdv4NopEmelyXkc6q/8bOKwwZr6PQlcbVGWDIUVC5JmbEzyvi9TXimaEGjIl lc+C0kx26bppDitoo9Vmf8uhUMpHDQ02W3jsLBDhkypjKcWFQLID5DksFzj0BNn1mwaS aEDAOolHkr5DPRV+402qiPAhwbN67JqZzAVfHlDrXjurCvFddEQeztOKLmb1faJM09VW oQ5b2ZiERPhDWJIrUT+470Ocmgja2OUyk4LwOXNQLL9ggkfgMJKnOqxGgyWcRb0KfjE1 lnDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=oaaEzGe48rQOZZkPwbRabi4a7HwDoRcH1qyMGnreP6o=; b=TBlkpWbOOzkOCQXfWnQDrf3nB1VUYD6ePx4dRw5uavS8SDiQw023st/wIaWWMRFRH5 bYASog9tXfMdS5bIaAWMX4yh7Ljk0ksTIHn0C1wa6cd6PAz1mpv5rTdGz0T08+OURYWo qVvjI2D+ENR+RuDzNEbyX+I+uLD7T34PvYr+h71g9oBBn8XYqc9Gl8tQX6+UJ3OR9xBy fusDsS9stdCAchyZPbHpe72aAVczpr/rRbYKT6T4thWuFUZGv+oe35injhy0hg9M5VJn LY+7z6jVvWsz3LJTVagsrFwF+VHGpHbf7z838Mfi0EIOqpolkyYvrVlEAYXXMc2dPVru 2Ejg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=TNeAKdDp; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eg55-20020a05640228b700b00445d2524d42si1548093edb.493.2022.09.01.09.37.05; Thu, 01 Sep 2022 09:37:32 -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=fail header.i=@igalia.com header.s=20170329 header.b=TNeAKdDp; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234761AbiIAQAM (ORCPT + 99 others); Thu, 1 Sep 2022 12:00:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233568AbiIAQAE (ORCPT ); Thu, 1 Sep 2022 12:00:04 -0400 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D82C1402C; Thu, 1 Sep 2022 08:59:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=oaaEzGe48rQOZZkPwbRabi4a7HwDoRcH1qyMGnreP6o=; b=TNeAKdDphsY167amWFDivtvHcx QOkff0372Cyn1lw7ET6tMcbvafqkTEugQHob8Zrge9n4lDOjCa+LdHXg1VvoPv28XZE/EC28GzBKv OY1LUmCmgF9oXxmBaelyaP4OEl+ud3lR0TQkmH3cfFiQKoW0tx8SplmtuI3eqfRUbBtJipnMpchYk YhpVIhWI9FRx1Vbx1HKF0SUgl6hT6aDiJVBhBkP9dQcC8F9wY4sRQl6VvQlT9UqbYNNPaocpyufti Lil932NQEs/8A3YtMSPRPZU9HHkFANEivFIW6nPwc95q2WVtIGx/LA8q1b6dBodk1ojG01dbLMaKa fQD4Lfsg==; Received: from 189-69-202-182.dial-up.telesp.net.br ([189.69.202.182] helo=[192.168.1.60]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_128_GCM:128) (Exim) id 1oTmbh-007pDD-Iz; Thu, 01 Sep 2022 17:59:53 +0200 Message-ID: Date: Thu, 1 Sep 2022 12:59:36 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH V3] firmware: google: Test spinlock on panic path to avoid lockups Content-Language: en-US To: Greg KH , evgreen@chromium.org Cc: arnd@arndb.de, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@gpiccoli.net, ardb@kernel.org, davidgow@google.com, jwerner@chromium.org, Petr Mladek References: <20220819155059.451674-1-gpiccoli@igalia.com> From: "Guilherme G. Piccoli" In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,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 + Petr, since this was extensively discussed in the original thread [0] and maybe he can help with the argument. [0] https://lore.kernel.org/lkml/20220427224924.592546-1-gpiccoli@igalia.com/ On 01/09/2022 12:52, Greg KH wrote: > [...] >> + * Perform the lock check before effectively trying >> + * to acquire it on gsmi_shutdown_reason() to avoid >> + * potential lockups in atomic context. >> + */ >> + if (spin_is_locked(&gsmi_dev.lock)) >> + return NOTIFY_DONE; >> + > > What happens if the lock is grabbed right after testing for it? > Shouldn't you use lockdep_assert_held() instead as the documentation > says to? How, if in this point only a single CPU (this one, executing the code) is running? Remember this is the panic path - before this point we disabled all other CPUs, except this one executing the code. So, either the lock was taken (and we bail), or it wasn't and it's safe to continue.