All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@cam.ac.uk>
To: "Murali K. Vemuri" <vemuri.muralikrishna@gmail.com>
Cc: 徐建辉 <xujianhui168@gmail.com>,
	linux-kernel@vger.kernel.org,
	spi-devel-general@lists.sourceforge.net,
	"Grant Likely" <grant.likely@secretlab.ca>
Subject: Re: SPI read problem
Date: Wed, 20 Apr 2011 14:48:00 +0100	[thread overview]
Message-ID: <4DAEE410.8020000@cam.ac.uk> (raw)
In-Reply-To: <BANLkTi=9dROLwWH2J=Y_FmP+t=rkjMLBJg@mail.gmail.com>

On 04/20/11 05:40, Murali K. Vemuri wrote:
> On Wed, Apr 20, 2011 at 12:19 PM, 徐建辉 <xujianhui168@gmail.com> wrote:
>> you can use tasklet.
>>
>> 2011/4/19 Murali K. Vemuri <vemuri.muralikrishna@gmail.com>
>>>
>>> Hello there,
>>> I have a device which is Written_to/Read_from using SPI Bus.
>>>
>>> I initialize the device like this:
>>>
>>> static int __init myDEV_init(void)
>>> {
>>>    return spi_register_driver(&myDEV_driver);
>>> }
>>> module_init(myDEV_init);
>>>
>>> My myDEV_probe() function looks like this:
>>>
>>> static int __devinit myDEV_probe(struct spi_device *spi)
>>> {
>>> .....
>>> .....
>>> /*when my CPU receives a particular IRQ, I have to do a spi_read() and
>>> do couple of spi_write(), I am using like this:*/
>>> err = request_threaded_irq (MY_DEV_IRQ, NULL, myDEV_irq_thread,
>>>            IRQF_TRIGGER_RISING, "MYDEV", NULL);
This should be fine.  The thread can sleep just fine. We do this
all over the place.  Could be something to do with the irq
handling on the device.
>>>
>>> return 0;
>>> }
>>>
>>> When the Interrupt is received by the CPU, myDEV_irq_thread is being
>>> called.
>>> However, in the ISR I have to do  spi_read(). This is always returning
>>> "Timed out".
That's very suspicious.  What spi controller are we dealing with here?
>>>
>>> To verify if the device is not at all working, along with registering
>>> for the IRQ, I also created a char device through I did a IOCTL.
>>> The IOCTL command in turn does spi_read(). In this case spi_read() is
>>> successful.
>>>
>>> Since it is necessary to do spi_read() in my ISR, I searched around
>>> and found some information that
>>> spi_read() is callable only from contexts that can sleep.
>>>
>>> How can I make my ISR sleep? or is there any other way of doing this?
>>>
>>> Any help is highly appreciated.
>>> Thanks & regards
>>> Murali
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>> Please read the FAQ at  http://www.tux.org/lkml/
>>
>>
> 
> Hi there,
> 
> I tried using "tasklet", "workqueue" and semaphore ... all my attempts failed.
> if there is any other method I should try, please let me know.
Something nastier is happening here.  It's not a problem with what you've
presented in this email.  Perhaps a minimum example of the full code surrounding
the problem may help us diagnose it.  

  reply	other threads:[~2011-04-20 13:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-19 11:41 SPI read problem Murali K. Vemuri
     [not found] ` <BANLkTimFd0ZuP2OQ4A_w7VFbDDN+rsvBtg@mail.gmail.com>
2011-04-20  4:40   ` Murali K. Vemuri
2011-04-20 13:48     ` Jonathan Cameron [this message]
2011-04-21  1:15       ` Murali K. Vemuri
2011-04-21  2:05         ` Pei Lin
2011-04-21  2:33           ` Murali K. Vemuri
2011-04-21 11:30             ` Murali K. Vemuri
2011-04-21 11:35               ` Jonathan Cameron
2011-04-22 12:22                 ` Murali K. Vemuri
  -- strict thread matches above, loose matches on Subject: below --
2011-04-19 21:46 Murali K. Vemuri

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=4DAEE410.8020000@cam.ac.uk \
    --to=jic23@cam.ac.uk \
    --cc=grant.likely@secretlab.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=spi-devel-general@lists.sourceforge.net \
    --cc=vemuri.muralikrishna@gmail.com \
    --cc=xujianhui168@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.