rpmsg: omx: fix copy_to_user in register/unregister ioctls

The ION fd registration and deregistration ioctls has the
arguments reversed in the copy_to_user() calls. The same
has been fixed.

Also included a minor additional case for returning a NULL
ION handle back to user-space.

Change-Id: I9d45957f9b913fa1775e70618f0da82e914a41d6
Signed-off-by: Tyler Luu <tluu@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
rpmsg: omx: send disconnect only if omx state is connected

The rpmsg_omx driver sends a disconnect message automatically when the
driver's .release is called. This should be done only if a connection
has been established, otherwise just destroy the local end point.

Change-Id: I21b84aa6d91ae0d456f49cbe958f8e64caf691d5
Signed-off-by: Miguel Vadillo <vadillo@ti.com>
rpmsg: omx: initialize completion event in rpmsg_omx_open

An omx object is created when opening the rpmsg-omx device. However
the "reply_arrived" completion event is not initialized until the
connection message is sent across.

When the rpmsg_omx driver is removed (like in recovery), all pending
threads waiting on the "reply_arrived" are unblocked by a complete_all
call, however, if the rpmsg-omx device was only opened, such event is
not initialized yet, so the complete_all call will dereference a null
object causing a panic.

This patch moves the initialization of the "reply_arrived" completion
event to the open call, after the allocation of the omx object.

Change-Id: I92cf9cf5ac748456cb43bedc88fe1a8d80addd6c
Signed-off-by: Juan Gutierrez <jgutierrez@ti.com>

Conflicts:
	drivers/rpmsg/rpmsg_omx.c
rpmsg: omx: fix copy_to_user in register/unregister ioctls

The ION fd registration and deregistration ioctls has the
arguments reversed in the copy_to_user() calls. The same
has been fixed.

Also included a minor additional case for returning a NULL
ION handle back to user-space.

Change-Id: I9d45957f9b913fa1775e70618f0da82e914a41d6
Signed-off-by: Tyler Luu <tluu@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
OMAP: TILER: validate input width and height

Add validation of input width and height to ensure that it does
not exceed maximum pixel width and height for the specific format.

Validate maximum length for 1D allocations.

Change-Id: I64b00f93a312ae715a040da28a0b0fe663afa9d8
Signed-off-by: Andy Gross <andy.gross@ti.com>
gpu: ion: check for input arguments in ion_free

ion_free is a public API and is directly dereferencing a
pointer without checking for NULL. A check has been
added for the same and throws a WARN in case of invalid
arguments.

Change-Id: Idcf72e4449f8cba2b8342d6fb0f64600c2c59c7e
Signed-off-by: Suman Anna <s-anna@ti.com>
Revert "omap: Add TILER reservation ION heap to omap4 board file"

This reverts commit 5e8c52491cc599ac573dd61161877200edb0e763.
ion: omap: change behaviour of getting buffers from pvr fd

previous implemention shares the pvr ion client and the ion
handles associated with that client for a particular pvr fd.
now, we just call ion_share on the handles and return the
shared buffers. caller is in charge of calling ion_import using
its own ion client to get the ion handles.

Change-Id: I2abdee1daed7b5c57c66b2e5fddc4eb0d0cc1305
Signed-off-by: Tyler Luu <tluu@ti.com>
Revert "ion: omap: change behaviour of getting buffers from pvr fd"

This reverts commit 0d0816865180460434403593e999fc953562a83c.
OMAP4: DVFS: Fix scaling dependent frequencies.

When scaling dependent frequencies down it is observed that the order
in which frequencies are changed is incorrect.  For example, when core
domain changes OPP down from OPP119 to OPP50 the order is:
a) scale L3 freq down to OPP50
b) scale SGX freq down to OPP50
which is wrong.

Frequencies are scaled in order devices are registered in omap dvfs
framework in device list. Devices are inserted to the list in order,
such as dependences are satisfied if scaling frequencies up.

When scaling frequencies down traverse list backwards.

Change-Id: I752bcb264cac12514f358986a906f29ee81ba75e
Signed-off-by: Oleksandr Kozaruk <oleksandr.kozaruk@ti.com>
rpmsg: omx: add ion system heap to omx ion client

Allow the rpmsg omx ion client to access buffers from
the ion system heap.

Change-Id: Ic2d6922cb5cb05ec96f807a36b77c124769f4ef2
Signed-off-by: Tyler Luu <tluu@ti.com>
Signed-off-by: David Schleef <ds@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
OMAP4: Blaze: Add dsi timing parameters

