Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3923528pxj; Mon, 21 Jun 2021 09:27:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMQ8RFn3BSyRa0YNFrJNGEnescMwYOu2zKV/NajgHWlOxvnbGTPDV/W8LMY2KMKPogQ/X7 X-Received: by 2002:aa7:ce87:: with SMTP id y7mr15937098edv.223.1624292879006; Mon, 21 Jun 2021 09:27:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624292879; cv=none; d=google.com; s=arc-20160816; b=0H9/kCkYp8hESUHJHhpZHlH5kSqPCqxR59aMCzk4yTKk2NPXMs/SnqdptRCRZj66BF tds3Q59M83H4kUUVQ7ZPZcRCsL66QKQJ0inr5FrywUir+6b6FQZ0wmUnUEbcKogjTaH8 AzXoUKYTN5WGrVhbDrSLuWAAy4MK5cmOezi3i9fz1YrmaO/UPctxHCT/nmbh54VN0xq8 EYbrJYnC5mRiI8LCcncEK2yk6Nx9ncLwQTKeuYYOQHi/NohimNV0dwR2TiEJGK9yP7On 8xtSvh6N9XkgD/iC3R1rmkCIQeWf/dMO9DlsxtUwnW691AzsouEu2QRmE3TtL1beYcjM m4vg== 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=x1GxfZ920TTg5deLUYLMnHPVjPLvMSkzoGaHnXnwjFE=; b=LLGD06rZUypSsRxCjHKj3ktK1jZZSdsCEU3k6Hq0Zr9zvzntl2yByXABVAzch4aUVx SVivksSy0a5zXjw5kAfe+U94it/UraFRKcudEgNclp63TTu9sRIsel17EzaEQF+H+c/M UjlyJAsX+L6q0hvQgWm4LTJtZeDSTOSdoZS0Aeu/Efa5zkV1M4e3b8kx/cgFFpvn+M+d fwx7tB50DDYBuqAiXxwiYwjqTOhEuoOejgfAM+pHAJrlXTefDIavicpcVhzkRtxtHdFa R3GUXfZNLzq3pnGA/1fiwg+oR1SBSUTmwucqVXgZZdNQLbTFRo6Ul8E+vVO1HwgArRNY TeCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TNi9yRyN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cq14si7612422edb.313.2021.06.21.09.27.36; Mon, 21 Jun 2021 09:27:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TNi9yRyN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S232000AbhFUQ2Z (ORCPT + 99 others); Mon, 21 Jun 2021 12:28:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:49176 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231447AbhFUQ1A (ORCPT ); Mon, 21 Jun 2021 12:27:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4F73261369; Mon, 21 Jun 2021 16:22:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624292555; bh=aOkl5aBhIz/uP2jKH6um4LvfzE3UxKNnKnOZ88DgE5s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TNi9yRyNxwzQHFSpZEszlQNqLmT2K2WgIuh7Y9TB84JhNyUzyJDuje/oe5J0zfdER IqZSVtR+81Ct4oc2OtPcj4swRSLTXhHG2xFWSLdcYBs84Opig2EkQhmjpdu5VWdq4S oPb13Mg+hgUYwHUMEcCebwr8LuSrjbbw+iHTXdm8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rahul Lakkireddy , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 042/146] cxgb4: fix sleep in atomic when flashing PHY firmware Date: Mon, 21 Jun 2021 18:14:32 +0200 Message-Id: <20210621154912.721945503@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154911.244649123@linuxfoundation.org> References: <20210621154911.244649123@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rahul Lakkireddy [ Upstream commit f046bd0ae15d8a0bbe57d4647da182420f720c3d ] Before writing new PHY firmware to on-chip memory, driver queries firmware for current running PHY firmware version, which can result in sleep waiting for reply. So, move spinlock closer to the actual on-chip memory write operation, instead of taking it at the callers. Fixes: 5fff701c838e ("cxgb4: always sync access when flashing PHY firmware") Signed-off-by: Rahul Lakkireddy Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c | 2 -- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 2 -- drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 2 ++ 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c index 61ea3ec5c3fc..bc2de01d0539 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c @@ -1337,9 +1337,7 @@ static int cxgb4_ethtool_flash_phy(struct net_device *netdev, return ret; } - spin_lock_bh(&adap->win0_lock); ret = t4_load_phy_fw(adap, MEMWIN_NIC, NULL, data, size); - spin_unlock_bh(&adap->win0_lock); if (ret) dev_err(adap->pdev_dev, "Failed to load PHY FW\n"); diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c index 04dcb5e4b316..8be525c5e2e4 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c @@ -4428,10 +4428,8 @@ static int adap_init0_phy(struct adapter *adap) /* Load PHY Firmware onto adapter. */ - spin_lock_bh(&adap->win0_lock); ret = t4_load_phy_fw(adap, MEMWIN_NIC, phy_info->phy_fw_version, (u8 *)phyf->data, phyf->size); - spin_unlock_bh(&adap->win0_lock); if (ret < 0) dev_err(adap->pdev_dev, "PHY Firmware transfer error %d\n", -ret); diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c index 236f6bf2858a..964ea3491b80 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c @@ -3827,9 +3827,11 @@ int t4_load_phy_fw(struct adapter *adap, int win, /* Copy the supplied PHY Firmware image to the adapter memory location * allocated by the adapter firmware. */ + spin_lock_bh(&adap->win0_lock); ret = t4_memory_rw(adap, win, mtype, maddr, phy_fw_size, (__be32 *)phy_fw_data, T4_MEMORY_WRITE); + spin_unlock_bh(&adap->win0_lock); if (ret) return ret; -- 2.30.2