sync: Limit logging to particular fence on timeout and error

Change-Id: I5bd7d62260666cdd2a32212f0e828d2d5d7d7bba
Signed-off-by: Prakash Kamliya <pkamliya@codeaurora.org>
base: genlock: Zero a structure before sending it to user space

In the handler for GENLOCK_IOC_EXPORT zero the entire genlock_lock
structure before passing it to the user.

CRs-fixed: 552303
Change-Id: Ic0dedbad257bf0a448d0bf67a14a3932b7925bfc
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
driver core: fix possible missing of device probe

Inside bus_add_driver(), one device might be added(device_add()) into
the bus or probed which is triggered by deferred probe
just after completing of driver_attach() and before
'klist_add_tail(&priv->knode_bus, &bus->p->klist_drivers)',
so the device won't be probed by this driver.

This patch moves the below line

	'klist_add_tail(&priv->knode_bus, &bus->p->klist_drivers)'

before driver_attach() inside bus_add_driver() to fix the
problem.

CRs-Fixed: 588802
Change-Id: I9250b399d57a89870d1df220b97fdca275e2e1a9
Signed-off-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Git-commit: 190888ac01d059e38ffe77a2291d44cafa9016fb
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
Signed-off-by: Swetha Chikkaboraiah <schikk@codeaurora.org>
diag: Bring Diag up to date

Diag on the A-Family mainline is out of date. This change brings
the diag code up to date.

This includes reducing the error message frequency and the latest
msg SSIDs, log codes and event IDs.

Change-Id: Ibfce8ea52e25044df32bdff419d457ad296c6fc1
CRs-Fixed: 455623
Signed-off-by: Ravi Aravamudhan <aravamud@codeaurora.org>
diag: Bring diag up to date

diag on A-Family mainline is out of date. This change
brings the diag code up to date. This change includes
the following changes:

1. diag: dci: Add new Logs and Events API for DCI
2. diag: dci: Clear DCI Cleint Event/Log mask on Exit
3. diag: dci: Process DCI packet during USB disconnect
4. diag: Fix diag hdlc decoding support for messages starting with 0x7e
5. diag: dci: Remove Event Code from DCI Event
6. diag: Fix incorrect response for Log On Demand request
7. diag: Add concurrency protection to writes on smd data channels
8. diag: Add support for sending DIAG_CTRL_MSG_DIAG_MODE
9. diag: Add Support for Callback mode to communicate with remote processors

Change-Id: Ic61bd3408af4533e5d86d73da73100c3f6c5f215
Signed-off-by: Dixon Peterson <dixonp@codeaurora.org>
diag: Check for build time masks being greater than ssid range

Added a check for build time masks to be lesser than the ssid
range. We would ignore and print a warning otherwise.

CRs-Fixed: 477199

Change-Id: Idf75658cc51d66834fa3c0d9f7a8a954be789efa
Signed-off-by: Ravi Aravamudhan <aravamud@codeaurora.org>
diag: Defer usb connect/disconnect processing

USB diag driver will be moving connect/disconnect
event notification from process context to interrupt
context. In order to incorporate that, defer usb
connect/disconnect processing in workqueue context.

CRs-Fixed: 475955
Change-Id: I72f9b5330ac81c78a112212d6bedbe27ddd274cb
Signed-off-by: Mohit Aggarwal <maggarwa@codeaurora.org>
diag: Upgrade Diag code on this branch

Diag on A-Family mainline is out of data. This change
includes the following changes to bring diag code up to date.

1. Updated the msg SSIDs, log codes and event IDs
2. Fix concurrency issues when processing userspace inputs
3. Add notification that diag supports feature mask
4. Update SSIDs and log codes
5. Fix writing of error message for mode command
6. Bring diag control message support up to date
7. Updated the msg SSIDs, log codes and event IDs
8. Fix array out of bounds access

This includes a crash fix due to out of bounds access.

CRs-Fixed: 488175

Change-Id: I0b315b5f5da0fecdbbd0cf071e05f2cf3ffd9ccb

Signed-off-by: Ravi Aravamudhan <aravamud@codeaurora.org>
diag: Fix diag crash due to memory corruption

Diag allocates memory based on the count received from userspace.
Add check to validate the memory pointer before derefencing it.

CRs-Fixed: 487981
Change-Id: Ibfee22d02bb2312192de7c811d9917ecab728269
Signed-off-by: Ashay Jaiswal <ashayj@codeaurora.org>
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
diag: Add debug prints in error cases

