Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2655748pxj; Mon, 14 Jun 2021 04:10:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsCYzCy9VzjLyesyeDVAPhriNiJevULmL1WsJiEQQ29W2O/O2udsVE2/aJB+eLRSg0/jmt X-Received: by 2002:a05:6402:3586:: with SMTP id y6mr16171467edc.154.1623669028536; Mon, 14 Jun 2021 04:10:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623669028; cv=none; d=google.com; s=arc-20160816; b=n+g8VR7xtc34IM8+YdcBaUAm1zRF+dl83SpDXOYZOtCFr7yGNfLlzXAaIahmhodH// 9HvMqIiVdCT9WpWABxaKqe1fP9XkbKL/rIyiJjtpmNRDkTr9xcv46QfwWVojrcFBdH3Y S2ns5v6d08r4JFKK7DMHIlDjejkoDwQaQpHgjFT5VuKhFEjHykrJtyEDQQCYLYxGINBc 4oQfBNSu8TbBfTtnQ7OdIPVWXMRNL33HgGeBkcOMgC1KVlPBqLQWVz+pV8d6+WNnfMz+ +C28MZa8qgL0OJQWfSTdoAqbjL+IEAryh1glDYbGWDQTHHJ9Y1lUSmvv3wxhuW3b4zTh U69g== 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=2jlJOhwbsO1++G4CZityPaqCA/HU/gGJ1l8Z54Yi3L8=; b=VMmmPiruKjwXszjcihJs8JY+VsaFN7Wcfaz62p+Kt5YJImlnVEcptzkef3hklSHbaA 2OAWRGm9s6xMsO8jzpdBIFyhEKuo/x8Qz4fjAglzSs5TFNCGmYXg0goSIZZ+UHIcokFV 2e68DVp95S2WX3tRvKqP/Ko3d9kPhp2y3veW6dXhOgrjU/0fFOmGhPNpPMKhOCwU08Sd WftMmecBhDJ8K+S8jSe89X6wYgfNr3AjctDtTaU5i8GDWSmC0VxhX/6Rza6veLZaDYuE unxWRTShXNM1FGhq+1OBba6nhfJU1bYdsdpD3q90iHWkEG00vMrxyNRfE++38q5qqsFi krLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KmaYO1Xs; 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 yc7si7669347ejb.288.2021.06.14.04.10.06; Mon, 14 Jun 2021 04:10:28 -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=KmaYO1Xs; 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 S235426AbhFNLKM (ORCPT + 99 others); Mon, 14 Jun 2021 07:10:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:35552 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234756AbhFNK7I (ORCPT ); Mon, 14 Jun 2021 06:59:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AA11761432; Mon, 14 Jun 2021 10:42:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623667334; bh=rBdCQKo4oTB5NfIG2Xln7Et4gcFivtkkr+NcTYq4zbM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KmaYO1XsDs4TuMjqzlh2SxBJn/yebvok89420PzRm1mm2Ucjs4Xp1DbvRBzfDKvnA pYF9dIXebQX8ndvK2pt1NMI6ngT0niBZNy8HtrviIDDk1p4RYQHMqi7cehPS0vYoD1 lHp5NKow7bF0GxiBsZ/dXeJ+rIysDp45+NVaGZso= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zong Li , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 030/131] net: macb: ensure the device is available before accessing GEMGXL control registers Date: Mon, 14 Jun 2021 12:26:31 +0200 Message-Id: <20210614102654.039561750@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210614102652.964395392@linuxfoundation.org> References: <20210614102652.964395392@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: Zong Li [ Upstream commit 5eff1461a6dec84f04fafa9128548bad51d96147 ] If runtime power menagement is enabled, the gigabit ethernet PLL would be disabled after macb_probe(). During this period of time, the system would hang up if we try to access GEMGXL control registers. We can't put runtime_pm_get/runtime_pm_put/ there due to the issue of sleep inside atomic section (7fa2955ff70ce453 ("sh_eth: Fix sleeping function called from invalid context"). Add netif_running checking to ensure the device is available before accessing GEMGXL device. Changed in v2: - Use netif_running instead of its own flag Signed-off-by: Zong Li Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/cadence/macb_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index 390f45e49eaf..1e8bf6b9834b 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -2709,6 +2709,9 @@ static struct net_device_stats *gem_get_stats(struct macb *bp) struct gem_stats *hwstat = &bp->hw_stats.gem; struct net_device_stats *nstat = &bp->dev->stats; + if (!netif_running(bp->dev)) + return nstat; + gem_update_stats(bp); nstat->rx_errors = (hwstat->rx_frame_check_sequence_errors + -- 2.30.2