From: Stefan Wahren <wahrenst@gmx.net>
To: Paolo Abeni <pabeni@redhat.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>
Cc: Lino Sanfilippo <LinoSanfilippo@gmx.de>,
Florian Fainelli <f.fainelli@gmail.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/4 net] qca_spi: Fix SPI thread creation
Date: Fri, 24 Nov 2023 14:40:33 +0100 [thread overview]
Message-ID: <d4385cad-41e2-4adc-99b1-45a5b75a2ad5@gmx.net> (raw)
In-Reply-To: <5327988fc5d02f3352be66b5f0a2ca9a468ef1da.camel@redhat.com>
Hi Paolo,
Am 23.11.23 um 12:26 schrieb Paolo Abeni:
> On Tue, 2023-11-21 at 17:30 +0100, Stefan Wahren wrote:
>> The qca_spi driver create/stop the SPI kernel thread in case
>> of netdev_open/close. This is a big issue because it allows
>> userspace to prevent from restarting the SPI thread after
>> ring parameter changes (e.g. signals which stop the thread).
>> This could be done by terminating a script which changes
>> the ring parameter in a loop.
>>
>> So fix this by moving create/stop of the SPI kernel into
>> the init/uninit ops. The open/close ops could be realized just
>> by 'park/unpark' the SPI kernel thread.
>>
>> Fixes: 291ab06ecf67 ("net: qualcomm: new Ethernet over SPI driver for QCA7000")
>> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
>> ---
>> drivers/net/ethernet/qualcomm/qca_spi.c | 35 ++++++++++++++++---------
>> 1 file changed, 23 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
>> index bec723028e96..b11a998b2456 100644
>> --- a/drivers/net/ethernet/qualcomm/qca_spi.c
>> +++ b/drivers/net/ethernet/qualcomm/qca_spi.c
>> @@ -580,6 +580,11 @@ qcaspi_spi_thread(void *data)
>> netdev_info(qca->net_dev, "SPI thread created\n");
>> while (!kthread_should_stop()) {
>> set_current_state(TASK_INTERRUPTIBLE);
>> + if (kthread_should_park()) {
>> + kthread_parkme();
>> + continue;
>> + }
>> +
>> if ((qca->intr_req == qca->intr_svc) &&
>> !qca->txr.skb[qca->txr.head])
>> schedule();
>> @@ -679,25 +684,17 @@ qcaspi_netdev_open(struct net_device *dev)
>> qca->sync = QCASPI_SYNC_UNKNOWN;
>> qcafrm_fsm_init_spi(&qca->frm_handle);
>>
>> - qca->spi_thread = kthread_run((void *)qcaspi_spi_thread,
>> - qca, "%s", dev->name);
>> -
>> - if (IS_ERR(qca->spi_thread)) {
>> - netdev_err(dev, "%s: unable to start kernel thread.\n",
>> - QCASPI_DRV_NAME);
>> - return PTR_ERR(qca->spi_thread);
>> - }
>> -
>> ret = request_irq(qca->spi_dev->irq, qcaspi_intr_handler, 0,
>> dev->name, qca);
>> if (ret) {
>> netdev_err(dev, "%s: unable to get IRQ %d (irqval=%d).\n",
>> QCASPI_DRV_NAME, qca->spi_dev->irq, ret);
>> - kthread_stop(qca->spi_thread);
>> return ret;
>> }
>>
>> /* SPI thread takes care of TX queue */
>> + kthread_unpark(qca->spi_thread);
>> + wake_up_process(qca->spi_thread);
> The above looks racy: after 'request_irq()' the interrupt handler can
> raise an irq before the thread being unparked.
yes fixing the whole resource allocation issue requires patch 1 and 2
applied, which should avoid the race. But i didn't want to combine both
patches to keep it applicable for stable. My thought was that 2 smaller
patches are more acceptable than a big one.
Should i squash them?
My concern is about the amount of affected devices. The QCA7000 is used
mostly in EV charging stations and EVs. I don't how many of them use
this driver.
> Additionally I think you can drop the 'if (qca->spi_thread)' in
> qcaspi_intr_handler()
Thanks i will check that for the next version.
>
> Cheers,
>
> Paolo
>
next prev parent reply other threads:[~2023-11-24 13:40 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-21 16:30 [PATCH 0/4 net] qca_spi: collection of major fixes Stefan Wahren
2023-11-21 16:30 ` [PATCH 1/4 net] qca_spi: Fix SPI thread creation Stefan Wahren
2023-11-23 11:26 ` Paolo Abeni
2023-11-24 13:40 ` Stefan Wahren [this message]
2023-11-21 16:30 ` [PATCH 2/4 net] qca_spi: Fix SPI IRQ handling Stefan Wahren
2023-11-23 11:37 ` Paolo Abeni
2023-11-24 14:01 ` Stefan Wahren
2023-11-24 15:33 ` Paolo Abeni
2023-11-24 22:02 ` Stefan Wahren
2023-11-21 16:30 ` [PATCH 3/4 net] qca_spi: Fix ethtool -G iface tx behavior Stefan Wahren
2023-11-23 11:51 ` Paolo Abeni
2023-11-24 14:17 ` Stefan Wahren
2023-11-24 15:49 ` Paolo Abeni
2023-11-21 16:30 ` [PATCH 4/4 net] qca_spi: Fix reset behavior Stefan Wahren
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=d4385cad-41e2-4adc-99b1-45a5b75a2ad5@gmx.net \
--to=wahrenst@gmx.net \
--cc=LinoSanfilippo@gmx.de \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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
all inboxes | Powered by JetHome®