mailbox/omap: Add ti,mbox-send-noirq quirk to fix AM33xx CPU Idle

The mailbox framework controls the transmission queue and requires
either its controller implementations or clients to run the state
machine for the Tx queue. The OMAP mailbox controller uses a Tx-ready
interrupt as the equivalent of a Tx-done interrupt to run this Tx
queue state-machine.

The WkupM3 processor on AM33xx and AM43xx SoCs is used to offload
certain PM tasks, like doing the necessary operations for Device
PM suspend/resume or for entering lower c-states during cpuidle.

The CPUIdle on AM33xx requires the messages to be sent without
having to trigger the Tx-ready interrupts, as the interrupt
would immediately terminate the CPUIdle operation. Support for
this has been added by introducing a DT quirk, "ti,mbox-send-noirq"
and using it to modify the normal OMAP mailbox controller behavior
on the sub-mailboxes used to communicate with the WkupM3 remote
processor. This also requires the wkup_m3_ipc driver to adjust
its mailbox usage logic to run the Tx state machine.

NOTE:
- AM43xx does not communicate with WkupM3 for CPU Idle, so is
  not affected by this behavior. But, it uses the same IPC driver
  for PM suspend/resume functionality, so requires the quirk as
  well, because of changes to the common wkup_m3_ipc driver.

Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
[s-anna@ti.com: revise logic and update comments/patch description]
Signed-off-by: Suman Anna <s-anna@ti.com>
ARM: dts: AM33XX: Add ti,mbox-send-noirq to wkup_m3 mailbox

Add ti,mbox-send-noirq to wkup_m3 mailbox so that messages using
wkup_m3 mailbox are sent without triggering any further interrupts.
This is needed to achieve lower power numbers during CPU idle on
AM33xx.

Tested-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
[s-anna@ti.com: revise commit description]
Signed-off-by: Suman Anna <s-anna@ti.com>
ARM: dts: AM4372: Add ti,mbox-send-noirq to wkup_m3 mailbox

Add ti,mbox-send-noirq to wkup_m3 mailbox so that messages using
wkup_m3 mailbox are sent without triggering any further interrupts.
This is required to be able to send multiple messages to the WkupM3
after the mailbox usage logic adjustment in the wkup_m3_ipc driver.

Signed-off-by: Keerthy <j-keerthy@ti.com>
Acked-by: Dave Gerlach <d-gerlach@ti.com>
[s-anna@ti.com: revise commit description]
Signed-off-by: Suman Anna <s-anna@ti.com>
ARM: OMAP2+: pm33xx: Only pass i2c volt scale offsets for DeepSleep

The offsets for i2c voltage scaling sequence were being set directly
into IPC register 5 and being passed for all PM operations. This is
incorrect as only DeepSleep0 should scale voltage, not standby or
cpuidle. Instead we should store the value when it is calculated
and only pass for DeepSleep operation, not cpuidle operation.

Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
remoteproc: wkup_m3: Defer probe until wkup_m3_pm_ops are populated

Defer probe till remowkup_m3_pm_ops are populated. This is to ensure
that wkup_m3 is probed after the wkup_m3_pm_ops are populated by the
mach-omap2 init call. This ensures clean initialization of m3.

Signed-off-by: Keerthy <j-keerthy@ti.com>
Acked-by: Dave Gerlach <d-gerlach@ti.com>
remoteproc: wkup_m3_rproc: Modify wkup_m3_ping to not use interrupts

The wkup_m3 needs the ability to receive messages in noirq context
during cpuidle transition. Change wkup_m3_ping to not use any mailbox
interrupts during ping now that the mailbox driver can handle sending
the message in noirq context.

Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
drm/omap: fix race condition with dev->obj_list

omap_gem_objects are added to dev->obj_list in omap_gem_new, and removed
in omap_gem_free_object. Unfortunately there's no locking for
dev->obj_list, which eventually leads to a crash:

WARNING: CPU: 1 PID: 1123 at lib/list_debug.c:59 __list_del_entry+0xa4/0xe0()
list_del corruption. prev->next should be e9281344, but was ea722b84

Add a spinlock to protect dev->obj_list.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Jyri Sarha <jsarha@ti.com>
drm/omap: fix race conditon in DMM

The omapdrm DMM code sometimes crashes with:

WARNING: CPU: 0 PID: 1235 at lib/list_debug.c:36 __list_add+0x8c/0xbc()
list_add double add: new=e9265368, prev=e90139c4, next=e9265368.

This is caused by the code calling release_engine() twice for the same
engine.

