msm: acpuclock: Fix acpuclk_data null pointer dereference

If acpuclk_data is null, dereferencing it in acpuclk_get_switch_time
causes a kernel panic.  Add pointer check to fix that.

Change-Id: I69b92671c8cf26cb45ec8f1193c147be2ebe4c16
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
msm: krait-regulator: Update SLEW_RATE constant

The Krait regulators are clocked from an RC oscillator circuit
that could vary in frequency by as much as 25% in extreme
conditions, causing the voltage ramp to be either faster or slower
than the nominal rate. To ensure we wait long enough for the rail
to settle in all conditions, lower SLEW_RATE by 25%.

from caf
commit  92abbdd637cee6f8b2f3ef438f5d727290680f2d

Change-Id: I11cc4e7d57eced2f8f984153d48b4298ee71ec9e
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
Signed-off-by: Devin Kim <dojip.kim@lge.com>
msm: krait-regulator: correct krait rail settling delay calculation

set_pmic_gang_voltage() updates pmic_vmax_uV to be equal to vmax
prior returning.  Because of this, the settling delay calculation
will always yield 0us. Fix this.

from caf
commit  46d0b10ef7b72fc5756eb290139a6e6595ab2081

Change-Id: I670a0bdecfe72e9ddf663e9a35ef8a6354946224
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
Signed-off-by: Devin Kim <dojip.kim@lge.com>
Revert "msm: msm_fb: Do not use ION_IOMMU_UNMAP_DELAYED flag."

This reverts commit c0f1aa3616669bb8803a5e561786725f07ebb5f4.
msm: kgsl: Detect gpu mem entry collisions when using MAP_FIXED flag

When using MAP_FIXED flags, detect collisions with previous gpu memory
entries. Fail mmap() if previous gpu entries exist.

Change-Id: I09f456677e7fc81b8bdf1b2f5724569220c7e897
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
iommu/core: pass a user-provided token to fault handlers

Sometimes a single IOMMU user may have to deal with several
different IOMMU devices (e.g. remoteproc).

When an IOMMU fault happens, such users have to regain their
context in order to deal with the fault.

Users can't use the private fields of neither the iommu_domain nor
the IOMMU device, because those are already used by the IOMMU core
and low level driver (respectively).

This patch just simply allows users to pass a private token (most
notably their own context pointer) to iommu_set_fault_handler(),
and then makes sure it is provided back to the users whenever
an IOMMU fault happens.

The patch also adopts remoteproc to the new fault handling
interface, but the real functionality using this (recovery of
remote processors) will only be added later in a subsequent patch
set.

Change-Id: Ic04659686e72838a0db518e9303dd037191e3879
Cc: Fernando Guzman Lugo <fernando.lugo@ti.com>
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
[ohaugan@codeaurora.org: Resolved compilation and merge issues]
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>

Conflicts:
	drivers/video/msm/mdss/mdss_mdp.c
iommu: Make termination of stalled transaction optional

When pagefault happens do not cancel the faulting transaction if
the registered fault handler returns EBUSY error. This way
drivers can control when they want to resume the transaction.

Change-Id: Ia4563da073ab04174803101c3b8ec82b0571850e
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: Sakshi Agrawal <sakshia@codeaurora.org>
iommu/msm: check range before mapping.

Make sure iommu_map_range() does not leave a partial
mapping on error if part of the range is already
mapped.

Change-Id: I0ddeb0e0169b579f1efdeca4071fce4ee75a11f8
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
Signed-off-by: Sakshi Agrawal <sakshia@codeaurora.org>
msm: iommu: Convert to clk_prepare/unprepare

Add calls to clk_prepare and unprepare so that MSM can migrate to
the common clock framework. We never unprepare the clocks until
driver remove because the clocks are enabled and disabled in irq
context. Finer grained power management is possible in the future
via runtime power management techniques.

Cc: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Acked-by: Joerg Roedel <joro@8bytes.org>
Signed-off-by: David Brown <davidb@codeaurora.org>
iommu: Split iommu_unmaps

iommu_map splits requests into pages that the iommu driver reports
that it can handle.  The iommu_unmap path does not do the same.  This
can cause problems not only from callers that might expect the same
behavior as the map path, but even from the failure path of iommu_map,
should it fail at a point where it has mapped and needs to unwind a
set of pages that the iommu driver cannot handle directly.  amd_iommu,
for example, will BUG_ON if asked to unmap a non power of 2 size.

Fix this by extracting and generalizing the sizing code from the
iommu_map path and use it for both map and unmap.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Joerg Roedel <joro@8bytes.org>
iommu: Fix compiler warning on pr_debug

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Joerg Roedel <joro@8bytes.org>
iommu: Check for valid pgsize_bitmap in iommu_map/unmap

In case the page-size bitmap is zero the code path in
iommu_map and iommu_unmap is undefined. Make it defined and
return -ENODEV in this case.

Signed-off-by: Joerg Roedel <joro@8bytes.org>
iommu: Use %pa and %zx instead of casting

printk supports using %pa for phys_addr_t and
%zx for size_t so use those instead of %lx and
casts to unsigned long.

Other miscellaneous changes around this:

Always use 0x%zx for size instead of one use of decimal.
Coalesce format and align arguments.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Joerg Roedel <joro@8bytes.org>
slub: tid must be retrieved from the percpu area of the current processor

As Steven Rostedt has pointer out: rescheduling could occur on a
different processor after the determination of the per cpu pointer and
before the tid is retrieved. This could result in allocation from the
wrong node in slab_alloc().

The effect is much more severe in slab_free() where we could free to the
freelist of the wrong page.

The window for something like that occurring is pretty small but it is
possible.

Signed-off-by: Christoph Lameter <cl@linux.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
msm: rotator: signal timeline when rotator prepare fails.

When rotator prepare fails, timeline is not signalled causing fence
timeout on the rotator release fence. This patch fixes the issue.

Change-Id: I6023393d768dbb1a0a9095bb1822ac504632ed64
Signed-off-by: Vishnuvardhan Prodduturi <vproddut@codeaurora.org>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
video: msm: Use the new fence release logic for video panel too

Change-Id: I51807e458f9db94c3ac05f8f8b108494a7fdd720
msm: kgsl: Don't halt the GPU, try to recover first

We don't want to halt the GPU when trying to recover in
production devices. Remove the bit mask that would do that.

Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
net: defer net_secret[] initialization

Instead of feeding net_secret[] at boot time, defer the init
at the point first socket is created.

This permits some platforms to use better entropy sources than
the ones available at boot time.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
msm: subsystem_restart: restart the subsystem independently

Restart the subsystem independently instead of SOC reset.

Change-Id: I856f4a52ae4da837117cc8f0fe7c3515f5323558
msm: kgsl: Align ION buffer mappings from userspace to 4k

When userspace allocates an ION buffer and maps it to GPU virtual space,
adjust the buffer size to be 4k aligned before mapping it to GPU virtual
space. GPU virtual space map routine expects the buffer to be 4k aligned.

Change-Id: Ibdb95597c24e2b5d0c3390d2c8550abb6b4b730b
Acked-by: Rama Vaddula <rvaddula@qualcomm.com>
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>