ASoC: wcd9320: Add NULL checks

An failed device start is bad enough, don't crash the device.
Non-negative errors look a bit funny, though.
msm: ocmem: Serialize allocation requests only when necessary

Certain clients of ocmem always have exclusive regions set aside in
the OCMEM memory map. Allocation requests for such clients do not
have to wait for any pending evictions in progress to be completed
nor will trigger any new evictions and can be safely scheduled right
away.

CRs-Fixed: 599002
Change-Id: I54369bca9d26378a9aa70db83d35ab94866a3ff1
Signed-off-by: Naveen Ramaraj <nramaraj@codeaurora.org>
Signed-off-by: Neeti Desai <neetid@codeaurora.org>
msm: pm: Set affinity of PM irqs to next scheduled CPU

Modify the affinity of the interrupts associated with PM driver to the cpu
that will wakeup for the next expiring timer.

Change-Id: I6a1b25538a6d12bada3345a17b3ed4ff181ac089
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
msm: smd: Use irq_set_affinity() API instead of the callback in irqchip.

When affinity is set by directly accessing the function pointer via
irqchip, the irq doesn't get migrated during hotplug and could result in
spurious wakeup of offlined cores. Switch to using irq_set_affinity
which ensures that the irq gets migrated during hotplug.

Change-Id: If700323f636d4ee4978b5e168077514e4d142cb9
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
slim_msm: ngd: Return success for channel removal during ADSP SSR

Slimbus master component resides on ADSP when this driver is used.
Wehn ADSP restarts, slimbus component goes down and bus is not
operational until it comes back up. During restart, slimbus clients
are notified since their device goes down, and the clients remove
channels and/or disconnect ports. Since bus is not operational,
return success for channel removal/port disconnection calls so that
the channel, port state is consistent with HW (not active, removed)

Change-Id: Ia2707ed9f3fc3573b5746c8e42fa7f229e0dea4f
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
slim_ngd: Return success for resource removal requests if HW restarts

Channel and ports are removed when HW restarts. Return success to
client channel removal, port disconnection requests when slimbus HW
is restarting.

Change-Id: Ifc9a3bb80023c823a7776a16fe32e5b59b181350
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
slim_msm: Add support for external MDM restart

If external MDM restarts when MDM slimbus channels are active, it
is possible that the MDM framer was clocking the bus, and ADSP was
not active. Make sure apps wakes up ADSP and checks the framer status
so that slimbus is clocked by ADSP instead of MDM, and communication
over slimbus is restored.

CRs-Fixed: 539637
Change-Id: I931ec418687b590934bac133979c0c7d608f1266
Signed-off-by: Naveen Kaje <nkaje@codeaurora.org>
slim_ngd: Handle error flags before handling SENT flag

It's possible that error flags were set alongwith SENT flag for
TX transaction status. In such a scenario, error flag status should
be handled (and SENT flag should be cleared). Move error-flag
handling ahead of SENT flag handling to avoid interrupt being called
twice, and completion being set twice.

Change-Id: I13f28df0a0448790069bd103422dc1cd6c7ac408
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
slim_ngd: Support REPEAT_CHANGE_VALUE user message

REPEAT_CHANGE_VALUE user message is used to transfer high amount of
messaging data efficiently.

CRs-Fixed: 503461
Change-Id: I2762ad858b27ac84597f4eaf22fc6f3d14232d76
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
slimbus: Use physical address type where physical address is used

Use physical address type for buffers using physical address.
(e.g. interaction with data-mover engine)

Change-Id: If0c02f13562c762c6effcea82a1e3c351ec2e288
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
Slimbus: Correct the conditional check during channel removal

Use actual channel number to check if the channel to be
removed is present in the define_chan list before removing
it, instead of using the internal channel number used by
the frame work.

CRs-Fixed: 555260
Change-Id: I4c9521f7d228ca43c155fedf2c9ba5b8f86e2d3a
Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
slimbus: Fix logical address notification mechanism

Make sure device-up/down notifications don't involve race condition,
and sub-system restart in such cases is handled gracefully

Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
slim_ngd: Use QMI server up notification instead of APR for probing

Slimbus QMI-server can reside on any other remote processor.
Avoid depedency on APR (for APR state) by utilizing QMI server-up
notification for slimbus hardware initialization from apps processor.

Change-Id: I85e268d08e5c4cfc9c53513199784813200f0223
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
slim-ngd: change log level of slave_notify completion

Change the logging of slave_notify completion to debug to avoid
excessive logging.

Change-Id: Ie8e4ec1c7db786a20212f828d1432ea64e87ccd7
Signed-off-by: Naveen Kaje <nkaje@codeaurora.org>
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
Slim_ngd: Modify waiting mechanism in kthread

wait_for_completion_timeout() is not a good option in
kthread as it leads to scheduling the kthread on the every timeout.
Hence modify it to wait_for_completion() from
wait_for_completion_timeout().

Change-Id: Iaa29e997fd1cd5cb02f9ba44e69e1700b31736ae
Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
Slim_ngd: Don't create the device node per SSR

Observe the device crash due to the device node
gets created per ADSP SSR when the logical address
query succeeds at the first attempt.
This patch makes sure that the device node creation
happened only once  by declaring another variable to
track the logical address retry.

CRs-Fixed: 640381
Change-Id: I3d947fcbc575af7cb431255772aa9cb64d2df6b6
Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
slim_ngd: notify slaves in some MDM restart scenarios

If MDM restarts when it had active framer, bus may lose sync.
Send device-down notification if that happens, and corresponding
reset-device and device-up notifications to slaves so that they
can act to restore their devices' communication over slimbus

CRs-Fixed: 612775
Change-Id: I83f22b9bcf18912c7c9507ea099691ed71d86a9f
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
Signed-off-by: Naveen Kaje <nkaje@codeaurora.org>
msm-slim-ngd: Read configurable external modem identifier

When an external modem is used, read the config from dt and use the
value in subsystem restart callback registration.

CRs-Fixed: 612775
Change-Id: I5e40e98a60c304c82741914157191cfb2f0697d5
Signed-off-by: Naveen Kaje <nkaje@codeaurora.org>
slim_msm: Handle external-modem shutdown differently than restart

External modem may shutdown in cases other than subsystem-restart.
In that case, the power-up notification may not happen.
Handle such a scenario and make sure runtime-pm vote is not held
for more time than required, and that slave-device up/down/reset
notifications happen as expected if slimbus was down.

CRs-Fixed: 645450
Change-Id: I5fef2393c835d06c5ce1dc4f9cb62d418620211b
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
slim_ngd: Handle runtime-pm resume error gracefully

Runtime-pm resume for satellite driver may fail if ADSP is going
through subsystem-restart. Handle that error, and set runtime-pm's
status to suspended if resume fails. Resume typically fails due to
failure to wake slimbus from pause_clock. Make sure another wakeup
can be tried later when ADSP comes back up

Change-Id: Ie9b798f5506de89a37491dbc3798acaa24b98808
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>