All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Genoud <richard.genoud@gmail.com>
To: Nicolas Ferre <nicolas.ferre@atmel.com>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Wenyou Yang <wenyou.yang@atmel.com>,
	linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: SPI zero-length transfer: What should it do ?
Date: Tue, 05 Nov 2013 10:34:14 +0100	[thread overview]
Message-ID: <5278BB96.20207@gmail.com> (raw)

Hi,

As I was coding something like this:
	static struct spi_ioc_transfer *xfer;
	struct spi_frame *rx_frame;
	xfer = calloc(nb, sizeof(*xfer));

	for (i = 0; i < nb; i++) {
		xfer[i].tx_buf = (unsigned long)tx_buf;
		xfer[i].rx_buf = (unsigned long)rx_buf;
		xfer[i].len = 0;
	}

	err = ioctl(spi_data->fd, SPI_IOC_MESSAGE(nb), xfer);
I ran into a bug in spi-atmel.c

NB: The zero-length SPI message was not intentional, it was just a bug in my software.

[   13.593750] spidev spi1.1:   xfer len 0 rx tx cs 8bits 150 usec 18000000Hz
[   13.601562] spidev spi1.1:   xfer len 0 rx tx cs 8bits 150 usec 18000000Hz
[   13.601562] spidev spi1.1:   xfer len 0 rx tx cs 8bits 150 usec 18000000Hz
[   13.609375] spidev spi1.1:   xfer len 0 rx tx cs 8bits 150 usec 18000000Hz
[   13.617187] spidev spi1.1:   xfer len 0 rx tx cs 8bits 150 usec 18000000Hz
[   13.625000] spidev spi1.1:   xfer len 0 rx tx cs 8bits 150 usec 18000000Hz
[   13.632812] spidev spi1.1:   xfer len 0 rx tx cs 8bits 150 usec 18000000Hz
[   13.632812] atmel_spi f0004000.spi: new message c7b49ec4 submitted for spi1.1
[   13.632812] atmel_spi f0004000.spi: start message c7b49ec4 for spi1.1
[   13.632812] spidev spi1.1: activate 16, mr 000d0031
[   13.632812] atmel_spi f0004000.spi: atmel_spi_next_xfer_pio
[   13.632812] atmel_spi f0004000.spi:   start pio xfer c79d80c0: len 0 tx c6e00000 rx c6e00000 bitpw 8
[   13.632812] irq 29: nobody cared (try booting with the "irqpoll" option)
[   13.632812] CPU: 0 PID: 494 Comm: multichannel Not tainted 3.11.2 #1
[   13.632812] [<c0012e20>] (unwind_backtrace+0x0/0xe0) from [<c0010bb8>] (show_stack+0x10/0x14)
[   13.632812] [<c0010bb8>] (show_stack+0x10/0x14) from [<c004d5b4>] (__report_bad_irq+0x1c/0xb4)
[   13.632812] [<c004d5b4>] (__report_bad_irq+0x1c/0xb4) from [<c004d9ac>] (note_interrupt+0x178/0x234)
[   13.632812] [<c004d9ac>] (note_interrupt+0x178/0x234) from [<c004c078>] (handle_irq_event_percpu+0x170/0x1a0)
[   13.632812] [<c004c078>] (handle_irq_event_percpu+0x170/0x1a0) from [<c004c0d0>] (handle_irq_event+0x28/0x38)
[   13.632812] [<c004c0d0>] (handle_irq_event+0x28/0x38) from [<c004e57c>] (handle_fasteoi_irq+0xa4/0xe4)
[   13.632812] [<c004e57c>] (handle_fasteoi_irq+0xa4/0xe4) from [<c004b910>] (generic_handle_irq+0x20/0x30)
[   13.632812] [<c004b910>] (generic_handle_irq+0x20/0x30) from [<c000f3e8>] (handle_IRQ+0x60/0x84)
[   13.632812] [<c000f3e8>] (handle_IRQ+0x60/0x84) from [<c00115e0>] (__irq_svc+0x40/0x4c)
[   13.632812] [<c00115e0>] (__irq_svc+0x40/0x4c) from [<bf1293dc>] (spidev_sync+0x6c/0x94 [spidev])
[   13.632812] [<bf1293dc>] (spidev_sync+0x6c/0x94 [spidev]) from [<bf129b24>] (spidev_ioctl+0x53c/0x66c [spidev])
[   13.632812] [<bf129b24>] (spidev_ioctl+0x53c/0x66c [spidev]) from [<c0087730>] (vfs_ioctl+0x28/0x3c)
[   13.632812] [<c0087730>] (vfs_ioctl+0x28/0x3c) from [<c0088158>] (do_vfs_ioctl+0x4e8/0x54c)
[   13.632812] [<c0088158>] (do_vfs_ioctl+0x4e8/0x54c) from [<c00881f0>] (SyS_ioctl+0x34/0x58)
[   13.632812] [<c00881f0>] (SyS_ioctl+0x34/0x58) from [<c000e500>] (ret_fast_syscall+0x0/0x2c)
[   13.632812] handlers:
[   13.632812] [<bf01142c>] atmel_spi_pio_interrupt [spi_atmel]
[   13.632812] Disabling IRQ #29

And that make me wonder what was the behavior to adopt in case of a zero-length transfer ?
Should spidev.c just return ok without doing anything ? Should it return -EINVAL ?
Or maybe we should activate/deactivate the chip select ?


Best regards,
Richard.

             reply	other threads:[~2013-11-05  9:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-05  9:34 Richard Genoud [this message]
     [not found] ` <5278BB96.20207-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-11-05  9:41   ` SPI zero-length transfer: What should it do ? Richard Genoud
2013-11-05  9:41     ` Richard Genoud

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=5278BB96.20207@gmail.com \
    --to=richard.genoud@gmail.com \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=nicolas.ferre@atmel.com \
    --cc=wenyou.yang@atmel.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.