linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wolfgang Grandegger <wg@grandegger.com>
To: info@essax.com
Cc: Marc Kleine-Budde <mkl@pengutronix.de>,
	David Laight <David.Laight@ACULAB.COM>,
	Oliver Hartkopp <socketcan@hartkopp.net>,
	henrik@proconx.com, netdev@vger.kernel.org,
	linux-can@vger.kernel.org, socketcan-users@lists.berlios.de,
	IreneV <boir1@yandex.ru>,
	Stanislav Yelenskiy <stanislavelensky@yahoo.com>,
	oe@port.de, henrik@focus-sw.com
Subject: Re: [PATCH net-next v2 2/4] can: cc770: add legacy ISA bus driver for the CC770 and AN82527
Date: Tue, 10 Jan 2012 15:20:05 +0100	[thread overview]
Message-ID: <4F0C4915.2010909@grandegger.com> (raw)
In-Reply-To: <4F0C2F4A.20500@essax.com>

On 01/10/2012 01:30 PM, Wolfgang Zarre wrote:
> Hello Wolfgang,
> 
>> On 01/10/2012 12:11 AM, Marc Kleine-Budde wrote:
>>> On 01/09/2012 10:47 PM, Wolfgang Zarre wrote:
>>> [...]
>>>
>>>>>> OK. My concern: Can we be sure that 16bit accesses are always
>>>>> supported
>>>>>> by the hardware? Does a spinlock_irqsave/spinlock_irqrestore around
>>>>> the
>>>>>> 8bit accesses already help?
>>>>>
>>>>> Hmmm... are there any register reads that need the
>>>>> same 'double cycle' sequence ??
>>>>> If so you need to stop reads being interleaved (with
>>>>> themselves and writes) so requesting a 16bit access
>>>>> doesn't help.
>>>>>
>>>>> Which means you need a spinlock...
>>>>>
>>>>>      David
>>>>>
>>>>>
>>>>
>>>> @David: Thank You very much for that hint. You are right and to
>>>> implement correct we need a spinlock.
>>>>
>>>> @Wolfgang: I was thinking about Your question regarding 8/16 bit and
>>>> in fact it wouldn't work at all on a clean 8 bit cards.
>>>>
>>>> Further it wouldn't work on 16 bit cards where the MSB is not equal
>>>> to base port +1 and anyway, it's depending always on how the chip is
>>>> interfaced to the ISA bus and in which mode the chip is configured.
>>>>
>>>>
>>>> And therefore I was giving David's hint a try in using a spinlock in
>>>> function cc770_isa_port_write_reg_indirect() and patched as follows:
>>>>
>>>> ---------------------------------------------------------------------
>>>> diff --git a/drivers/net/can/cc770/cc770.c
>>>> b/drivers/net/can/cc770/cc770.c
>>>> index 2d12f89..dad6707 100644
>>>> --- a/drivers/net/can/cc770/cc770.c
>>>> +++ b/drivers/net/can/cc770/cc770.c
>>>> @@ -460,15 +460,6 @@ static netdev_tx_t cc770_start_xmit(struct sk_buff
>>>> *skb, struct net_device *dev)
>>>>
>>>>       stats->tx_bytes += dlc;
>>>>
>>>> -
>>>> -    /*
>>>> -     * HM: We had some cases of repeated IRQs so make sure the
>>>> -     * INT is acknowledged I know it's already further up, but
>>>> -     * doing again fixed the issue
>>>> -     */
>>>> -    cc770_write_reg(priv, msgobj[mo].ctrl0,
>>>> -            MSGVAL_UNC | TXIE_UNC | RXIE_UNC | INTPND_RES);
>>>> -
>>>>       return NETDEV_TX_OK;
>>>>   }
>>>>
>>>> @@ -689,12 +680,6 @@ static void cc770_tx_interrupt(struct net_device
>>>> *dev, unsigned int o)
>>>>       /* Nothing more to send, switch off interrupts */
>>>>       cc770_write_reg(priv, msgobj[mo].ctrl0,
>>>>               MSGVAL_RES | TXIE_RES | RXIE_RES | INTPND_RES);
>>>> -    /*
>>>> -     * We had some cases of repeated IRQ so make sure the
>>>> -     * INT is acknowledged
>>>> -     */
>>>> -    cc770_write_reg(priv, msgobj[mo].ctrl0,
>>>> -            MSGVAL_UNC | TXIE_UNC | RXIE_UNC | INTPND_RES);
>>
>> Please provide an extra patch for these unrelated changes. If we really
>> want to remove it.
>>
> 
> Sure, this I can do.
> 
>>>>       stats->tx_packets++;
>>>>       can_get_echo_skb(dev, 0);
>>>> diff --git a/drivers/net/can/cc770/cc770_isa.c
>>>> b/drivers/net/can/cc770/cc770_isa.c
>>>> index 4be5fe2..fe39eed 100644
>>>> --- a/drivers/net/can/cc770/cc770_isa.c
>>>> +++ b/drivers/net/can/cc770/cc770_isa.c
>>>> @@ -110,6 +110,9 @@ MODULE_PARM_DESC(bcr, "Bus configuration register
>>>> (default=0x40 [CBY])");
>>>>   #define CC770_IOSIZE          0x20
>>>>   #define CC770_IOSIZE_INDIRECT 0x02
>>>>
>>>> +/* Spinlock for cc770_isa_port_write_reg_indirect */
>>>> +static DEFINE_SPINLOCK( outb_lock);

Please use a more specific name, e.g.: cc770_isa_port_lock

>>>> +
>>>
>>> Do we need a global or a per device spin lock? If this should be a per
>>> device one, please introduce a cc770_isa_priv and put the spinlock
>>> there. Don't forget to initialize the spinlock.
>>
>> Yes, that's what I was thinking as well but in the ocan driver I find:
>>
>> /*
>>   * we need a spinlock here, as the address register looks shared between
>>   * two PC-ECAN devices. Moreover, we need to protect WRT interrupts
>>   */
>>
>> Looks like wired hardware. Anyway, a global spinlock might be safer.
>>
> 
> Hmmm, actually I thought to place the spinlock local because of having
> the problem just with the interrupt and not with mutex.
> 
> But if global wouldn't it then better to make an array[MAX_DEV] for the
> lock with initialisation in _init or _start?

Global means *one* spin-irq-lock for the indirect register access of all
devices. That might be the most efficient solution but we are sure that
it works, also with wired i82527 hardware, which seem to exist. That's
also what the related lincan and ocan drivers used.

Wolfgang.

  reply	other threads:[~2012-01-10 14:20 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-25  9:43 [PATCH net-next v2 0/4] can: cc770: add support for the Bosch CC770 and Intel AN82527 Wolfgang Grandegger
2011-11-25  9:43 ` [PATCH net-next v2 1/4] can: cc770: add driver core " Wolfgang Grandegger
     [not found]   ` <1322214204-1121-2-git-send-email-wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2011-11-26 15:11     ` Oliver Hartkopp
2011-11-28 11:28   ` [Socketcan-users] " Marc Kleine-Budde
2011-11-28 13:52     ` Wolfgang Grandegger
     [not found]       ` <4ED3922A.50704-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2011-11-28 14:01         ` Marc Kleine-Budde
2011-11-28 14:01           ` [Socketcan-users] " David Laight
     [not found]           ` <4ED3941D.3070302-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2011-11-28 14:10             ` Wolfgang Grandegger
     [not found]               ` <4ED3966E.7080609-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2011-11-28 14:18                 ` Marc Kleine-Budde
     [not found]     ` <4ED3704D.5020903-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2011-11-29  9:20       ` Wolfgang Grandegger
2011-11-25  9:43 ` [PATCH net-next v2 2/4] can: cc770: add legacy ISA bus driver for the CC770 and AN82527 Wolfgang Grandegger
     [not found]   ` <1322214204-1121-3-git-send-email-wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2011-11-26 14:59     ` Oliver Hartkopp
2011-11-28  8:56       ` Wolfgang Zarre
2011-11-28  9:17         ` Wolfgang Grandegger
2011-11-28 12:03           ` Wolfgang Zarre
     [not found]             ` <4ED37885.8080909-PyqsHJVlJN8AvxtiuMwx3w@public.gmane.org>
2011-11-28 16:06               ` Oliver Hartkopp
     [not found]                 ` <4ED3B198.2040308-fJ+pQTUTwRTk1uMJSBkQmQ@public.gmane.org>
2011-11-29  9:16                   ` Wolfgang Grandegger
     [not found]                     ` <4ED4A2EC.40103-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2011-12-04 18:47                       ` Wolfgang Zarre
2011-12-04 18:56                         ` Wolfgang Grandegger
     [not found]                           ` <4EDBC25D.50405-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2011-12-06 21:08                             ` Wolfgang Zarre
     [not found]                               ` <4EDE8435.5080100-PyqsHJVlJN8AvxtiuMwx3w@public.gmane.org>
2011-12-07 13:42                                 ` Wolfgang Grandegger
2011-12-09 10:26                                   ` Wolfgang Grandegger
2011-12-11 18:33                                     ` Wolfgang Zarre
     [not found]                                       ` <4EE4F76E.3000506-PyqsHJVlJN8AvxtiuMwx3w@public.gmane.org>
2011-12-12  9:23                                         ` Wolfgang Grandegger
     [not found]                                           ` <4EE5C824.2050704-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2011-12-12 11:18                                             ` Wolfgang Zarre
2011-12-12 11:55                                               ` Wolfgang Grandegger
     [not found]                                                 ` <4EE5EBBF.6080007-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2011-12-21 18:32                                                   ` Wolfgang Zarre
2011-12-22  9:37                                                     ` Wolfgang Grandegger
     [not found]                                                       ` <4EF2FA3F.3010308-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2011-12-22 13:20                                                         ` Wolfgang Zarre
     [not found]                                                           ` <4EF32E84.1080006-PyqsHJVlJN8AvxtiuMwx3w@public.gmane.org>
2011-12-31  9:39                                                             ` Wolfgang Zarre
2012-01-04 13:10                                                               ` Wolfgang Grandegger
2012-01-05  3:29                                                                 ` Wolfgang Zarre
     [not found]                                                                   ` <4F051927.8010600-PyqsHJVlJN8AvxtiuMwx3w@public.gmane.org>
2012-01-05 11:51                                                                     ` Wolfgang Grandegger
2012-01-05 12:00                                                                       ` David Laight
2012-01-09 21:47                                                                         ` Wolfgang Zarre
2012-01-09 23:11                                                                           ` Marc Kleine-Budde
2012-01-10  9:30                                                                             ` Wolfgang Grandegger
2012-01-10 12:30                                                                               ` Wolfgang Zarre
2012-01-10 14:20                                                                                 ` Wolfgang Grandegger [this message]
2012-01-10 14:25                                                                                   ` Wolfgang Grandegger
2012-01-11  9:00                                                                                 ` Wolfgang Zarre
2012-01-11  9:37                                                                                   ` David Laight
2012-01-11 14:37                                                                                     ` Wolfgang Zarre
2012-01-11  9:38                                                                                   ` Marc Kleine-Budde
2012-01-11 14:42                                                                                     ` Wolfgang Zarre
2012-01-11 15:02                                                                                       ` Marc Kleine-Budde
2012-01-10 10:00                                                                           ` David Laight
2012-01-10 12:41                                                                             ` Wolfgang Zarre
2012-01-10 14:43                                                                               ` Wolfgang Grandegger
2012-01-10 14:50                                                                                 ` Oliver Hartkopp
2012-01-10 16:13                                                                                 ` Wolfgang Zarre
2012-01-10 16:20                                                                                   ` Marc Kleine-Budde
2012-01-10 16:23                                                                                   ` Wolfgang Grandegger
2012-01-10 19:02                                                                                     ` Wolfgang Zarre
2012-01-11  9:05                                                                                       ` Wolfgang Zarre
2012-01-11  9:31                                                                                         ` Marc Kleine-Budde
2012-01-10 11:41                                                                           ` Henrik Maier
2012-01-10 11:59                                                                             ` Wolfgang Grandegger
2012-01-10 12:43                                                                               ` Wolfgang Zarre
2012-01-05 19:45                                                                       ` Oliver Hartkopp
2012-01-05 20:48                                                                         ` Oliver Hartkopp
2011-12-23 11:32                                                       ` peak_pci: device channels chained list issue Grosjean Stephane
2011-12-23 12:11                                                       ` peak_pci: device channels chained list issue (cont.) Grosjean Stephane
2012-01-31 22:12                                                         ` Marc Kleine-Budde
2011-11-28 12:09   ` [PATCH net-next v2 2/4] can: cc770: add legacy ISA bus driver for the CC770 and AN82527 Marc Kleine-Budde
     [not found]     ` <4ED379F3.1070206-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2011-11-28 13:59       ` Wolfgang Grandegger
2011-11-28 14:03         ` David Laight
     [not found]           ` <AE90C24D6B3A694183C094C60CF0A2F6D8AEE9-CgBM+Bx2aUAnGFn1LkZF6NBPR1lH4CV8@public.gmane.org>
2011-11-28 14:09             ` Marc Kleine-Budde
     [not found]               ` <4ED3960F.4040508-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2011-11-28 15:10                 ` Wolfgang Grandegger
2011-11-25  9:43 ` [PATCH net-next v2 3/4] can: cc770: add platform " Wolfgang Grandegger
2011-11-25  9:43 ` [PATCH net-next v2 4/4] powerpc: tqm8548/tqm8xx: add and update CAN device nodes 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=4F0C4915.2010909@grandegger.com \
    --to=wg@grandegger.com \
    --cc=David.Laight@ACULAB.COM \
    --cc=boir1@yandex.ru \
    --cc=henrik@focus-sw.com \
    --cc=henrik@proconx.com \
    --cc=info@essax.com \
    --cc=linux-can@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=oe@port.de \
    --cc=socketcan-users@lists.berlios.de \
    --cc=socketcan@hartkopp.net \
    --cc=stanislavelensky@yahoo.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).