From: Diogo Ivo <diogo.ivo@siemens.com>
To: Paolo Abeni <pabeni@redhat.com>,
MD Danish Anwar <danishanwar@ti.com>,
Roger Quadros <rogerq@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Richard Cochran <richardcochran@gmail.com>,
Nishanth Menon <nm@ti.com>, Vignesh Raghavendra <vigneshr@ti.com>,
Tero Kristo <kristo@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Jan Kiszka <jan.kiszka@siemens.com>,
Jacob Keller <jacob.e.keller@intel.com>,
Simon Horman <horms@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
diogo.ivo@siemens.com
Subject: Re: [PATCH net-next v2 2/3] net: ti: icss-iep: Enable compare events
Date: Thu, 6 Jun 2024 14:28:29 +0100 [thread overview]
Message-ID: <a08ff9c7-eac7-409e-8f22-5ad1fa0cf212@siemens.com> (raw)
In-Reply-To: <c518f6dd6cf9e92469d37a7317a6881ebed6a8c1.camel@redhat.com>
Hi Paolo,
On 6/6/24 11:32 AM, Paolo Abeni wrote:
> On Tue, 2024-06-04 at 14:15 +0100, Diogo Ivo wrote:
>> @@ -571,6 +573,57 @@ static int icss_iep_perout_enable(struct icss_iep *iep,
>> return ret;
>> }
>>
>> +static void icss_iep_cap_cmp_work(struct work_struct *work)
>> +{
>> + struct icss_iep *iep = container_of(work, struct icss_iep, work);
>> + const u32 *reg_offs = iep->plat_data->reg_offs;
>> + struct ptp_clock_event pevent;
>> + unsigned int val;
>> + u64 ns, ns_next;
>> +
>> + spin_lock(&iep->irq_lock);
>
> 'irq_lock' is always acquired with the irqsave variant, and here we are
> in process context. This discrepancy would at least deserve a comment;
> likely the above lock type is not correct.
If my reasoning is correct I believe this variant is correct here. The
register accesses in the IRQ handler and icss_iep_cap_cmp_work() are
orthogonal, so there should be no need to guard against the IRQ handler
here. This is the case for the other places where the _irqsave() variant
is used, so using the _irqsave() variant is overkill there.
From my understanding this is a remnant of the SDK's version of the
driver, where all of the processing now done in icss_iep_cap_cmp_work()
was done directly in the IRQ handler, meaning that we had to guard
against some other thread calling icss_iep_ptp_enable() and accessing
for example ICSS_IEP_CMP1_REG0 concurrently. This can be seen in the
comment on line 114:
struct icss_iep {
...
spinlock_t irq_lock; /* CMP IRQ vs icss_iep_ptp_enable access */
...
};
For v3 I can add a comment with a condensed version of this argument in
icss_iep_cap_cmp_work().
With this said it should be possible to change this spinlock to a mutex as
well, since all the possibilities for concurrency happen outside of
interrupt context. I can add a patch to this series doing that if you
agree with my reasoning above and find it beneficial. For this some
comments from TI would also be good to have in case I missed something
or there is some other factor that I am not aware of.
Best regards,
Diogo
next prev parent reply other threads:[~2024-06-06 13:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-04 13:15 [PATCH net-next v2 0/3] Enable PTP timestamping/PPS for AM65x SR1.0 devices Diogo Ivo
2024-06-04 13:15 ` [PATCH net-next v2 1/3] net: ti: icssg-prueth: Enable PTP timestamping support for " Diogo Ivo
2024-06-04 14:19 ` Wojciech Drewek
2024-06-04 13:15 ` [PATCH net-next v2 2/3] net: ti: icss-iep: Enable compare events Diogo Ivo
2024-06-04 14:23 ` Wojciech Drewek
2024-06-06 10:32 ` Paolo Abeni
2024-06-06 13:28 ` Diogo Ivo [this message]
2024-06-06 13:49 ` Paolo Abeni
2024-06-06 15:43 ` Diogo Ivo
2024-06-04 13:15 ` [PATCH net-next v2 3/3] arm64: dts: ti: iot2050: Add IEP interrupts for SR1.0 devices Diogo Ivo
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=a08ff9c7-eac7-409e-8f22-5ad1fa0cf212@siemens.com \
--to=diogo.ivo@siemens.com \
--cc=conor+dt@kernel.org \
--cc=danishanwar@ti.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jacob.e.keller@intel.com \
--cc=jan.kiszka@siemens.com \
--cc=kristo@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nm@ti.com \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=robh@kernel.org \
--cc=rogerq@kernel.org \
--cc=vigneshr@ti.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