Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3936595pxj; Mon, 21 Jun 2021 09:44:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBafetyiByrInk4Er4kAXmqESPIQgkN1ab6wrUGvvBDTxQ8r0h3huZKEjCjiEBMfDCXGmW X-Received: by 2002:a05:6402:3487:: with SMTP id v7mr22511082edc.378.1624293876758; Mon, 21 Jun 2021 09:44:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624293876; cv=none; d=google.com; s=arc-20160816; b=jnSkN0cLmjikE2zl1shtGB67UezdZ5SkIyQPhxkSZl5AASXQc6yO2ZHsV8EhKzZL10 Gi382AdcEU4zckYNuNRBxFrh1AXDA5z3iylyCuTiIhipJVvsIwwauXxQwhpVPLZ2pIb5 5b+DhGdaqTofpXn3g9ekreCd5erPaJvvw5ch68xvNtzWPtNonykT7H6Vi/Ry5jr0Rkez NBzeZZCWHDBxWAIQ5kAGQbJ3hhvsQdMoPx8Q07MrcA19MVWmbosR4kjD8ET3QYafMGnV 7fhVOsYsspGVbQxD2oP4jHJ6wOLhwwHvvfOSGzccC9WiK2K0EQieyrwk8+gNTCDH7TWW dv2w== 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=tO+vSK/zfX7ioQlhJa88NvExPIKq4zhyUNBLfA8N2NU=; b=FmNYbULbTHrtbDvvWb9e46JcA+jxJqR51gdbKs01IG9r/8gDAIFMgKF1ZnOdUw3QkX ys/3Uia8xAuWCj5OtxL57LSA8BqiwdNiJgFHoY0fmF6mxKVFWLVA2fq6ztX+jdU+MORe 7+rAh/ecVCGID1N8wmSEvS56bww3oRUUYTrJ4dzY+94hpG8FcHXEzUet9VLK3skf1Fqf yZ24H9WVkvJoCMrBv8gHKJTHtsSqGVX7cTgNqHo1n3dHF/yKuGj8dIbgBjN41R273Fz7 8i8HCTrzOf/1W7wajoGe9l8Pf+WL0Gweb1heatL6rdODPOb2zYAeopId4+utlS5oIAqi +tAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=v1NSRIrn; 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 k2si10901177ejs.648.2021.06.21.09.44.12; Mon, 21 Jun 2021 09:44:36 -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=v1NSRIrn; 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 S233075AbhFUQl7 (ORCPT + 99 others); Mon, 21 Jun 2021 12:41:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:60472 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232099AbhFUQiu (ORCPT ); Mon, 21 Jun 2021 12:38:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A5E1560698; Mon, 21 Jun 2021 16:29:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624292976; bh=dB/Ejp+KEceRyiGU0o4t7O8oibqrIpwNwrngwRmZoZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v1NSRIrnVh7FMLpUAfTTq56BwYtTWsAhqcQjxo7WppnvyRuZeNU0kRZU3QgufMZI6 ET4aDg4KqNVtkrhEkeLlQx0ZnunBBkUqZ0xzb7XSuGEUOzhdrJZ//HIjEhv+OUBobX czLt2z0xsfWdNgjoKXfRO0WFHuTh88tjJybYjNyI= 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.12 051/178] cxgb4: fix sleep in atomic when flashing PHY firmware Date: Mon, 21 Jun 2021 18:14:25 +0200 Message-Id: <20210621154924.111663250@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154921.212599475@linuxfoundation.org> References: <20210621154921.212599475@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 1f601de02e70..762113a04dde 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c @@ -4424,10 +4424,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 029f0c83d785..601853bb34c9 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c @@ -3820,9 +3820,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