linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mirza Krak <mirza.krak@hostmobility.com>
To: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: Wolfgang Grandegger <wg@grandegger.com>,
	linux-can@vger.kernel.org,
	Rickard Gustafsson <rickard.gustafsson@hostmobility.com>,
	Tord Andersson <tord.andersson@endian.se>
Subject: Re: Dual SJA1000 can controllers on SMP system.
Date: Mon, 17 Jun 2013 20:49:28 +0200	[thread overview]
Message-ID: <51BF5A38.3080001@hostmobility.com> (raw)
In-Reply-To: <51BF193B.1030307@pengutronix.de>

[-- Attachment #1: Type: text/plain, Size: 1250 bytes --]

Thank you Marc for your patch. We  applied it but it did not solve our 
problem.

Wolfgang suggested defining a lock common for all devices:

  static DEFINE_SPINLOCK(snor_bus_lock);

Which I applied and now it seems to work perfectly. Thank you for your help.

Should I blame the hardware driver? :)

Attaching the patch for reference .

Med Vänliga Hälsningar / Best Regards
Mirza

*******************************************************************
Mirza Krak
Host Mobility AB
mirza.krak@hostmobility.com
Anders Personsgatan 12, 416 64 Göteborg
Sweden
www.hostmobility.com <http://www.hostmobility.com>
Direct: +46 31 31 32 704
Phone: +46 31 31 32 700
Fax: +46 31 80 67 51
Mobile: +46 730 28 06 22
*******************************************************************


On 06/17/2013 04:12 PM, Marc Kleine-Budde wrote:
> On 06/17/2013 03:46 PM, Mirza Krak wrote:
>> My modifications to sja1000_platform.c are attached as a patch.
>>
>> Wolfgang: Using spinlock_irqsave() and spinlock_irqrestore() was also my
>> initial idea on the io functions but I tried this without it solving the
>> problem. I could try this again to be sure.
>
> Without problem locking it not work anyway. Try the attached patch (it's
> compile time tested only).
>
> Marc
>

[-- Attachment #2: sja1000_platform.c.patch --]
[-- Type: text/x-diff, Size: 1261 bytes --]

Index: drivers/net/can/sja1000/sja1000_platform.c
===================================================================
--- drivers/net/can/sja1000/sja1000_platform.c	(revision 519)
+++ drivers/net/can/sja1000/sja1000_platform.c	(working copy)
@@ -27,6 +27,7 @@
 #include <linux/can/dev.h>
 #include <linux/can/platform/sja1000.h>
 #include <linux/io.h>
+#include <linux/spinlock_types.h>
 
 #include "sja1000.h"
 
@@ -36,16 +37,29 @@
 MODULE_DESCRIPTION("Socket-CAN driver for SJA1000 on the platform bus");
 MODULE_LICENSE("GPL v2");
 
+static DEFINE_SPINLOCK(snor_bus_lock);
+
 static u8 sp_read_reg8(const struct sja1000_priv *priv, int reg)
 {
+	u8 value;
+	unsigned long flags;
+
+	spin_lock_irqsave(&snor_bus_lock, flags);
 	iowrite8(reg, priv->reg_base);
-	return ioread8(priv->reg_base + 0x20);
+	value = ioread8(priv->reg_base + 0x20);
+	spin_unlock_irqrestore(&snor_bus_lock, flags);
+
+	return value;
 }
 
 static void sp_write_reg8(const struct sja1000_priv *priv, int reg, u8 val)
 {
+	unsigned long flags;
+
+	spin_lock_irqsave(&snor_bus_lock, flags);
 	iowrite8(reg, priv->reg_base);
 	iowrite8(val, (priv->reg_base + 0x20));
+	spin_unlock_irqrestore(&snor_bus_lock, flags);
 }
 
 static u8 sp_read_reg16(const struct sja1000_priv *priv, int reg)

  reply	other threads:[~2013-06-17 18:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-16 11:20 Dual SJA1000 can controllers on SMP system mirza
2013-06-16 12:39 ` Wolfgang Grandegger
2013-06-17  6:10   ` Mirza Krak
2013-06-17  7:18     ` Marc Kleine-Budde
2013-06-17 13:46       ` Mirza Krak
2013-06-17 14:12         ` Marc Kleine-Budde
2013-06-17 18:49           ` Mirza Krak [this message]
2013-06-17 19:34             ` Wolfgang Grandegger
  -- strict thread matches above, loose matches on Subject: below --
2013-06-13 12:47 Mirza Krak
2013-06-16  9:20 ` Wolfgang Grandegger

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=51BF5A38.3080001@hostmobility.com \
    --to=mirza.krak@hostmobility.com \
    --cc=linux-can@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=rickard.gustafsson@hostmobility.com \
    --cc=tord.andersson@endian.se \
    --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).