netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Csókás Bence" <csokas.bence@prolan.hu>
To: Wei Fang <wei.fang@nxp.com>, <davem@davemloft.net>,
	<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
	<richardcochran@gmail.com>, <shenwei.wang@nxp.com>,
	<xiaoning.wang@nxp.com>
Cc: <linux@roeck-us.net>, <imx@lists.linux.dev>,
	<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net] net: fec: don't save PTP state if PTP is unsupported
Date: Tue, 8 Oct 2024 11:02:23 +0200	[thread overview]
Message-ID: <da9833c7-ad3d-48f5-b846-add3e57433a0@prolan.hu> (raw)
In-Reply-To: <20241008061153.1977930-1-wei.fang@nxp.com>

On 2024. 10. 08. 8:11, Wei Fang wrote:
> Some platforms (such as i.MX25 and i.MX27) do not support PTP, so on
> these platforms fec_ptp_init() is not called and the related members
> in fep are not initialized. However, fec_ptp_save_state() is called
> unconditionally, which causes the kernel to panic. Therefore, add a
> condition so that fec_ptp_save_state() is not called if PTP is not
> supported.
> 
> Fixes: a1477dc87dc4 ("net: fec: Restart PPS after link state change")
> Reported-by: Guenter Roeck <linux@roeck-us.net>
> Closes: https://lore.kernel.org/lkml/353e41fe-6bb4-4ee9-9980-2da2a9c1c508@roeck-us.net/
> Signed-off-by: Wei Fang <wei.fang@nxp.com>
> ---
>   drivers/net/ethernet/freescale/fec_main.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
> index 60fb54231ead..1b55047c0237 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -1077,7 +1077,8 @@ fec_restart(struct net_device *ndev)
>   	u32 rcntl = OPT_FRAME_SIZE | 0x04;
>   	u32 ecntl = FEC_ECR_ETHEREN;
>   
> -	fec_ptp_save_state(fep);
> +	if (fep->bufdesc_ex)
> +		fec_ptp_save_state(fep);
>   
>   	/* Whack a reset.  We should wait for this.
>   	 * For i.MX6SX SOC, enet use AXI bus, we use disable MAC
> @@ -1340,7 +1341,8 @@ fec_stop(struct net_device *ndev)
>   			netdev_err(ndev, "Graceful transmit stop did not complete!\n");
>   	}
>   
> -	fec_ptp_save_state(fep);
> +	if (fep->bufdesc_ex)
> +		fec_ptp_save_state(fep);
>   
>   	/* Whack a reset.  We should wait for this.
>   	 * For i.MX6SX SOC, enet use AXI bus, we use disable MAC

Thanks, it seems fec_ptp_restore_state() was properly guarded, but 
save_state() was not. Sorry for that.

Reviewed-by: Csókás, Bence <csokas.bence@prolan.hu>


  reply	other threads:[~2024-10-08  9:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-08  6:11 [PATCH net] net: fec: don't save PTP state if PTP is unsupported Wei Fang
2024-10-08  9:02 ` Csókás Bence [this message]
2024-10-09 11:54 ` Simon Horman
2024-10-09 12:43   ` Wei Fang
2024-10-09 12:52     ` Simon Horman
2024-10-09 17:19 ` Guenter Roeck
2024-10-10  2:50 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=da9833c7-ad3d-48f5-b846-add3e57433a0@prolan.hu \
    --to=csokas.bence@prolan.hu \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=imx@lists.linux.dev \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=shenwei.wang@nxp.com \
    --cc=wei.fang@nxp.com \
    --cc=xiaoning.wang@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).