From: Vadim Fedorenko <vadim.fedorenko@linux.dev>
To: Michael Chan <michael.chan@broadcom.com>
Cc: Pavan Chebbi <pavan.chebbi@broadcom.com>,
Jakub Kicinski <kuba@kernel.org>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Paolo Abeni <pabeni@redhat.com>,
"David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org,
Richard Cochran <richardcochran@gmail.com>
Subject: Re: [PATCH net-next v3 2/2] bnxt_en: replace PTP spinlock with seqlock
Date: Tue, 29 Oct 2024 20:41:37 +0000 [thread overview]
Message-ID: <2a538f3b-d66f-4fe2-a08e-0f852befb350@linux.dev> (raw)
In-Reply-To: <CACKFLimm96szzQd5AowWy-sQyfCKdoBCLgr5P68vOn6n0WKjWQ@mail.gmail.com>
On 29/10/2024 20:34, Michael Chan wrote:
> On Mon, Oct 28, 2024 at 11:57 AM Vadim Fedorenko <vadfed@meta.com> wrote:
>>
>> We can see high contention on ptp_lock while doing RX timestamping
>> on high packet rates over several queues. Spinlock is not effecient
>> to protect timecounter for RX timestamps when reads are the most
>> usual operations and writes are only occasional. It's better to use
>> seqlock in such cases.
>>
>> Signed-off-by: Vadim Fedorenko <vadfed@meta.com>
>> ---
>> v3:
>> - remove unused variable
>> v2:
>> - use read_excl lock to serialize reg access with FW reset
>> ---
>> drivers/net/ethernet/broadcom/bnxt/bnxt.c | 19 +++--
>> drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 73 ++++++-------------
>> drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h | 14 +++-
>> 3 files changed, 46 insertions(+), 60 deletions(-)
>>
>
>> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
>> index 820c7e83e586..5ab52f7a282d 100644
>> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
>> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
>> @@ -67,19 +67,21 @@ static int bnxt_ptp_settime(struct ptp_clock_info *ptp_info,
>> if (BNXT_PTP_USE_RTC(ptp->bp))
>> return bnxt_ptp_cfg_settime(ptp->bp, ns);
>>
>> - spin_lock_irqsave(&ptp->ptp_lock, flags);
>> + write_seqlock_irqsave(&ptp->ptp_lock, flags);
>> timecounter_init(&ptp->tc, &ptp->cc, ns);
>> - spin_unlock_irqrestore(&ptp->ptp_lock, flags);
>> + write_sequnlock_irqrestore(&ptp->ptp_lock, flags);
>> return 0;
>> }
>>
>> -/* Caller holds ptp_lock */
>> static int bnxt_refclk_read(struct bnxt *bp, struct ptp_system_timestamp *sts,
>> u64 *ns)
>> {
>> struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
>> u32 high_before, high_now, low;
>> + unsigned long flags;
>>
>> + /* We have to serialize reg access and FW reset */
>> + read_seqlock_excl_irqsave(&ptp->ptp_lock, flags);
>> if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state))
>
> I think we need read_sequnlock_excl_irqrestore() here before returning.
Yes, you are right, we need to unlock seqlock in case of error. I'll
post v4 soon, thanks!
>
>> return -EIO;
>>
>> @@ -93,6 +95,7 @@ static int bnxt_refclk_read(struct bnxt *bp, struct ptp_system_timestamp *sts,
>> low = readl(bp->bar0 + ptp->refclk_mapped_regs[0]);
>> ptp_read_system_postts(sts);
>> }
>> + read_sequnlock_excl_irqrestore(&ptp->ptp_lock, flags);
>> *ns = ((u64)high_now << 32) | low;
>>
>> return 0;
prev parent reply other threads:[~2024-10-29 20:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-28 18:57 [PATCH net-next v3 1/2] bnxt_en: cache only 24 bits of hw counter Vadim Fedorenko
2024-10-28 18:57 ` [PATCH net-next v3 2/2] bnxt_en: replace PTP spinlock with seqlock Vadim Fedorenko
2024-10-29 20:34 ` Michael Chan
2024-10-29 20:41 ` Vadim Fedorenko [this message]
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=2a538f3b-d66f-4fe2-a08e-0f852befb350@linux.dev \
--to=vadim.fedorenko@linux.dev \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=michael.chan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pavan.chebbi@broadcom.com \
--cc=richardcochran@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.