Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3419499pxf; Mon, 29 Mar 2021 01:30:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYmIJ2lPR6YprW7AnKvWYGgIVOdPS2tkYRXe1jWARjMoSMX70CuEtbvPQGH7z1/7u8kAms X-Received: by 2002:a17:907:216d:: with SMTP id rl13mr26830460ejb.362.1617006643303; Mon, 29 Mar 2021 01:30:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617006643; cv=none; d=google.com; s=arc-20160816; b=FjZgd2Avh0xabCsNRzk/JvPxAWjNRU5xe9OceZv6vh87e8MxhSChYmub3kcSP2lZ7y mM3W4WXQaRHSgVJR+AZD5Jy9pGPYDJpzO/RPKQ0KSCj85nSpyj/qKSBodl0OJIVCyjxm wwIxSCoEy2KbwRoKn37RwUssxUYwvuBAcCHgebO8csoP1xKBhuR6YRLine0fuqtEujef LIgBTVpZJ5tAjGRtZm8serncZHDWtdinr0NiBYe/UlIcE3nw3oMl04TStZmpl8ejIwnr cy5cl6C6/Jp3/DU4WmTI52zNOklNlSZGubP8sj9Su5pLqG5U49OW8dcCBws7gjDNENVV E9WQ== 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=xw1BVhbiSMrjDLX7+2Vy7lj3johvrzOu3kHlKe6EF8U=; b=E5/ycCgZ5Rth9PasrU0BMwZnRVVy3o7NtAH9Tz5i1scF0L3Tlo5ChVfbtG/C71CxzZ EqxQ8SYGUBdoFb6Od1sQdDx2AHBkKo5qjX+4yPVjj+Zh67KHM6yQltYFAxOSYMZqnyud 659jbHp5Goo4lrJXV3TUbTTK4PCzJhFkRoRZepiCAzW+9vom4wqC/oFrRBUBEDDC2aTG FEUXZkFPogyfxYEN5pu4ZdKvQu9kz2s3hW58Ge6P2C/P0gk9xcBo98wUf2byhyW7GZrP yUQtRuC0pQDUO9ukS80iJsziKHluHRZPzRpferfgHjIlBrwcTJZdgTJ6Cz1NqlWK4zT6 9mOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ADoalKlI; 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 f24si12420690eds.18.2021.03.29.01.30.20; Mon, 29 Mar 2021 01:30:43 -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=ADoalKlI; 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 S234258AbhC2I2A (ORCPT + 99 others); Mon, 29 Mar 2021 04:28:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:58964 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233354AbhC2IRc (ORCPT ); Mon, 29 Mar 2021 04:17:32 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 028C66044F; Mon, 29 Mar 2021 08:17:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617005846; bh=GT+lisKyj04s1FvVx444rz72yjzpOZdk93r+kgqXFr0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ADoalKlIxo2WH1og+my6paPSENJzw6arU+NL0MGkYT+pWJaaGubAZBJ0ICFQRPjcY u4IABhT8RHHLZlHGRDi7pLm4DYFYcefc1bl/EzXSbd9T7kWNVYavAR+PxWqQ2rZUJG 8nM0JzOZLOUjWCOHcUXX+w2FhtEcHgDkEznzb4UE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Heiko Thiery , Richard Cochran , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.10 005/221] net: fec: ptp: avoid register access when ipg clock is disabled Date: Mon, 29 Mar 2021 09:55:36 +0200 Message-Id: <20210329075629.356202815@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@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: Heiko Thiery [ Upstream commit 6a4d7234ae9a3bb31181f348ade9bbdb55aeb5c5 ] When accessing the timecounter register on an i.MX8MQ the kernel hangs. This is only the case when the interface is down. This can be reproduced by reading with 'phc_ctrl eth0 get'. Like described in the change in 91c0d987a9788dcc5fe26baafd73bf9242b68900 the igp clock is disabled when the interface is down and leads to a system hang. So we check if the ptp clock status before reading the timecounter register. Signed-off-by: Heiko Thiery Acked-by: Richard Cochran Link: https://lore.kernel.org/r/20210225211514.9115-1-heiko.thiery@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/freescale/fec_ptp.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c index 2e344aada4c6..1753807cbf97 100644 --- a/drivers/net/ethernet/freescale/fec_ptp.c +++ b/drivers/net/ethernet/freescale/fec_ptp.c @@ -377,9 +377,16 @@ static int fec_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts) u64 ns; unsigned long flags; + mutex_lock(&adapter->ptp_clk_mutex); + /* Check the ptp clock */ + if (!adapter->ptp_clk_on) { + mutex_unlock(&adapter->ptp_clk_mutex); + return -EINVAL; + } spin_lock_irqsave(&adapter->tmreg_lock, flags); ns = timecounter_read(&adapter->tc); spin_unlock_irqrestore(&adapter->tmreg_lock, flags); + mutex_unlock(&adapter->ptp_clk_mutex); *ts = ns_to_timespec64(ns); -- 2.30.1