From: Paolo Abeni <pabeni@redhat.com>
To: Divya.Koppera@microchip.com, andrew@lunn.ch,
Arun.Ramadoss@microchip.com, UNGLinuxDriver@microchip.com,
hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, richardcochran@gmail.com,
vadim.fedorenko@linux.dev
Subject: Re: [PATCH net-next v5 2/5] net: phy: microchip_ptp : Add ptp library for Microchip phys
Date: Thu, 5 Dec 2024 12:07:57 +0100 [thread overview]
Message-ID: <946b59e0-18f9-4e4f-a3c9-3de432db4340@redhat.com> (raw)
In-Reply-To: <CO1PR11MB477140866E76B0FCEFA05735E2302@CO1PR11MB4771.namprd11.prod.outlook.com>
On 12/5/24 12:00, Divya.Koppera@microchip.com wrote:
> From: Paolo Abeni <pabeni@redhat.com> Thursday, December 5, 2024 3:17 PM
>> To: Divya Koppera - I30481 <Divya.Koppera@microchip.com>;
>> andrew@lunn.ch; Arun Ramadoss - I17769
>> <Arun.Ramadoss@microchip.com>; UNGLinuxDriver
>> <UNGLinuxDriver@microchip.com>; hkallweit1@gmail.com;
>> linux@armlinux.org.uk; davem@davemloft.net; edumazet@google.com;
>> kuba@kernel.org; netdev@vger.kernel.org; linux-kernel@vger.kernel.org;
>> richardcochran@gmail.com; vadim.fedorenko@linux.dev
>> Subject: Re: [PATCH net-next v5 2/5] net: phy: microchip_ptp : Add ptp library
>> for Microchip phys
>>
>> EXTERNAL EMAIL: Do not click links or open attachments unless you know the
>> content is safe
>>
>> On 12/3/24 09:52, Divya Koppera wrote:
>>> +struct mchp_ptp_clock *mchp_ptp_probe(struct phy_device *phydev, u8
>> mmd,
>>> + u16 clk_base_addr, u16
>>> +port_base_addr) {
>>> + struct mchp_ptp_clock *clock;
>>> + int rc;
>>> +
>>> + clock = devm_kzalloc(&phydev->mdio.dev, sizeof(*clock), GFP_KERNEL);
>>> + if (!clock)
>>> + return ERR_PTR(-ENOMEM);
>>> +
>>> + clock->port_base_addr = port_base_addr;
>>> + clock->clk_base_addr = clk_base_addr;
>>> + clock->mmd = mmd;
>>> +
>>> + /* Register PTP clock */
>>> + clock->caps.owner = THIS_MODULE;
>>> + snprintf(clock->caps.name, 30, "%s", phydev->drv->name);
>>> + clock->caps.max_adj = MCHP_PTP_MAX_ADJ;
>>> + clock->caps.n_ext_ts = 0;
>>> + clock->caps.pps = 0;
>>> + clock->caps.adjfine = mchp_ptp_ltc_adjfine;
>>> + clock->caps.adjtime = mchp_ptp_ltc_adjtime;
>>> + clock->caps.gettime64 = mchp_ptp_ltc_gettime64;
>>> + clock->caps.settime64 = mchp_ptp_ltc_settime64;
>>> + clock->ptp_clock = ptp_clock_register(&clock->caps,
>>> + &phydev->mdio.dev);
>>> + if (IS_ERR(clock->ptp_clock))
>>> + return ERR_PTR(-EINVAL);
>>> +
>>> + /* Initialize the SW */
>>> + skb_queue_head_init(&clock->tx_queue);
>>> + skb_queue_head_init(&clock->rx_queue);
>>> + INIT_LIST_HEAD(&clock->rx_ts_list);
>>> + spin_lock_init(&clock->rx_ts_lock);
>>> + mutex_init(&clock->ptp_lock);
>>
>> The s/w initialization is completed after successfully registering the new ptp
>> clock, is that safe? It looks like it may race with ptp callbacks.
>
> If I understand your comment correctly ptp_lock in the clock instance is not initialized before registering the clock.
> Rest of the initializations are related to packet processing and also depends on phydev->default_timestamp and mii_ts instance only after which packets will be forwarded to phy.
> As we are also re-initializing the clock ptp4l/application need to restart.
>
> Initializing ptp_lock before registering the clock should be safe from ptp point of view.
>
> Let me know your opinion?
I guess moving the lock initialization before the registration should be
safe.
Please not that the main issue open is WRT code reuse: I second Andrew
opinion about the need of consolidating the microchip ptp drivers
implementation. A library should be able to abstract above individual
device differences.
Thanks,
Paolo
next prev parent reply other threads:[~2024-12-05 11:08 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-03 8:52 [PATCH net-next v5 0/5] " Divya Koppera
2024-12-03 8:52 ` [PATCH net-next v5 1/5] net: phy: microchip_ptp : Add header file for Microchip ptp library Divya Koppera
2024-12-03 8:52 ` [PATCH net-next v5 2/5] net: phy: microchip_ptp : Add ptp library for Microchip phys Divya Koppera
2024-12-05 9:47 ` Paolo Abeni
2024-12-05 11:00 ` Divya.Koppera
2024-12-05 11:07 ` Paolo Abeni [this message]
2024-12-05 11:26 ` Divya.Koppera
2024-12-03 8:52 ` [PATCH net-next v5 3/5] net: phy: Kconfig: Add ptp library support and 1588 optional flag in " Divya Koppera
2024-12-04 1:39 ` Andrew Lunn
2024-12-04 15:47 ` Divya.Koppera
2024-12-04 16:02 ` Andrew Lunn
2024-12-04 16:09 ` Russell King (Oracle)
2024-12-05 6:04 ` Divya.Koppera
2024-12-05 14:35 ` Andrew Lunn
2024-12-06 11:30 ` Divya.Koppera
2024-12-03 8:52 ` [PATCH net-next v5 4/5] net: phy: Makefile: Add makefile support for ptp " Divya Koppera
2024-12-03 8:52 ` [PATCH net-next v5 5/5] net: phy: microchip_t1 : Add initialization of ptp for lan887x Divya Koppera
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=946b59e0-18f9-4e4f-a3c9-3de432db4340@redhat.com \
--to=pabeni@redhat.com \
--cc=Arun.Ramadoss@microchip.com \
--cc=Divya.Koppera@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@gmail.com \
--cc=vadim.fedorenko@linux.dev \
/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
all inboxes | Powered by JetHome®