The dsi timing parameters have moved from being
hard coded in the driver to be specified in the
board file.

Change-Id: Ife3d887fd7302242467ce093bc65330acdbf1fc2
Signed-off-by: Peter Nordström <nordstrom@ti.com>
usb: musb: implement (un)map_urb_for_dma hooks

MUSB controller cannot work in DMA mode with misaligned buffers,
switching in PIO mode.

HCD core has hooks that allow to override the default DMA
mapping and unmapping routines for host controllers that have
special DMA requirements, such as alignment contraints.

It is observed that work in PIO mode is slow and it's better
to align buffers properly before pass them to MUSB

Some ideas taken from ehci-tegra.c

Change-Id: Id6eeaa811063d408f121c79012aba921f26eb582
Signed-off-by: Ruslan Bilovol <ruslan.bilovol@ti.com>
usb: hcd: Add a dma_align flag

Some host controllers has special DMA requirements,
such as alignment contraints.
Added a flag dma_align for indicating this requirement

Change-Id: I06277ade030429a832e6db38cc695128a1033f08
Signed-off-by: Ruslan Bilovol <ruslan.bilovol@ti.com>
usbnet: dma alignment fix

Allow usb ethernet driver to be used with a controller
driver that does not support DMA to adresses not aligned
to a 4-byte boundary

Change-Id: I017163921792c888c1cffff2531de55ef7bdb7f3
Signed-off-by: Ruslan Bilovol <ruslan.bilovol@ti.com>
usb: musb: indicate DMA alignment requirement

The MUSB host controller requires DMA buffers to be aligned.
If DMA buffers are misaligned it will use (un)map_urb_for_dma
for re-aligning buffers.
This often happens with USB network adapters, where skbuff
alignment is often in the middle of a 4-byte dword.
Indicate host controller DMA alignment requirement for such cases

Change-Id: I8a03f392caff762e9b48b65d31a119fdd833ae69
Signed-off-by: Ruslan Bilovol <ruslan.bilovol@ti.com>
usb: ehci-omap: indicate DMA alignment requirement

The OMAP host controller requires DMA buffers to be aligned.
If DMA buffers are misaligned then DMA transfers may take more
time.
This often happens with USB network adapters, where skbuff
alignment is often in the middle of a 4-byte dword.
Indicate host controller DMA alignment requirement for such cases

Change-Id: Ic2191f3f339cb189b02218d43b6d432cfe136269
Signed-off-by: Ruslan Bilovol <ruslan.bilovol@ti.com>
MFD: twl6040-codec: cancel synch all active works on suspend

The TWL6040 vib_update work has to be canceled synchronously
before continue suspending, because of:
- it may sleep while accessing to I2C bus and, as result, WFI may be
reached in the middle of its execution and that may prevent system
from entering to OFF state.
- the device suspend handler may switch TWL6040 device to sleep
state while vib_update work is still active.

Change-Id: I77b681188976378eec9242ea64dc5f001960d279
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
MFD: TWL6030: cancel synch all active works on suspend

The TWL6030 battery works have to be canceled synchronously
before continue suspending, because of:
- they may sleep while accessing to I2C bus and, as result, WFI may be
reached in the middle of its execution and that may prevent system
from entering to OFF state.
- the device suspend handler may switch TWL6030 device to sleep
state while their works are still active.

Change-Id: Ie3ef579e05bded049e39f9186acb01b116283c87
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
ALSA: usb-audio: fixed usb audio subsystem initialization

If USB audio device is already present on bus during
snd_usb_audio_init initialization will fail and kernel
will reboot due to null-pointer dereference.

The snd_usb_audio_init consists of 2 steps:
1) usb_register() - registers USB audio driver
2) switch_dev_register() - initializes the switch_dev sdev structure

If there is no USB audio device present on the bus, the
snd_usb_audio_init will finish with initialized sdev structure.
After that if USB audio device is plugged, the usb_audio_probe
callback will initialize device (during this step we are accessing sdev)

But if USB audio device is already present on bus during
snd_usb_audio_init initialization, usb_audio_probe callback will
be called during usb_register() - when sdev isn't initialized yet.
We are getting reboot due to null-pointer dereference.

Changed order of described steps so sdev is initialized when
calling usb_register.

Change-Id: Id22356157af2b69038506f1138a6da78d8f1e727
Signed-off-by: Ruslan Bilovol <ruslan.bilovol@ti.com>