tspp: Add synchronization between API call and tasklet

The TSPP driver uses a tasklet which is scheduled on BAM transfer
completion to process the data. The tasklet verifies that the
channel had not already been closed. Therefore, it is necessary
to have a synchronization mechanism between the channel_close API
function and the tasklet function. Added acquisition of spinlock
in the channel_close function.

Change-Id: I274298cbc9c83b4b6c1d50ffb709b8c5d8d43231
CRs-Fixed: 477556
Signed-off-by: Liron Kuch <lkuch@codeaurora.org>
vm: convert fb_mmap to vm_iomap_memory() helper

This is my example conversion of a few existing mmap users.  The
fb_mmap() case is a good example because it is a bit more complicated
than some: fb_mmap() mmaps one of two different memory areas depending
on the page offset of the mmap (but happily there is never any mixing of
the two, so the helper function still works).

Change-Id: I291e4392725fda8d54ac045663ade7ffb7598d15
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
msm_fb: display: Add delay kickoff to MDDI

Add delay kickoff mechanism to consolidate multiple kickoffs
into one to avoid unnecessary delay at MDDI interface.
Also the MDP4_NONBLOCKING was removed due to every MDDI kickoff
is blocked until overlay blending completion interrupt is delivered.
This patch also remove unnecessary semaphore at the topmost layer
(fbmem) ioctl to allow multiple msm_fb ioctl calls. Mutex is
provided by individual function to synch between multiple
ioctl calls.

CRs-fixed: 264934
Change-Id: I3aecdd9cb4d7c79f67b641f90e78a6764095a6b2
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
Signed-off-by: David Brown <davidb@codeaurora.org>
vm: add vm_iomap_memory() helper function

commit b4cbb197c7e7a68dbad0d491242e3ca67420c13e upstream.

Various drivers end up replicating the code to mmap() their memory
buffers into user space, and our core memory remapping function may be
very flexible but it is unnecessarily complicated for the common cases
to use.

Our internal VM uses pfn's ("page frame numbers") which simplifies
things for the VM, and allows us to pass physical addresses around in a
denser and more efficient format than passing a "phys_addr_t" around,
and having to shift it up and down by the page size.  But it just means
that drivers end up doing that shifting instead at the interface level.

It also means that drivers end up mucking around with internal VM things
like the vma details (vm_pgoff, vm_start/end) way more than they really
need to.

So this just exports a function to map a certain physical memory range
into user space (using a phys_addr_t based interface that is much more
natural for a driver) and hides all the complexity from the driver.
Some drivers will still end up tweaking the vm_page_prot details for
things like prefetching or cacheability etc, but that's actually
relevant to the driver, rather than caring about what the page offset of
the mapping is into the particular IO memory region.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
power: pm8921-bms: fix SOC jumps while entering suspend/resume

The last_soc is being set to -EINVAL when entering suspend. This
causes SOC to jump while coming out of resume.

Instead remember
If we are reporting for the first time after suspend.
The calculated_soc at the time we went to suspend.

Soc should not increase because we cannot suspend while
charging. If the calculated_soc has increased continue reporting
the lower last_soc.

If the calculated soc has dropped check if it has dropped since
suspend. If so decrease the reported soc by the amount it dropped
since suspend.

If the calculated soc has dropped but it has increased since suspend
continue to report the last_soc.

Change-Id: I9040feceaa3e829d11bec0b21e61951f2ed1180b
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
power: pm8921-bms: Cancel/schedule work across suspend/resume

Clean up the work before going into suspend to avoid any
race during resume.

While at it, fix the timing comparison during resume
and use the de-referenced chip pointer.

Change-Id: I9e6dbe49e6ad5ebf1cdf9a3cd0ec7f57aa6495c6
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
power: pm8921-bms: Fine tune SOC reporting during suspend/resume

Report SOC based on the time for which the system was suspended.

Remember -
1. If we recalculated the SOC in resume
2. The last_soc before going into suspend

Two cases arise - if we had a short suspend or if the suspend
was significant to case a drop in SOC. For the former do not
report a change in SOC and for the latter, report the
newly calculated_soc. In either of the cases, soc should not
increase because we cannot suspend while charging.

There is a possibility that the report_soc may be called
before BMS resume (update_power_supply), causing the driver
to report the old SOC. Handle this case by setting state
variables before recalculating the soc in resume.

CRs-Fixed: 482611
Change-Id: Ic21a24a1126800011f5e7e4531c1953436812811
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
Merge of Sony Release 10.3.1.A.0.244

Change-Id: I7866c9c5c2fa8674ae3d5d559e871091f9a9e5b5