From patchwork Wed Jul 5 02:18:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lee, Kah Jing" X-Patchwork-Id: 115915 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp1579565vqx; Tue, 4 Jul 2023 19:29:12 -0700 (PDT) X-Google-Smtp-Source: APBJJlHzvE4XySWwwu6Gl5pqmGOcpfRmxxnfHRtl9ORHWuGQqgipEyUHOmNwdi8rSqqerMAkK7CH X-Received: by 2002:a05:6870:4253:b0:1a6:cba1:7cce with SMTP id v19-20020a056870425300b001a6cba17ccemr13421623oac.32.1688524152231; Tue, 04 Jul 2023 19:29:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688524152; cv=none; d=google.com; s=arc-20160816; b=vbqr18rdJFviJMS+6u4Qgi95xjMa6TakFingQOUo8fk7dtTGJL7ZDf+6lDoNkiqSyH G5DQliv60kn0R2va9uLr8uzNci7fOIfyydMzcci8Ypidr/wrU3xIbw4G5lJkCMMgq9mb O929iOZ2Q6mSTo+dJgd22M948RS7m1Uene4p1akmqJ05kxrbTBjejV0nNkHnDGYtieEj ExqA39e5FxDOuQ+DuQmYaKjQ+DZHP8zB4M+zuwX+R9Zsyb3A5g5T0KM+s30xNbwJh5Qn ztOqYJkejqtn1TpE1sRIRTI82Q+XzlDQ1DdAmLYwrHRsqJ21sIKIAGgcIJr2O23gB53h CBHw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=rwFIPJkciTzWxjAP3PbuihkkRNXNf+hSDNraEEjoIC4=; fh=dS/vBEhtxATdBCOzkBDuaCdhuKcVZoKMqKm0sa2C8MM=; b=Plaf+DmFMsWP6CRpZl+/2Qym7f45MBqTg7IVH6dGiokFEhYDxjY/6lYtCKhZiMMtnt Pdad5o1f1LtS8O4N0qPlLAoxPrl5hC0HXz13TZv3QP643+fVL1BY6mIA2OgCCdiyKFwh FmJcT8v7E8b+l2ZvsT9JjSwbKXlm127UxCyNvbpq3Rnsv3Bd5fRkcyRFRsdCFdNdlqC0 cLrTXR8e/mfvRv6/OIaSJxWUrM1xGrM5b+TFOtFc/FItCK3oZe4kV8GBjeCGhf9BOib6 5lKWD4v5U/ry9TUdkgnQA+cRZrn97nfYg2LRjrk2l+aHCL4DJ+p81sF2CYbGn92Z1+q6 zGqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eiTwTrMr; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i5-20020a17090a65c500b002636d222400si580381pjs.14.2023.07.04.19.28.59; Tue, 04 Jul 2023 19:29:12 -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=eiTwTrMr; 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 S230367AbjGECUK (ORCPT + 99 others); Tue, 4 Jul 2023 22:20:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229469AbjGECUJ (ORCPT ); Tue, 4 Jul 2023 22:20:09 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AABD10E3 for ; Tue, 4 Jul 2023 19:20:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688523608; x=1720059608; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=LfdV5CNoYjK7UQgvI7xVw/46x3sR/AWcKvOG1E3NDnM=; b=eiTwTrMrC0W9a/oxh/tHw0sWwLLZ3tXewfjWDzAw5X63iYUGIGO/dEh9 6W9Wq8YnINM+riYFSMrkWuWLmg8jE2T7nxUDlX8XUl7vgDOVukDJJurTM KNm5zeUS3oXokwQdOxqtx8EzulDEYfEC4eTamLoo6pEP+gNyJZTdOEeER SPE/UhyMtsAFtlFkkrqN/wDKqtEhWYDLfNNxhh5kbZwzM/YOiqtbKB9ix pDKw4F2179S0uwYYd5/lWh3rBPRyxNBjMKd204SR+oQM1jj6a3/9k2kPj LqjMDRD9kSu+tnTzPCcPtKkZl7BL45Y4HFL00PQNAR8qRUKnVhiKiwMqv Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10761"; a="353058742" X-IronPort-AV: E=Sophos;i="6.01,181,1684825200"; d="scan'208";a="353058742" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jul 2023 19:20:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10761"; a="713029258" X-IronPort-AV: E=Sophos;i="6.01,181,1684825200"; d="scan'208";a="713029258" Received: from unknown (HELO localhost.localdomain) ([10.226.216.117]) by orsmga007.jf.intel.com with ESMTP; 04 Jul 2023 19:20:07 -0700 From: kah.jing.lee@intel.com To: Dinh Nguyen Cc: linux-kernel@vger.kernel.org, tien.sung.ang@intel.com, Kah Jing Lee Subject: [PATCH] firmware: stratix10-rsu: prevent io block when sending RSU messages Date: Wed, 5 Jul 2023 10:18:47 +0800 Message-Id: <20230705021846.1536829-1-kah.jing.lee@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770545901525439524?= X-GMAIL-MSGID: =?utf-8?q?1770545901525439524?= From: Kah Jing Lee Fix the issue for preventing recursive rsu mutex lock issue in RSU update command. Signed-off-by: Kah Jing Lee --- drivers/firmware/stratix10-rsu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/stratix10-rsu.c b/drivers/firmware/stratix10-rsu.c index e51c95f8d445..0a7542e9bb6f 100644 --- a/drivers/firmware/stratix10-rsu.c +++ b/drivers/firmware/stratix10-rsu.c @@ -280,7 +280,9 @@ static int rsu_send_msg(struct stratix10_rsu_priv *priv, struct stratix10_svc_client_msg msg; int ret; - mutex_lock(&priv->lock); + if (!mutex_trylock(&priv->lock)) + return -EAGAIN; + reinit_completion(&priv->completion); priv->client.receive_cb = callback; @@ -525,7 +527,9 @@ static ssize_t reboot_image_store(struct device *dev, ret = rsu_send_msg(priv, COMMAND_RSU_UPDATE, address, rsu_command_callback); - if (ret) { + if (ret == -EAGAIN) + return 0; + else if (ret) { dev_err(dev, "Error, RSU update returned %i\n", ret); return ret; }