Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp775816pxb; Thu, 24 Mar 2022 06:49:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy34cs12lQUf7Hu384CXb2t4SKtVh5RUvDBLLabC5Kmol3Kfe6oeqnYxJri/eZP2JdHDntu X-Received: by 2002:a63:1112:0:b0:380:7ef:1f1c with SMTP id g18-20020a631112000000b0038007ef1f1cmr4201365pgl.152.1648129745893; Thu, 24 Mar 2022 06:49:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648129745; cv=none; d=google.com; s=arc-20160816; b=BzXoFI+aSjKP8GEnAVkgxEKmVHRiuOd8RRvFGFKO/W4Vl+ofFy9KYD4b3ailYDhSxd Zo+ZZQSLACvMQih804ZmP/LLuqmoHTr5Gh+3EaOz7nHZxRzVCQFtjZk4AdPbMyJM+/MF JNrF2X0Sz4QKINPpQJBRQJV+4QZvMFO65ZhJfXRWPwgHjoMOxDMQ2dvAUJeflXHryVjo CfWWIBftMwPYmwUM4PIRalz1XgXBkqpdf6oEpadpYSYj6819u3Fgoc8f/X9WeZxY4RuV aSJe3eYGWRgAeiFaF001jJW1buUwvZf6P2sZC2ntorO8hPzI2DC4scFAm3yJc/rSlodI oCzQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KFrmcYIFddkTdA8lFM1HVY0WBZTifgjscMfeICEK58s=; b=JVQwz0SSKohMh4Qhpsh8iFO7k3dczPy6vEf5J0Rle5ImdIBaZfd3c5TcmH6/QVO+0Y NUNDLlW46I7hwQWfHqOCKHA0COr7jNP61OoBzumFUXNTd2GRewpN5a0UhdbQOkCeVg9t zPrdlKYRQCe7/LOgKPNSatMA5nkZLvIgJ71z+VGh/Tk6BQAVRGlqH7DT6zwiAaTbiEaR VrHSuGagryKeb8anj7fW1io2jKSElcR1Uvb3yc+iFCGIGMKD8WlDSd3hkHFTkYts+jMC RyQcZefVuB3/MMbNqs6gETez5ZDMUmPCKEEWF1xWg7MZJ8mJgje0L4uD1/XuV4OGM1f4 7qJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ghfs1pPR; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a1-20020a656541000000b003816043ee81si20360544pgw.118.2022.03.24.06.48.51; Thu, 24 Mar 2022 06:49:05 -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=@intel.com header.s=Intel header.b=Ghfs1pPR; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346106AbiCWXfR (ORCPT + 99 others); Wed, 23 Mar 2022 19:35:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345734AbiCWXfJ (ORCPT ); Wed, 23 Mar 2022 19:35:09 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 785BF7DE06 for ; Wed, 23 Mar 2022 16:33:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648078417; x=1679614417; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5B867NxD2rUzUfzuiddRfj7M0tvh5dRqn7VBG5tbW4Q=; b=Ghfs1pPRp4d+sox8BPmyK7ucRukshgU0c7YvgF/TFPxOINkdOyfScppX G9lRVQ8lbJPwSdriJUOr7SvkWzlr3vZaPyWJrStHOwRa0Eu5oDN/US85d 9BmRizzOmmSIOjzfU2JTPhRf+PCLV2ftcwlyrRVlb2BIAhDdV9OViRg4i R8YgztLrD2eHusN+rcWRHkHfR2VtJu4iXqxSwOqhbVdEwr9BUNN/BYUU3 VB9h5MHu8om+FPpS5G5VT59eglbo00h6WJYll4sexYGceJFCHvlY8nF6S 9zSk2ObLgCYhfhMmnauhF/NronqTXSZcYWKJ7OhD3ORVizdRdCX0em96p A==; X-IronPort-AV: E=McAfee;i="6200,9189,10295"; a="258202355" X-IronPort-AV: E=Sophos;i="5.90,205,1643702400"; d="scan'208";a="258202355" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2022 16:33:37 -0700 X-IronPort-AV: E=Sophos;i="5.90,205,1643702400"; d="scan'208";a="583880273" Received: from rhweight-mobl.amr.corp.intel.com (HELO rhweight-mobl.ra.intel.com) ([10.212.130.166]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2022 16:33:36 -0700 From: Russ Weight To: mcgrof@kernel.org, gregkh@linuxfoundation.org, rafael@kernel.org, linux-kernel@vger.kernel.org Cc: trix@redhat.com, lgoncalv@redhat.com, yilun.xu@intel.com, hao.wu@intel.com, matthew.gerlach@intel.com, basheer.ahmed.muddebihal@intel.com, tianfei.zhang@intel.com, Russ Weight Subject: [RESEND PATCH v1 2/8] firmware_loader: Check fw_state_is_done in loading_store Date: Wed, 23 Mar 2022 16:33:25 -0700 Message-Id: <20220323233331.155121-3-russell.h.weight@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220323233331.155121-1-russell.h.weight@intel.com> References: <20220323233331.155121-1-russell.h.weight@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,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 Add the fw_state_is_done() function and exit early from firmware_loading_store() if the state is already "done". This is being done in preparation for supporting persistent sysfs nodes to allow userspace to upload firmware to a device, potentially reusing the sysfs loading and data files multiple times. Signed-off-by: Russ Weight --- v1: - No change from RFC patch --- drivers/base/firmware_loader/fallback.c | 2 +- drivers/base/firmware_loader/firmware.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/base/firmware_loader/fallback.c b/drivers/base/firmware_loader/fallback.c index 4afb0e9312c0..d82e055a4297 100644 --- a/drivers/base/firmware_loader/fallback.c +++ b/drivers/base/firmware_loader/fallback.c @@ -250,7 +250,7 @@ static ssize_t firmware_loading_store(struct device *dev, mutex_lock(&fw_lock); fw_priv = fw_sysfs->fw_priv; - if (fw_state_is_aborted(fw_priv)) + if (fw_state_is_aborted(fw_priv) || fw_state_is_done(fw_priv)) goto out; switch (loading) { diff --git a/drivers/base/firmware_loader/firmware.h b/drivers/base/firmware_loader/firmware.h index 2889f446ad41..58768d16f8df 100644 --- a/drivers/base/firmware_loader/firmware.h +++ b/drivers/base/firmware_loader/firmware.h @@ -149,6 +149,11 @@ static inline void fw_state_done(struct fw_priv *fw_priv) __fw_state_set(fw_priv, FW_STATUS_DONE); } +static inline bool fw_state_is_done(struct fw_priv *fw_priv) +{ + return __fw_state_check(fw_priv, FW_STATUS_DONE); +} + int assign_fw(struct firmware *fw, struct device *device); #ifdef CONFIG_FW_LOADER -- 2.25.1