base: genlock: add magic to protect attach from non-genlock file

It is possible for user space to attempt to attach a valid fd that
does not correspond to a genlock file. This change adds a magic to
the kernel private data that is used for validation.

CRs-fixed: 359649
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
(cherry picked from commit 507a9d3354b24e7cc7f22e9695339de6df317fc1)

Change-Id: Ice93bfc904f61431688f03027a4090ceb7b9289a
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
(cherry picked from commit 6856721e05a2e97130a654884a16cf8d79753d58)

Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: ipc: Add support to load and unload the modem

When all the user-space clients are killed, modem gets unloaded and goes
to silent reset. When the user-space clients come up again, modem resets
its side of the RPCRPY_CNTL SMD channel. This leaves the SMD channel in
stale state. Hence modem starts reading stale data from the SMD channel
and crashes. So as long as the IPC Router uses the SMD channel, cast a
vote to PIL to ensure that the modem is loaded.

Change-Id: I27a49b8ba3f953df316c6a2f171e0d0f0c7a9355
CRs-Fixed: 359773
Signed-off-by: Karthikeyan Ramasubramanian <kramasub@codeaurora.org>
(cherry picked from commit 9a5aca7ecfbe51b1f3d9d462429546d10374f2b3)
sysfs: handle 'parent deleted before child added'

In scsi at least two cases of the parent device being deleted before the
child is added have been observed.

1/ scsi is performing async scans and the device is removed prior to the
   async can thread running (can happen with an in-opportune / unlikely
   unplug during initial scan).

2/ libsas discovery event running after the parent port has been torn
   down (this is a bug in libsas).

Result in crash signatures like:
 BUG: unable to handle kernel NULL pointer dereference at 0000000000000098
 IP: [<ffffffff8115e100>] sysfs_create_dir+0x32/0xb6
 ...
 Process scsi_scan_8 (pid: 5417, threadinfo ffff88080bd16000, task ffff880801b8a0b0)
 Stack:
  00000000fffffffe ffff880813470628 ffff88080bd17cd0 ffff88080614b7e8
  ffff88080b45c108 00000000fffffffe ffff88080bd17d20 ffffffff8125e4a8
  ffff88080bd17cf0 ffffffff81075149 ffff88080bd17d30 ffff88080614b7e8
 Call Trace:
  [<ffffffff8125e4a8>] kobject_add_internal+0x120/0x1e3
  [<ffffffff81075149>] ? trace_hardirqs_on+0xd/0xf
  [<ffffffff8125e641>] kobject_add_varg+0x41/0x50
  [<ffffffff8125e70b>] kobject_add+0x64/0x66
  [<ffffffff8131122b>] device_add+0x12d/0x63a

In this scenario the parent is still valid (because we have a
reference), but it has been device_del()'d which means its kobj->sd
pointer is NULL'd via:

 device_del()->kobject_del()->sysfs_remove_dir()

...and then sysfs_create_dir() (without this fix) goes ahead and
de-references parent_sd via sysfs_ns_type():

 return (sd->s_flags & SYSFS_NS_TYPE_MASK) >> SYSFS_NS_TYPE_SHIFT;

This scenario is being fixed in scsi/libsas, but if other subsystems
present the same ordering the system need not immediately crash.

Change-Id: I435d14af35fa7cb4d4017890af9411299a9a8455
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: James Bottomley <JBottomley@parallels.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
msm: kgsl: Check whether the ops pointer is valid.

Check that the ops pointer is valid before using it, otherwise we
may fault.

CRs-fixed: 360810
Change-Id: Ic154d281020605dc4a5823291c3dc8ccbe4420ae
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>

Conflicts:

	drivers/gpu/msm/kgsl.h