dmm_txn_commit(wait=true) call is supposed to wait until the DMM
transaction has been finished. And it does that, but it does not wait
for the irq handler to finish.

What happens is that the irq handler is triggered, and it either wakes
up the thread that called dmm_txn_commit(), or that thread never even
slept because the transaction was finished in the HW very quickly. That
thread then continues executing, even if the irq handler is not yet
finished, and a new transaction may be initiated. If that transaction is
async (i.e. wait=false), a 'async' flag is set to true. The original irq
handler, which has yet not finished, then sees the transaction as
'async', even if it was supposed to be 'sync'.

When that happens, the irq handler does an extra release_engine() call
because it thinks it need to release the engine, leading to the crash.

This patch fixes the issue by using completion to ensure that the irq
handler has finished before a dmm_txn_commit(wait=true) may continue.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Jyri Sarha <jsarha@ti.com>
video/logo: prevent use of logos after they have been freed

If the probe of an fb driver has been deferred due to missing
dependencies, and the probe is later ran when a module is loaded, the
fbdev framework will try to find a logo to use.

However, the logos are __initdata, and have already been freed. This
causes sometimes page faults, if the logo memory is not mapped,
sometimes other random crashes as the logo data is invalid, and
sometimes nothing, if the fbdev decides to reject the logo (e.g. the
random value depicting the logo's height is too big).

This patch adds a late_initcall function to mark the logos as freed. In
reality the logos are freed later, and fbdev probe may be ran between
this late_initcall and the freeing of the logos. In that case we will
miss drawing the logo, even if it would be possible.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Jyri Sarha <jsarha@ti.com>
ASoC: tlv320aic31xx: Do not ignore errors in aic31xx_device_init()

[ Upstream commit a72d2abbe5752f3a773c4d8b7b41ae41f617f772 ]

We need to return the error codes from aic31xx_device_init() and return
from the i2c_probe with the error code.
We will have kernel panic (NULL pointer dereference) in
regulator_register_notifier() in case the devm_regulator_bulk_get() fails
(with -EPROBE_DEFER for example).

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Cc: stable@vger.kernel.org

Conflicts:

	sound/soc/codecs/tlv320aic31xx.c

Signed-off-by: Jyri Sarha <jsarha@ti.com>
ARM: OMAP2: pm33xx: Bump firmware version requirement to 0x190

Bump PM firmware minimum version requirement to 0x190 to fix AM335x
cpuidle that uses the CM3 for MPU clock gating.

Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
Merge branch 'pm-ti-linux-3.14.y' of git://git.ti.com/~kristo/ti-linux-kernel/pm-linux-feature-tree into ti-linux-3.14.y

TI-Feature: power_management_base
TI-Tree: git://git.ti.com/~kristo/ti-linux-kernel/pm-linux-feature-tree.git
TI-Branch: pm-ti-linux-3.14.y

* 'pm-ti-linux-3.14.y' of git://git.ti.com/~kristo/ti-linux-kernel/pm-linux-feature-tree:
  ARM: OMAP2: pm33xx: Bump firmware version requirement to 0x190
  remoteproc: wkup_m3_rproc: Modify wkup_m3_ping to not use interrupts
  remoteproc: wkup_m3: Defer probe until wkup_m3_pm_ops are populated
  ARM: OMAP2+: pm33xx: Only pass i2c volt scale offsets for DeepSleep
  ARM: dts: AM4372: Add ti,mbox-send-noirq to wkup_m3 mailbox
  ARM: dts: AM33XX: Add ti,mbox-send-noirq to wkup_m3 mailbox
  mailbox/omap: Add ti,mbox-send-noirq quirk to fix AM33xx CPU Idle

Signed-off-by: Dan Murphy <DMurphy@ti.com>
Merge branch 'audio-display-ti-linux-3.14.y' of git://git.ti.com/~darrene/ti-linux-kernel/audio-display-linux-feature-tree into ti-linux-3.14.y

TI-Feature: audio-display
TI-Tree: git://git.ti.com/~darrene/ti-linux-kernel/audio-display-linux-feature-tree.git
TI-Branch: audio-display-ti-linux-3.14.y

* 'audio-display-ti-linux-3.14.y' of git://git.ti.com/~darrene/ti-linux-kernel/audio-display-linux-feature-tree:
  ASoC: tlv320aic31xx: Do not ignore errors in aic31xx_device_init()
  video/logo: prevent use of logos after they have been freed
  drm/omap: fix race conditon in DMM
  drm/omap: fix race condition with dev->obj_list

Signed-off-by: Dan Murphy <DMurphy@ti.com>