15 Nov, 2013
1 commit
-
This patch enhances the type safety for the kfifo API. It is now safe
to put const data into a non const FIFO and the API will now generate a
compiler warning when reading from the fifo where the destination
address is pointing to a const variable.As a side effect the kfifo_put() does now expect the value of an element
instead a pointer to the element. This was suggested Russell King. It
make the handling of the kfifo_put easier since there is no need to
create a helper variable for getting the address of a pointer or to pass
integers of different sizes.IMHO the API break is okay, since there are currently only six users of
kfifo_put().The code is also cleaner by kicking out the "if (0)" expressions.
[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Stefani Seibold
Cc: Russell King
Cc: Hauke Mehrtens
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds
02 Oct, 2010
1 commit
-
The kfifo_dma family of functions use sg_mark_end() on the last element in
their scatterlist. This forces use of a fresh scatterlist for each DMA
operation, which makes recycling a single scatterlist impossible.Change the behavior of the kfifo_dma functions to match the usage of the
dma_map_sg function. This means that users must respect the returned
nents value. The sample code is updated to reflect the change.This bug is trivial to cause: call kfifo_dma_in_prepare() such that it
prepares a scatterlist with a single entry comprising the whole fifo.
This is the case when you map the entirety of a newly created empty fifo.
This causes the setup_sgl() function to mark the first scatterlist entry
as the end of the chain, no matter what comes after it.Afterwards, add and remove some data from the fifo such that another call
to kfifo_dma_in_prepare() will create two scatterlist entries. It returns
nents=2. However, due to the previous sg_mark_end() call, sg_is_last()
will now return true for the first scatterlist element. This causes the
sample code to print a single scatterlist element when it should print
two.By removing the call to sg_mark_end(), we make the API as similar as
possible to the DMA mapping API. All users are required to respect the
returned nents.Signed-off-by: Ira W. Snyder
Cc: Stefani Seibold
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds
21 Aug, 2010
3 commits
-
Provide a check in all the kfifo examples to validate the correct
execution of each testcase.Signed-off-by: Andrea Righi
Acked-by: Stefani Seibold
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
We use a dynamically allocated kfifo in the dma example, so we need to
free it when unloading the module.Signed-off-by: Andrea Righi
Acked-by: Stefani Seibold
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
The scatterlist is used uninitialized in kfifo_dma_in_prepare(). This
triggers the following bug if CONFIG_DEBUG_SG=y:------------[ cut here ]------------
kernel BUG at include/linux/scatterlist.h:65!
invalid opcode: 0000 [#1] PREEMPT SMP
...
Call Trace:
[] setup_sgl+0x6b/0xe0
[] ? example_init+0x0/0x265 [dma_example]
[] __kfifo_dma_in_prepare+0x21/0x30
[] example_init+0x124/0x265 [dma_example]
[] ? trace_module_notify+0x25/0x370
[] ? free_pages_prepare+0x11e/0x1e0
[] ? get_parent_ip+0x11/0x50
[] ? trace_module_notify+0x25/0x370
[] ? trace_hardirqs_on+0xd/0x10
[] ? mutex_unlock+0xe/0x10
[] ? trace_module_notify+0x41/0x370
[] ? __blocking_notifier_call_chain+0x45/0x80
[] ? vfree+0x2a/0x30
[] ? up_read+0x23/0x40
[] ? __blocking_notifier_call_chain+0x65/0x80
[] do_one_initcall+0x43/0x180
[] sys_init_module+0xba/0x200
[] system_call_fastpath+0x16/0x1b
RIP [] setup_sgl_buf+0x1a1/0x1b0
RSP
---[ end trace a72b979fd3c1d3a5 ]---Add the proper initialization to avoid the bug.
Signed-off-by: Andrea Righi
Acked-by: Stefani Seibold
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds
11 Aug, 2010
1 commit
-
Add four examples to the kernel sample directory.
It shows how to handle:
- a byte stream fifo
- a integer type fifo
- a dynamic record sized fifo
- the fifo DMA functions[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Stefani Seibold
Cc: Greg KH
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds