1
0
Fork 0
Commit Graph

51 Commits (da2577fe63f865cd9dc785a42c29c0071f567a35)

Author SHA1 Message Date
Takashi Iwai 6ce1d63ed7 ALSA: core: Don't allow NULL device for memory allocation
Since we covered all callers with NULL device pointer, let's catch the
remaining calls with NULL and warn explicitly.

Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-02-05 11:05:26 +01:00
Takashi Iwai 3c4cfa7bf6 ALSA: memalloc: Add fall-through annotation
As a preparatory patch for the upcoming -Wimplicit-fallthrough
compiler checks, add the "fall through" annotation in
snd_dma_alloc_pages().  Note that this seems necessary to be put
exactly before the next label, so it's outside the ifdef block.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-10-12 09:31:23 +02:00
Takashi Iwai 42e748a0b3 ALSA: memalloc: Add non-cached buffer type
In some cases (mainly for x86), we need the DMA coherent buffer with
non-cached pages.  Although this has been done in each driver side
like HD-audio and intel8x0, it can be done cleaner in the core memory
allocator.

This patch adds the new types, SNDRV_DMA_TYPE_DEV_UC and
SNDRV_DMA_TYPE_DEV_UC_SG, for allocating such non-cached buffer
pages.  On non-x86 architectures, they work as same as the standard
SNDRV_DMA_TYPE_DEV and *_SG.

One additional change by this move is that we can assure to pass the
non-cached pgprot to the vmapped buffer, too.  It eventually fixes the
case like non-snoop mode without mmap access on HD-audio.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-08-28 13:56:47 +02:00
Takashi Iwai 28f3f4f685 ALSA: memalloc: Simplify snd_malloc_dev_pages() calls
snd_malloc_dev_pages() and snd_free_dev_pages() are local functions
and the parameters passed there are all contained in snd_dma_buffer
object.  As a code-simplification, pass snd_dma_buffer object and
assign the address there like other allocators do (except for
snd_malloc_pages() which is called from outside, hence we can't change
easily).

Only code refactoring, no functional changes.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-08-28 13:56:46 +02:00
Takashi Iwai 03486830c5 ALSA: memalloc: Don't align the size to power-of-two
The size passed to dma_alloc_coherent() doesn't have to be aligned
with power-of-two, rather it should be the raw size.  As a minor
optimization, remove the size adjustment in the current code.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-08-28 13:56:46 +02:00
Takashi Iwai dfef01e150 ALSA: memalloc: Don't exceed over the requested size
snd_dma_alloc_pages_fallback() tries to allocate pages again when the
allocation fails with reduced size.  But the first try actually
*increases* the size to power-of-two, which may give back a larger
chunk than the requested size.  This confuses the callers, e.g. sgbuf
assumes that the size is equal or less, and it may result in a bad
loop due to the underflow and eventually lead to Oops.

The code of this function seems incorrectly assuming the usage of
get_order().  We need to decrease at first, then align to
power-of-two.

Reported-and-tested-by: he, bo <bo.he@intel.com>
Reported-by: zhang jun <jun.zhang@intel.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-07-23 09:06:33 +02:00
Takashi Iwai 35f8001415 ALSA: core: Follow standard EXPORT_SYMBOL() declarations
Just a tidy up to follow the standard EXPORT_SYMBOL*() declarations
in order to improve grep-ability.

- Move EXPORT_SYMBOL*() to the position right after its definition
- Remove superfluous blank line before EXPORT_SYMBOL*() lines

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-06-16 16:19:16 +02:00
Vladimir Zapolskiy abdd4a7025 genalloc: rename of_get_named_gen_pool() to of_gen_pool_get()
To be consistent with other kernel interface namings, rename
of_get_named_gen_pool() to of_gen_pool_get().  In the original function
name "_named" suffix references to a device tree property, which contains
a phandle to a device and the corresponding device driver is assumed to
register a gen_pool object.

Due to a weak relation and to avoid any confusion (e.g.  in future
possible scenario if gen_pool objects are named) the suffix is removed.

[sfr@canb.auug.org.au: crypto/marvell/cesa - fix up for of_get_named_gen_pool() rename]
Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Shawn Guo <shawn.guo@linaro.org>
Cc: Sascha Hauer <kernel@pengutronix.de>
Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Cc: Vinod Koul <vinod.koul@intel.com>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Boris BREZILLON <boris.brezillon@free-electrons.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-06-30 19:45:01 -07:00
Takashi Iwai f2f9307a4f ALSA: core: Use standard printk helpers
Use dev_err() & co as much as possible.  If not available (no device
assigned at the calling point), use pr_xxx() helpers instead.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-02-14 08:14:15 +01:00
Takashi Iwai 2d82ea2005 ALSA: Merge memalloc code into snd-pcm module
Instead of keeping a separate snd-page-alloc module, merge into the
core snd-pcm module, as we don't need to keep it as an individual
module due to the drop of page reservation.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-01-09 08:12:57 +01:00
Takashi Iwai f5d8e6df4b ALSA: Remove superfluous header inclusions in memalloc.c
After cutting off the proc and page reservation codes, we don't need
many headers any longer.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-01-09 07:44:11 +01:00
Takashi Iwai 47d98c026e ALSA: Remove memory reservation code from memalloc helper
Nowadays we have CMA for obtaining the contiguous memory pages
efficiently.  Let's kill the old kludge for reserving the memory pages
for large buffers.  It was rarely useful (only for preserving pages
among module reloading or a little help by an early boot scripting),
used only by a couple of drivers, and yet it gives too much ugliness
than its benefit.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-01-09 07:32:10 +01:00
Takashi Iwai d7b135410e ALSA: Remove memory accounting in memalloc helper
It's almost superfluous, and doesn't help much for real uses.
Let's reduce the layer size.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-01-09 07:32:05 +01:00
Nicolin Chen 07968fe4ac sound/core/memalloc.c: use gen_pool_dma_alloc() to allocate iram buffer
Since gen_pool_dma_alloc() is introduced, we implement it to simplify code.

Signed-off-by: Nicolin Chen <b42378@freescale.com>
Acked-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-11-15 09:32:23 +09:00
Takashi Iwai a40a393722 ALSA: memalloc: NULL-initialize in snd_malloc_dev_iram()
dmab->area and addr fields should be cleared at the head of
snd_malloc_dev_iram() as especially dmab->area is used to indicate the
allocation failure / fallback.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-10-29 11:59:31 +01:00
Takashi Iwai 9f694bc793 ALSA: memalloc: Make snd_{malloc|free}_dev_iram() static
These are used only locally.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-10-29 11:56:21 +01:00
Takashi Iwai 63437313da ALSA: memalloc: Yet another ifdef CONFIG_GENERIC_ALLOCATOR protection
I obviously forgot to merge the right version...

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-10-28 16:08:27 +01:00
Takashi Iwai a5606f8561 ALSA: Add ifdef CONFIG_GENERIC_ALLOCATOR for SNDRV_DMA_TYPE_IRAM code
It turned out that we can't use gen_pool_*() functions on archs
without CONFIG_GENERIC_ALLOCATOR (resulting in missing symbols), since
linux/genalloc.h doesn't provide dummy functions for all.  We'd be
able to fix linux/genalloc.h size, but I take an easier path for
now...

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-10-24 14:36:40 +02:00
Nicolin Chen 055032142c ALSA: Add SoC on-chip internal ram support for DMA buffer allocation
Now it's quite common that an SoC contains its on-chip internal RAM.
By using this RAM space for DMA buffer during audio playback/record,
we can shutdown the voltage for external RAM to save power.

So add new DEV type with iram malloc()/free() and accordingly modify
current default mmap() for the iram circumstance.

Signed-off-by: Nicolin Chen <b42378@freescale.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-10-24 09:20:47 +02:00
Yacine Belkadi eb7c06e8e9 ALSA: add/change some comments describing function return values
script/kernel-doc reports the following type of warnings (when run in verbose
mode):

Warning(sound/core/init.c:152): No description found for return value of
'snd_card_create'

To fix that:
- add missing descriptions of function return values
- use "Return:" sections to describe those return values

Along the way:
- complete some descriptions
- fix some typos

Signed-off-by: Yacine Belkadi <yacine.belkadi.1@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-03-12 08:32:53 +01:00
Joe Perches bfb9035c98 treewide: Correct spelling of successfully in comments
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-09-27 18:08:04 +02:00
Clemens Ladisch fea952e5cc ALSA: core: sparse cleanups
Change the core code where sparse complains.  In most cases, this means
just adding annotations to confirm that we indeed want to do the dirty
things we're doing.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-02-14 17:10:11 +01:00
Takashi Iwai cc6a8acdee ALSA: Fix SG-buffer DMA with non-coherent architectures
Using SG-buffers with dma_alloc_coherent() is often very inefficient
on non-coherent architectures because a tracking record could be
allocated in addition for each dma_alloc_coherent() call.
Instead, simply disable SG-buffers but just allocate normal continuous
buffers on non-supported (currently all but x86) architectures.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-07-08 14:20:20 +02:00
David S. Miller 56c5d900db Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts:

	sound/core/memalloc.c
2008-10-11 12:39:35 -07:00
David S. Miller 759ee81be6 alsa: Remove special SBUS dma support code.
No longer used.

Signed-off-by: David S. Miller <davem@davemloft.net>
2008-08-29 02:14:58 -07:00
David S. Miller 738f2b7b81 sparc: Convert all SBUS drivers to dma_*() interfaces.
And all the SBUS dma interfaces are deleted.

A private implementation remains inside of the 32-bit sparc port which
exists only for the sake of the implementation of dma_*().

Signed-off-by: David S. Miller <davem@davemloft.net>
2008-08-29 02:13:15 -07:00
David S. Miller 7a715f4601 sparc: Make SBUS DMA interfaces take struct device.
This is the first step in converting all the SBUS drivers
over to generic dma_*().

Signed-off-by: David S. Miller <davem@davemloft.net>
2008-08-29 02:13:12 -07:00
Takashi Iwai 4e184f8fc0 ALSA: Fix allocation size calculation in snd_dma_alloc_pages_fallback()
snd_dma_alloc_pages_fallback() always tries to reduce the size in a half,
but it's not good when the given size isn't a power-of-two.
Check it first then try to align.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2008-08-25 09:57:19 +02:00
Takashi Iwai 77a23f2695 ALSA: Clean up SG-buffer helper functions and macros
Clean up SG-buffer helper functions and macros.  Helpers take substream
as arguments now.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2008-08-25 09:57:18 +02:00
Takashi Iwai 7eaa943c8e ALSA: Kill snd_assert() in sound/core/*
Kill snd_assert() in sound/core/*, either removed or replaced with
if () with snd_BUG_ON().

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2008-08-13 11:46:35 +02:00
Takashi Iwai c17cf06bfc [ALSA] Remove unneeded ugly hack for i386 in memalloc.c
The hack for dma_alloc_coherent() is no longer needed on 2.6.26 since
the base code was improved.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2008-05-19 13:19:15 +02:00
Denis V. Lunev 7bf4e6d3e9 sound: use non-racy method for /proc/driver/snd-page-alloc creation
Use proc_create() to make sure that ->proc_fops be setup before gluing PDE to
main tree.

Signed-off-by: Denis V. Lunev <den@openvz.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Jaroslav Kysela <perex@suse.cz>
Cc: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-04-29 08:06:20 -07:00
Julia Lawall df1deb6753 [ALSA] sound/core/memalloc.c: Add missing pci_dev_put
There should be a pci_dev_put when breaking out of a loop that iterates
over calls to pci_get_device and similar functions.
In this case, the return under the initial if needs a pci_dev_put in the
same way that the return under the subsequent for loop has a pci_dev_put.
This was fixed using the following semantic patch.
// <smpl>
@@
type T;
identifier d;
expression e;
@@
T *d;
...
while ((d = \(pci_get_device\|pci_get_device_reverse\|pci_get_subsys\|pci_get_class\)(..., d)) != NULL)
  {... when != pci_dev_put(d)
       when != e = d
(
    return d;
|
+  pci_dev_put(d);
?  return ...;
)
...}
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2008-01-31 17:29:30 +01:00
Jaroslav Kysela c1017a4cdb [ALSA] Changed Jaroslav Kysela's e-mail from perex@suse.cz to perex@perex.cz
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2007-10-16 16:51:18 +02:00
Takashi Iwai 8f11551b17 [ALSA] Fix build error without CONFIG_HAS_DMA
The recent change of include/asm-generic/dma-mapping-broken.h breaks
the build without CONFIG_HAS_DMA.  This patch is an ad hoc fix.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
2007-10-16 15:58:05 +02:00
Takashi Iwai ccec6e2c4a Convert snd-page-alloc proc file to use seq_file
Use seq_file for the proc file read/write of snd-page-alloc module.
This automatically fixes bugs in the old proc code.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-09-24 08:20:52 -07:00
Johannes Berg 9244b2c307 [ALSA] alsa core: convert to list_for_each_entry*
This patch converts most uses of list_for_each to list_for_each_entry all
across alsa. In some place apparently an item can be on a list with
different pointers so of course that isn't compatible with list_for_each, I
therefore didn't touch those places.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
2007-02-09 09:00:10 +01:00
Jörn Engel 6ab3d5624e Remove obsolete #include <linux/config.h>
Signed-off-by: Jörn Engel <joern@wohnheim.fh-wedel.de>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
2006-06-30 19:25:36 +02:00
Takashi Iwai 2ba8c15c73 [ALSA] Removed unneeded page-reserve
Modules: Memalloc module

Removed unneeded page-reservation.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2006-03-22 10:28:12 +01:00
Takashi Iwai ea50888d83 [ALSA] Use dma_alloc_coherent() hack on i386 only
Modules: Memalloc module

Use dma_alloc_coherent() hack on i386 only (as a valid arch).

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2006-03-22 10:28:06 +01:00
Ingo Molnar 1a60d4c5a0 [ALSA] semaphore -> mutex (core part)
Semaphore to mutex conversion.

The conversion was generated via scripts, and the result was validated
automatically via a script as well.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2006-03-22 10:24:50 +01:00
Clemens Ladisch d001544ded [ALSA] dynamic minors (6/6): increase maximum number of sound cards
Modules: ALSA Core,Memalloc module,ALSA sequencer

With dynamic minor numbers, we can increase the number of sound cards.

This requires that the sequencer client numbers of some kernel drivers
are allocated dynamically, too.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2006-01-03 12:29:21 +01:00
Hugh Dickins f3d48f0373 [PATCH] unpaged: fix sound Bad page states
Earlier I unifdefed PageCompound, so that snd_pcm_mmap_control_nopage and
others can give out a 0-order component of a higher-order page, which won't
be mistakenly freed when zap_pte_range unmaps it.  But many Bad page states
reported a PG_reserved was freed after all: I had missed that we need to
say __GFP_COMP to get compound page behaviour.

Some of these higher-order pages are allocated by snd_malloc_pages, some by
snd_malloc_dev_pages; or if SBUS, by sbus_alloc_consistent - but that has
no gfp arg, so add __GFP_COMP into its sparc32/64 implementations.

I'm still rather puzzled that DRM seems not to need a similar change.

Signed-off-by: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-11-22 09:13:43 -08:00
Al Viro 1ef64e670e [PATCH] gfp_t: sound
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-10-28 08:16:50 -07:00
Al Viro dd0fc66fb3 [PATCH] gfp flags annotations - part 1
- added typedef unsigned int __nocast gfp_t;

 - replaced __nocast uses for gfp flags with gfp_t - it gives exactly
   the same warnings as far as sparse is concerned, doesn't change
   generated code (from gcc point of view we replaced unsigned int with
   typedef) and documents what's going on far better.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-10-08 15:00:57 -07:00
Jiri Slaby 0dd119f703 [ALSA] pci_find_device remove
Memalloc module,CS46xx driver,VIA82xx driver,ALI5451 driver
au88x0 driver
Replace pci_find_device() with pci_get_device() and pci_dev_put().

Signed-off-by: Jiri Slaby <xslaby@fi.muni.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-09-12 10:47:08 +02:00
Takashi Iwai e0be4d32bd [ALSA] Fix compilation without CONFIG_PROC_FS
Memalloc module
Fix an error when built without CONFIG_PROC_FS.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-08-30 08:47:07 +02:00
Clemens Ladisch a53fc188ec [ALSA] make local objects static
Memalloc module,PCM Midlevel,Timer Midlevel,GUS Library,AC97 Codec
ALI5451 driver,RME9652 driver
Make some functions/variables that are used in only one file static.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2005-08-30 08:45:01 +02:00
Victor Fusco 5a0f217d96 [ALSA] sound/core Fix the sparse warning 'implicit cast to nocast type'
Memalloc module,ALSA Core,Instrument layer
Fix the sparse warning 'implicit cast to nocast type'

File/Subsystem:sound/core

Signed-off-by: Victor Fusco <victor@cetuc.puc-rio.br>
Signed-off-by: Domen Puncer <domen@coderock.org>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
2005-07-28 12:22:44 +02:00
Takashi Iwai b6a969155b [ALSA] Add write support to snd-page-alloc proc file
Documentation,Memalloc module,RME HDSP driver,RME9652 driver
Add the write support to snd-page-alloc proc file for buffer pre-allocation.
Removed the pre-allocation codes via module options.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-06-22 12:27:47 +02:00