From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Alexander Stein <alexander.stein@systec-electronic.com>,
Wolfgang Grandegger <wg@grandegger.com>,
Marc Kleine-Budde <mkl@pengutronix.de>
Cc: linux-can@vger.kernel.org
Subject: Re: [PATCH 1/5] can: slcan: Fix spinlock variant
Date: Tue, 22 Apr 2014 21:58:36 +0200 [thread overview]
Message-ID: <5356C9EC.4050100@hartkopp.net> (raw)
In-Reply-To: <1397573468-7619-2-git-send-email-alexander.stein@systec-electronic.com>
On 15.04.2014 16:51, Alexander Stein wrote:
> slc_xmit is called within softirq context and locks sl->lock, but
> slcan_write_wakeup is not softirq context, so we need to use
> spin_[un]lock_bh!
> Detected using kernel lock debugging mechanism.
>
> Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Btw. two questions:
1. Is it still valid in slc_xmit() to use spin_lock without _bh then as the
only occurrences in slcan.c?
2. Does this problem also exist in our 'twin' code in slip.c in
slip_write_wakeup() and sl_tx_timeout() then?
Best regards,
Oliver
> ---
> I found this by just enabling the kernel config options named in
> Documentation/SubmitChecklist :)
>> 12: Has been tested with CONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT,
>> CONFIG_DEBUG_SLAB, CONFIG_DEBUG_PAGEALLOC, CONFIG_DEBUG_MUTEXES,
>> CONFIG_DEBUG_SPINLOCK, CONFIG_DEBUG_ATOMIC_SLEEP, CONFIG_PROVE_RCU
>> and CONFIG_DEBUG_OBJECTS_RCU_HEAD all simultaneously enabled.
>
> drivers/net/can/slcan.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c
> index 3fcdae2..2577c1e 100644
> --- a/drivers/net/can/slcan.c
> +++ b/drivers/net/can/slcan.c
> @@ -322,13 +322,13 @@ static void slcan_write_wakeup(struct tty_struct *tty)
> if (!sl || sl->magic != SLCAN_MAGIC || !netif_running(sl->dev))
> return;
>
> - spin_lock(&sl->lock);
> + spin_lock_bh(&sl->lock);
> if (sl->xleft <= 0) {
> /* Now serial buffer is almost free & we can start
> * transmission of another packet */
> sl->dev->stats.tx_packets++;
> clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
> - spin_unlock(&sl->lock);
> + spin_unlock_bh(&sl->lock);
> netif_wake_queue(sl->dev);
> return;
> }
> @@ -336,7 +336,7 @@ static void slcan_write_wakeup(struct tty_struct *tty)
> actual = tty->ops->write(tty, sl->xhead, sl->xleft);
> sl->xleft -= actual;
> sl->xhead += actual;
> - spin_unlock(&sl->lock);
> + spin_unlock_bh(&sl->lock);
> }
>
> /* Send a can_frame to a TTY queue. */
>
next prev parent reply other threads:[~2014-04-22 19:58 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-15 14:51 Bitrate and CAN status support for slcan Alexander Stein
2014-04-15 14:51 ` [PATCH 1/5] can: slcan: Fix spinlock variant Alexander Stein
2014-04-22 19:58 ` Oliver Hartkopp [this message]
2014-04-24 20:32 ` Marc Kleine-Budde
2014-04-15 14:51 ` [PATCH 2/5] can: slcan: Convert to can_dev interface Alexander Stein
2014-04-17 19:10 ` Marc Kleine-Budde
2014-04-15 14:51 ` [PATCH 3/5] can: slcan: Send open/close command upon interface up/down Alexander Stein
2014-04-15 14:51 ` [PATCH 4/5] can: slcan: Add bitrate change support Alexander Stein
2014-04-17 19:13 ` Marc Kleine-Budde
2014-04-15 14:51 ` [PATCH 5/5] can: slcan: Add CAN status flag support Alexander Stein
2014-04-17 19:22 ` Marc Kleine-Budde
2014-04-19 20:38 ` Oliver Hartkopp
2014-04-19 19:24 ` Bitrate and CAN status support for slcan Oliver Hartkopp
2014-04-22 7:08 ` Alexander Stein
2014-04-22 19:50 ` Oliver Hartkopp
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=5356C9EC.4050100@hartkopp.net \
--to=socketcan@hartkopp.net \
--cc=alexander.stein@systec-electronic.com \
--cc=linux-can@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=wg@grandegger.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).