Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5611434rdb; Sun, 17 Sep 2023 04:56:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHWVUIbc0KFYqXC2oXu46tjIA+rt+5sPUcgvYLVNfUXir30pVcbCbJkKgZk5zX9OK7E8hGP X-Received: by 2002:a05:6830:2:b0:6c0:7bab:28ed with SMTP id c2-20020a056830000200b006c07bab28edmr7974429otp.16.1694951772588; Sun, 17 Sep 2023 04:56:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694951772; cv=none; d=google.com; s=arc-20160816; b=LgeDgBd5fXoBrCHceGI2ghhEXlsBJOrrA0lmHEAHPYOZxFdrv0+HYQOPlIVvnYKV3h me8R1MqIB2p8w9QXe6s+qL/XHU/wf0/vc2FVXxn/MjhJmqZuWvi+P4ORGHwImyaRBru7 prXX7CF8rGtcD0Xf5LPXy0LlK+GoishQ8OCNzp0g/z3D1tEnC2+Khj9cvms2OFPbvqtw Y2rcQrD82Q9AvFqlGk6wTuey4/6DrjpSHlNOQs4GuttSM3Mq7jm6y7igV7FFTC513UQ8 chJSiYM9TZu6lsT7zuCfzotz/T9P0IZqsyzN4PpWbVdpkZyatyw2hGkAmHDWeyN6A4G7 +Yug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/WcRQDyymxrmKlAwCq58SlWkxN9TtQEV0p/55CuAxes=; fh=kgg1KL1MueFrjulmlx6lcdmFve/3bK17AhQe3qmcPg0=; b=e6HDQO15I0RxoHxJPczx91/4LaloXT2b7L4W6e/wld/0U4g3z5Yjhl3zm3PUoPmjjX fpzUNgtqfFtP4BgwFWq/7cP1+GEUFCpMy4NvQWJpw1k2DE8yJtYVh+ArMtMi4ea0Ox3y vE6YPEEkEEUcSMd44hB2jRjo9roZg0Xk3OGgpCj28zakotY0K4qrVWSowFqDexDxZH5P ub+Ipw5/cBUxE1VWVCxPXgF16NNdkcYPwFI3pO6ymM57pHIpnnmFmj4NJB/KazLFBppW bsbBc5Ejc0SW/tn7tNMqWSiXic02nWMpI7CSrxRZ73tN7WKyJbujWxcstaOc/gqQP71W Q8qA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IE2A6HVd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id y63-20020a638a42000000b00573f99f3d6esi6406308pgd.655.2023.09.17.04.56.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 04:56:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IE2A6HVd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 139748037965; Sun, 17 Sep 2023 03:13:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236559AbjIQKMt (ORCPT + 99 others); Sun, 17 Sep 2023 06:12:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236589AbjIQKM1 (ORCPT ); Sun, 17 Sep 2023 06:12:27 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1AFE18E for ; Sun, 17 Sep 2023 03:12:21 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB8CFC433C8; Sun, 17 Sep 2023 10:12:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1694945541; bh=Vz8TqJ5fsUVWBLlxF+L0vgftJ77qy5DyQpFe/T5uDSA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IE2A6HVdA9KavFz4dMfFOepJ9/8SSmeIB+lV5zTQ5vWljEypbJEsJzdSWTLKoaapa dWiRE76rvsvkyyPMOAaR263XKCunZTVKrYdz/p7oSrkjcyJT22/xBgngWvXMjxNh12 V2ihRnpn/Qyz7vNvpie2bpUArdx9wvOcgSd6iY5w= Date: Sun, 17 Sep 2023 12:12:18 +0200 From: Greg KH To: Mukesh Ojha Cc: mcgrof@kernel.org, russell.h.weight@intel.com, rafael@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] firmware_loader: Add reboot_in_progress for user helper path Message-ID: <2023091727-clever-schilling-3814@gregkh> References: <1694773288-15755-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1694773288-15755-1-git-send-email-quic_mojha@quicinc.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sun, 17 Sep 2023 03:13:44 -0700 (PDT) On Fri, Sep 15, 2023 at 03:51:28PM +0530, Mukesh Ojha wrote: > There could be following scenario where there is a ongoing reboot > is going from processA which tries to call all the reboot notifier > callback and one of them is firmware reboot call which tries to > abort all the ongoing firmware userspace request under fw_lock > but there could be another processB which tries to do request > firmware, which came just after abort done from ProcessA and > ask for userspace to load the firmware and this can stop the > ongoing reboot ProcessA to stall for next 60s(default timeout) > which may be expected behaviour everyone like to see, instead > we should abort every request which came after once firmware > marks reboot notification. > > ProcessA ProcessB > > kernel_restart_prepare > blocking_notifier_call_chain > fw_shutdown_notify > kill_pending_fw_fallback_reqs > __fw_load_abort > fw_state_aborted request_firmware > __fw_state_set firmware_fallback_sysfs > ... fw_load_from_user_helper > .. ... > . .. > usermodehelper_read_trylock > fw_load_sysfs_fallback > fw_sysfs_wait_timeout > usermodehelper_disable > __usermodehelper_disable > down_write() > > Signed-off-by: Mukesh Ojha > --- > drivers/base/firmware_loader/fallback.c | 2 +- > drivers/base/firmware_loader/firmware.h | 1 + > drivers/base/firmware_loader/main.c | 2 ++ > 3 files changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/base/firmware_loader/fallback.c b/drivers/base/firmware_loader/fallback.c > index bf68e3947814..a5546aeea91f 100644 > --- a/drivers/base/firmware_loader/fallback.c > +++ b/drivers/base/firmware_loader/fallback.c > @@ -86,7 +86,7 @@ static int fw_load_sysfs_fallback(struct fw_sysfs *fw_sysfs, long timeout) > } > > mutex_lock(&fw_lock); > - if (fw_state_is_aborted(fw_priv)) { > + if (reboot_in_progress || fw_state_is_aborted(fw_priv)) { > mutex_unlock(&fw_lock); > retval = -EINTR; > goto out; What prevents reboot_in_progress to change right after you check it here? And what kernel driver is trying to call the reboot notifier that gets mixed up in this? Why not fix that driver to not need the reboot notifier at all (hint, I really doubt it needs it...) > --- a/drivers/base/firmware_loader/main.c > +++ b/drivers/base/firmware_loader/main.c > @@ -93,6 +93,7 @@ static inline struct fw_priv *to_fw_priv(struct kref *ref) > DEFINE_MUTEX(fw_lock); > > struct firmware_cache fw_cache; > +bool reboot_in_progress; Bad global name for a variable in the firmware_loader core. thanks, greg k-h