In some error cases, returning error code without printing
any message which makes debugging difficult. Add more
extensive debugging prints in error cases.

Change-Id: I1bc147c4420942ecda953ab512f639f6683e511d
CRs-Fixed: 495436
Signed-off-by: Mohit Aggarwal <maggarwa@codeaurora.org>
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
diag: Fix race condition in diagchar driver

diag driver maintains socket logging process in global driver
structure which is manipulated in switch_logging and in close
file_operation.
There is a possibility of race while clearing the socket logging
process in close operation and sending signal in switch_logging
operation. Adding lock to serialize the two operations.

CRs-Fixed: 495063
Change-Id: I0064509c9ace18a8ff40c5a744363546a9021612
Signed-off-by: Ashay Jaiswal <ashayj@codeaurora.org>
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
diag: Rate limit few error messages

Some diag error messages are printed with high frequency. This
is causing flooding of kernel logs. Rate limiting these messages
will help reading kernel logs.

Change-Id: Ica7c50cabff494f28de685f47d2cf234badb2e85
CRs-fixed: 511430
Signed-off-by: Mohit Aggarwal <maggarwa@codeaurora.org>
diag: Command registration not happening properly

Some CM command registrations are not happening properly
on apps side. This could be because some smd events
for control type were getting missed. Make changes
in order to read pending SMD packets for control
type.

Change-Id: I0fe25455275f6169bee91d151d8657330081c104
CRs-Fixed: 516718
Signed-off-by: Mohit Aggarwal <maggarwa@codeaurora.org>
diag: Change maximum size of error response

Diag currently allows error responses of length 490 bytes. This is
outdated as we support 4K responses on the Apps. This patch changes
the Apps buffer size to 4K and also the limit on the error response
length.

Change-Id: I8212bf000a7493b756b5ac0e428c3b2e4be9e9c6

CRs-Fixed: 512035
Signed-off-by: Ravi Aravamudhan <aravamud@codeaurora.org>
diag: NRT read wakelocks held for very long time

During on-device logging with '-b' option,
NRT read wakelocks i.e. diag_nrt_modem_read
and diag_nrt_wcnss_read were held for more than
a day's time. This patch releases the wakelocks
even if SMD channel will be closed.

Change-Id: I7d211aaeaeb8d59369a191c5eef54c02a1b4a61d
CRs-Fixed: 513309
Signed-off-by: Mohit Aggarwal <maggarwa@codeaurora.org>
diag: Reduce error message frequency

Some diag error messages are printed with high frequency. This
cause flooding of kernel logs. Rate limiting these messages will
help reading kernel logs.

Change-Id: I477ff2394116603a27d65948a60d3460c32572d1
CRs-fixed: 594186
Signed-off-by: Katish Paran <kparan@codeaurora.org>
diag: dci: Preventing unitialized stack memcpy operation

At certain point in diag driver there can be memcpy operation
for the unintialized stack. Due to uninitilization of memory
user can obatin valuable information on accessing this stack
in userspace. This patch fixes that issue.

Change-Id: I4bfcf156300132dc426dcadce325e0c76c1d0357
CRs-fixed: 565808
Signed-off-by: Katish Paran <kparan@codeaurora.org>
diag: dci: Index DCI client table by client id

Diag driver maintains a table of all DCI clients. This table
is currently indexed by the PID of the clients. Make changes
to index the table base on an unique client id.

Change-Id: I57bfab9eae1381882b8eb6270d7ac212e0aaf271
CRs-fixed: 590721
Signed-off-by: Katish Paran <kparan@codeaurora.org>
diag: dci: Safeguard to prevent integer overflow

At certain point in diag driver there can be integer overflow
thus can lead to memory leak. Added a safegaurd for it.

Change-Id: I9347405d8f1f95ed42fe0abf35cbf4c362281bdf
CRs-fixed: 565160
Signed-off-by: Katish Paran <kparan@codeaurora.org>
diag: Safeguard for bound checks and integer underflow

At certain point in diag driver there can be integer underflow
and thus can lead to memory leak. Bound checks are placed to
ensure correct behavior of condition statements.

Change-Id: I47e02f764c2c7412db6f90fd42192fee32a761d3
CRs-fixed: 549470
Signed-off-by: Katish Paran <kparan@codeaurora.org>