Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp269256ybj; Mon, 4 May 2020 21:04:59 -0700 (PDT) X-Google-Smtp-Source: APiQypKlHq/g6XTyC31sPQW2x2TU7m73BWMjSOIKCK07obk5ZGFh21/d0B/Sxi34j1eNdxJg5wm5 X-Received: by 2002:a17:906:6441:: with SMTP id l1mr966171ejn.148.1588651499557; Mon, 04 May 2020 21:04:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588651499; cv=none; d=google.com; s=arc-20160816; b=IMfExeqIqGbsEGGIlbx0FpGXgeNJGzcKeYLgGL6GMkKZpuoHl/QQj5TBVfuPcpaPXd dXPDaDNuFV8wEcXeaV538mJsoktVncqKDw04vIYEce0zbqad6psn3YNZwAN62ROYf3UG EcOn0ybikMZrXyyBsdsxvwGJtSqtHcqR8TcWXcjFgGSg9hr8dYl7DoPGNH0jNs10Km/L vGtDFMSjoU4VsbcIP9hU8QTecCrvdK4uekVhdMQxnpX5mzRFx58200KU5Ru/8vBkW15o EMPKzmcbNy/SzIy30Up9B3mZeXiaG89rgV88Vk4jJU0nN+SMvoHLJGGC40/uR41iKDsy iDvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=pe5Jkz1N0Ut2NF38LUfo3uijsixO9jWbVaNGB+NPBMs=; b=nGU74uw/zvu9xtyvhgTC67LuM8X7aV/3KAJy2SwPdaHEKcFVGWNP8TXdWHaAfRkIA4 mh4yjv/BDEghYn9jZXWxa99CTZHLGSrCt4LNeOEPh3KX/BMBcoUKpRTkXdQ9+gnpOLuI 5863H2ATKJ4RAMk3iRFtHPoo4aaT7zNBvaHAjsa+knLoKm/9x0GBNv78B47rsJDdCrYd +bSwnlat3Nuxz2jD0KD7xfDhMpIKEVav7cBOC1FsD6Ji2XwuX84H6BHslvSKx85pg3mo AY/wTQ2nX9VUn6Mn66VpBVd/F9CE6eOcffECd6n6MNJ0+klzh29Hz1ETZJPiAr89FZFM 9r0A== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t27si516732edt.42.2020.05.04.21.04.35; Mon, 04 May 2020 21:04:59 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728208AbgEEECH (ORCPT + 99 others); Tue, 5 May 2020 00:02:07 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:60099 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726093AbgEEECH (ORCPT ); Tue, 5 May 2020 00:02:07 -0400 Received: from 61-220-137-37.hinet-ip.hinet.net ([61.220.137.37] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jVomO-0001hb-Mx; Tue, 05 May 2020 04:02:01 +0000 From: Kai-Heng Feng To: jeffrey.t.kirsher@intel.com Cc: Kai-Heng Feng , Aaron Brown , "David S. Miller" , intel-wired-lan@lists.osuosl.org (moderated list:INTEL ETHERNET DRIVERS), netdev@vger.kernel.org (open list:NETWORKING DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2] igb: Report speed and duplex as unknown when device is runtime suspended Date: Tue, 5 May 2020 12:01:54 +0800 Message-Id: <20200505040154.24080-1-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org igb device gets runtime suspended when there's no link partner. We can't get correct speed under that state: $ cat /sys/class/net/enp3s0/speed 1000 In addition to that, an error can also be spotted in dmesg: [ 385.991957] igb 0000:03:00.0 enp3s0: PCIe link lost Since device can only be runtime suspended when there's no link partner, we can skip reading register and let the following logic set speed and duplex with correct status. The more generic approach will be wrap get_link_ksettings() with begin() and complete() callbacks. However, for this particular issue, begin() calls igb_runtime_resume() , which tries to rtnl_lock() while the lock is already hold by upper ethtool layer. So let's take this approach until the igb_runtime_resume() no longer needs to hold rtnl_lock. Cc: Jeff Kirsher Cc: Aaron Brown Suggested-by: Alexander Duyck Signed-off-by: Kai-Heng Feng --- v2: - Don't early return the routine so other info can be set. drivers/net/ethernet/intel/igb/igb_ethtool.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c index 39d3b76a6f5d..2cd003c5ad43 100644 --- a/drivers/net/ethernet/intel/igb/igb_ethtool.c +++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c @@ -143,7 +143,8 @@ static int igb_get_link_ksettings(struct net_device *netdev, u32 speed; u32 supported, advertising; - status = rd32(E1000_STATUS); + status = pm_runtime_suspended(&adapter->pdev->dev) ? + 0 : rd32(E1000_STATUS); if (hw->phy.media_type == e1000_media_type_copper) { supported = (SUPPORTED_10baseT_Half | -- 2.17.1