From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Mirza Krak <mirza.krak@hostmobility.com>
Cc: Wolfgang Grandegger <wg@grandegger.com>,
linux-can@vger.kernel.org,
Rickard Gustafsson <rickard.gustafsson@hostmobility.com>
Subject: Re: Dual SJA1000 can controllers on SMP system.
Date: Mon, 17 Jun 2013 16:12:11 +0200 [thread overview]
Message-ID: <51BF193B.1030307@pengutronix.de> (raw)
In-Reply-To: <51BF132B.3020705@hostmobility.com>
[-- Attachment #1.1: Type: text/plain, Size: 700 bytes --]
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
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-HACK-can-sja1000_platform-add-support-for-indirect-r.patch --]
[-- Type: text/x-diff; name="0001-HACK-can-sja1000_platform-add-support-for-indirect-r.patch", Size: 2793 bytes --]
From bfebee863f12bee39dee9b00bfe9e3d8c1017d16 Mon Sep 17 00:00:00 2001
From: Marc Kleine-Budde <mkl@pengutronix.de>
Date: Mon, 17 Jun 2013 16:09:13 +0200
Subject: [PATCH] HACK: can: sja1000_platform: add support for indirect
register access
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Based on a privious work by Vänliga Hälsningar.
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/sja1000/sja1000_platform.c | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/drivers/net/can/sja1000/sja1000_platform.c b/drivers/net/can/sja1000/sja1000_platform.c
index 8e259c5..35f279c 100644
--- a/drivers/net/can/sja1000/sja1000_platform.c
+++ b/drivers/net/can/sja1000/sja1000_platform.c
@@ -37,14 +37,33 @@ MODULE_DESCRIPTION("Socket-CAN driver for SJA1000 on the platform bus");
MODULE_ALIAS("platform:" DRV_NAME);
MODULE_LICENSE("GPL v2");
+struct sp_priv {
+ spinlock_t ind_lock;
+};
+
static u8 sp_read_reg8(const struct sja1000_priv *priv, int reg)
{
- return ioread8(priv->reg_base + reg);
+ struct sp_priv *sp = priv->priv;
+ unsigned long flags;
+ u8 val;
+
+ spin_lock_irqsave(&sp->ind_lock, flags);
+ iowrite8(reg, priv->reg_base);
+ val = ioread8(priv->reg_base + 0x20);
+ spin_unlock_irqrestore(&sp->ind_lock, flags);
+
+ return val;
}
static void sp_write_reg8(const struct sja1000_priv *priv, int reg, u8 val)
{
- iowrite8(val, priv->reg_base + reg);
+ struct sp_priv *sp = priv->priv;
+ unsigned long flags;
+
+ spin_lock_irqsave(&sp->ind_lock, flags);
+ iowrite8(reg, priv->reg_base);
+ iowrite8(val, (priv->reg_base + 0x20));
+ spin_unlock_irqrestore(&sp->ind_lock, flags);
}
static u8 sp_read_reg16(const struct sja1000_priv *priv, int reg)
@@ -73,6 +92,7 @@ static int sp_probe(struct platform_device *pdev)
void __iomem *addr;
struct net_device *dev;
struct sja1000_priv *priv;
+ struct sp_priv *sp;
struct resource *res_mem, *res_irq;
struct sja1000_platform_data *pdata;
@@ -102,12 +122,13 @@ static int sp_probe(struct platform_device *pdev)
goto exit_release;
}
- dev = alloc_sja1000dev(0);
+ dev = alloc_sja1000dev(sizeof(struct sp_priv));
if (!dev) {
err = -ENOMEM;
goto exit_iounmap;
}
priv = netdev_priv(dev);
+ sp = priv->priv;
dev->irq = res_irq->start;
priv->irq_flags = res_irq->flags & IRQF_TRIGGER_MASK;
@@ -118,6 +139,7 @@ static int sp_probe(struct platform_device *pdev)
priv->can.clock.freq = pdata->osc_freq / 2;
priv->ocr = pdata->ocr;
priv->cdr = pdata->cdr;
+ spin_lock_init(&sp->ind_lock);
switch (res_mem->flags & IORESOURCE_MEM_TYPE_MASK) {
case IORESOURCE_MEM_32BIT:
--
1.8.3.1
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]
next prev parent reply other threads:[~2013-06-17 14:12 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 [this message]
2013-06-17 18:49 ` Mirza Krak
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=51BF193B.1030307@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=linux-can@vger.kernel.org \
--cc=mirza.krak@hostmobility.com \
--cc=rickard.gustafsson@hostmobility.com \
--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).