msm: kgsl: flush device workqueue before stop

Make sure the irq is off, the idle timer is
stopped and the workqueue is flushed before
stopping the device for early suspend, suspend,
last release or hang recovery. There is one case
where the workqueue cannot be flushed, which is from
kgsl_pwrctrl_sleep() when going into SLUMBER
state. This codepath can be called from the
workqueue itself so flushing would deadlock.
msm: kgsl: Make sure SLUMBER is the requested state

The stop_work function releases the device mutex to flush
the workqueue.  The requested state may change while the
mutex is held by a different thread.  So set the requested
state after stop_work.

Change-Id: I3454e773fd670722ea5776d2c8d960190da24006
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
kgsl:fix order
Revert "msm: kgsl: flush device workqueue before stop"

This reverts commit c5ca7b850aaddccb7c99939674830f4f5dff5857.
msm: kgsl: convert sg allocation to vmalloc
msm: kgsl: cancel events from kgsl_release

Events need to be cancelled when an fd is released,
to avoid possible memory leaks or use after free.

When the event is cancelled, its callback is called.
Currently this is sufficient since events are used for
resource management and we have no option but to
release the lock or memory. If future uses need to
distinguish between the callback firing and
a cancel, they can look at the timestamp passed to
the callback, which will be before the timestamp they
expected. Otherwise a separate cancel callback can
be added.

CRs-Fixed: 327647
Change-Id: I49f8f58aea6366344d1c82613f73881a169834b3
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
msm: kgsl: Add a new property to IOCTL_KGSL_DEVICE_GETPROPERTY

Return the reset status of the GPU unit when
IOCTL_KGSL_DEVICE_GETPROPERTY is called with
type KGSL_PROP_GPU_RESET_STAT

Change-Id: I4bb17be959eadba3ba491d94c6fd4f5824442e92
Signed-off-by: Shubhraprakash Das<sadas@codeaurora.org>

Conflicts:
	include/linux/msm_kgsl.h
msm: kgsl: return correct error code for unknown ioctls

Unknown ioctl code errors are supposed to be ENOIOCTLCMD,
not EINVAL.

Change-Id: Id38529e4ec70d63091a9273a780585aea6ae9d9a
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
msm: kgsl: Detach memory objects from a process ahead of destroy time
msm: kgsl: Find a mem_entry by way of a GPU address and a pagetable base
msm: kgsl: Cleanup a superfluous structure in kgsl_device.h

struct kgsl_memregion was used to store the MMIO and GMEM
addressing for KGSL and adreno but it didn't serve much
purpose other than another level of redirection in the
structures.  Remove it and add the necessary pointer and
size members directly to the KGSL and adreno structs.

Change-Id: Ic0dedbad8ec3f0a2c63383fa451cc39a25cab087
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
sweep2wake:first test