usb: gadget: composite: Fix a bug in delayed status handling

The SET_CONFIGURATION control request's status phase is delayed
till the new config change is handled by the file-storage thread.
If the cable is disconnected or the bus is reset before the
previous config is handled, then composite driver is not notified
about the delayed status.  As a result of which, the delayed_status
field of composite device structure remains non-zero.  The status
phase of next SET_CONFIGURATION control request is not sent.
This makes the gadget unusable.

Calling usb_composite_setup_continue() after the disconnect or reset
does not make any sense.  If the host sends another control request
before the status phase of the previous control request is sent, the
delayed_status must be reset to zero.  This is not straight forward
as the UDC handles some control requests without delegating them to
the composite driver.  A simple fix would be resetting the delayed
status value after the disconnect/reset.

CRs-Fixed: 501527
Change-Id: I67c832afc88c9e7d025247e539b7223fd83644d7
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
msm: smd: Remove spurious DATA notification

Add a check to make sure that the SMD_EVENT_DATA
notification is only sent if the FIFO head or
tail has been actually updated.

This extra notification is harmless, but adds
interrupt overhead due to the extra unnecessary
processing.

Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
(cherry picked from commit 65a7d431afd94c59fd3cddc284db7db28f326377)

Change-Id: I884bd8a22e6bf82e5d6ca61b38d1b9de7fec3255
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
msm: smd: Add logging for power analysis

Add special logging flag to allow identification of
the source and reason for SMD and SMSM interrupts
to enable tracking wakeup sources for power
optimization.

Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
(cherry picked from commit 98c6c64ce3dd6eff290981e5bc343b35c778b797)

Change-Id: Ic44dba701cf0072cc681fdd3b94bb134b7aacb0b
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
msm: smsm: Add support for SMSM interrupt mask

When a remote processor changes its SMSM state, it compares the change
against the notification mask and sends a notification to the remote
processor if needed.  Traditionally, Apps has set all interrupt flags to
enabled, so it is woken up and interrupted for all state changes.

With the recent addition of the SMSM callback notifiers, we can start
setting the mask based upon the callbacks.

(cherry picked from commit e8a39324872fbac07fe7f2ef569ac4aee81122a4)

Change-Id: Ie0c2b3df1928d0a5df1754d5b97a5488e7c7c2be
CRs-Fixed: 347968
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
msm: smsm: Cache Flush on SMSM_RESET

Flush inner and outer cache when SMSM_RESET is received by apps proc.
On 7K targets, outer cache is not flushed during panic and ram dumps
do not provide all the updated information.

Change-Id: I97dd1ee10f9ad3656c1dda77f3e7f4542550ab13
Signed-off-by: Adinarayana Gupta Grandhi <agrandhi@codeaurora.org>
(cherry picked from commit 89abbcaed4f4216325f052f005d8d7f11610bbaa)

Signed-off-by: Gopal G Goberu <ggober@codeaurora.org>
msm: smd_pkt: fix wake lock locking race condition

When smd_pkt receives data for a client in userspace, smd_pkt locks a wake
lock to give the userspace client time to lock their own wake lock if
necessary.  Clients using poll() will trigger the unlocking of the wake
lock in smd_pkt, otherwise smd_pkt modifies the wake lock to expire in two
seconds.

Fix a race condition where smd_pkt locks the wake lock, the client reads
their data and triggers the unlocking, and then smd_pkt relocks the wake
lock when it modifies the timeout to two seconds.  This causes suspend to
be unnecessarily delayed.  The fix is to bypass setting the timeout if the
client has already read their data and triggered the unlocking of the wake
lock.

CRs-Fixed: 367001
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
(cherry picked from commit 93476a35471a8ffa926ab4474bf028795db95cca)

Conflicts:

	arch/arm/mach-msm/smd_pkt.c

Change-Id: I561abdf34aacaaecd617b80c1ea476d4b9c373f1
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
msm: smd_pkt: Fix wakelock concurrency issue

In failure conditions, some clients violate the SMD PKT restriction of
single-threaded access resulting in overlapping open requests which
corrupt the wakelock list.

Move the wakelock initialization into the channel mutex to prevent
concurrent access from corrupting the wakelock.

CRs-Fixed: 374644
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>

(cherry picked from commit b399a4fbce9c9b20ef258e3245e916cd9ce788e2)

Conflicts:

	arch/arm/mach-msm/smd_pkt.c

Change-Id: I43df498cbf3480b8e345900be49c16afc4669f4a
Signed-off-by: Subrahmanyam Uppala <csuppal@codeaurora.org>
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
msm: gic: Remove manual GIC programming for PPI trigger type

There is no need to manually program GIC for edge trigger PPIs
through board or device file hooks after the introduction of
enable_percpu_irq(.., type) interface. 2nd parameter of this
API needs to be used for programming the right trigger
type for the PPI.

Change-Id: Ie200928eb70fcbab6646ddd63acfd89a1a87f5fe
Signed-off-by: Trilok Soni <tsoni@codeaurora.org>
Signed-off-by: Taniya Das <tdas@codeaurora.org>
msm: ipc: Update the wakelock name to include client info

QMI clients in user-space do not read the messages queued to them.
This leads to IPC router holding the wakelock forever. To enable
debugging which client's wakelock is active, include the client's id
in the wakelock name.

CRs-Fixed: 367561
Signed-off-by: Karthikeyan Ramasubramanian <kramasub@codeaurora.org>
(cherry picked from commit b4aeeb9882c40a73da870b8b60f698e853b7be0d)

Change-Id: I67539f4dddc0531752a9c7b04405cd80eaaccb10
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
msm: ipc: Fix race condition between route & close_port operations

QMI Client is closing the interface port with IPC Router, while the
IPC Router is handling an incoming QMI message from modem for that
client. There is a race condition between these two operations. This in
turn leads to IPC Router trying to lock the wakelock which has been
destroyed as part of close operation. IPC Router gains exclusive
access to the interface port information, so that close operation
does not happen in parallel to the route operation.

CRs-Fixed: 367561
Signed-off-by: Karthikeyan Ramasubramanian <kramasub@codeaurora.org>
(cherry picked from commit be9954bc046aa9238f17fd2d420973a273906b81)

Change-Id: Ieff91b8959003a4d19e7c8d6a6aa2f1b39698990
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
msm: ipc: Update the work item in the read path

IPC Message Router schedules a work item to read incoming messages
from the remote subsystems. Once a message is read, the work item
queues itself again in the workqueue. The queued work item performs
an uninterruptible wait for further messages. This causes the "loadavg"
to be consistently greater than 1. So refactor the read path such that
the read work item is queued only after the message has arrived.

CRs-Fixed: 383657
Signed-off-by: Karthikeyan Ramasubramanian <kramasub@codeaurora.org>
(cherry picked from commit 872ecd84746547eb5d82c04080439b46fc2426d7)

Change-Id: If91e8738bad8b33f91af55ec69795693e20b3d3e
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
mtd: msm_nand: Fix wrong uncorrectable error bit check

For the Nand controller on 7x30 and 7x27a, the
uncorrectable error bit in the NANDC_BUFFER_STATUS
register is changed to BIT(8) from BIT(3) (in legacy
targets) due to change in the ECC requirements. Currently,
this is handled only in dual nandc mode (default for 7x30
and 7x27a). In case, if only single nandc is used, the
uncorrectable bit check is broken and the driver wouldn't
detect any ECC errors.

Add software version info in platform data to differentiate
between the targets that have different register interface.

CRs-fixed: 365433
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
(cherry picked from commit ec9b3250fe233e4ff96b4ad23372df5f8299fc67)

Change-Id: Ibfdc4e5cc5c91426b0eca45a400b8549d42eabcc
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
ipv6: introdcue __ipv6_addr_needs_scope_id and ipv6_iface_scope_id helper functions

[net-next commit b7ef213ef65256168df83ddfbb8131ed9adc10f9]

__ipv6_addr_needs_scope_id checks if an ipv6 address needs to supply
a 'sin6_scope_id != 0'. 'sin6_scope_id != 0' was enforced in case
of link-local addresses. To support interface-local multicast these
checks had to be enhanced and are now consolidated into these new helper
functions.

v2:
a) migrated to struct ipv6_addr_props

v3:
a) reverted changes for ipv6_addr_props
b) test for address type instead of comparing scope

v4:
a) unchanged

Change-Id: Id6fc54cec61f967928e08a9eba4f857157d973a3
Suggested-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Cc: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Acked-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Acked-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net: ipv6: Add IPv6 support to the ping socket.

[backport of net-next 6d0bfe22611602f36617bc7aa2ffa1bbb2f54c67]

This adds the ability to send ICMPv6 echo requests without a
raw socket. The equivalent ability for ICMPv4 was added in
2011.

Instead of having separate code paths for IPv4 and IPv6, make
most of the code in net/ipv4/ping.c dual-stack and only add a
few IPv6-specific bits (like the protocol definition) to a new
net/ipv6/ping.c. Hopefully this will reduce divergence and/or
duplication of bugs in the future.

Caveats:

- Setting options via ancillary data (e.g., using IPV6_PKTINFO
  to specify the outgoing interface) is not yet supported.
- There are no separate security settings for IPv4 and IPv6;
  everything is controlled by /proc/net/ipv4/ping_group_range.
- The proc interface does not yet display IPv6 ping sockets
  properly.

Tested with a patched copy of ping6 and using raw socket calls.
Compiles and works with all of CONFIG_IPV6={n,m,y}.

Change-Id: Ia359af556021344fc7f890c21383aadf950b6498
Signed-off-by: Lorenzo Colitti <lorenzo@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
[lorenzo@google.com: backported to 3.0]
Signed-off-by: Lorenzo Colitti <lorenzo@google.com>
ping: always initialize ->sin6_scope_id and ->sin6_flowinfo

[net-next commit c26d6b46da3ee86fa8a864347331e5513ca84c2b]

If we don't need scope id, we should initialize it to zero.
Same for ->sin6_flowinfo.

Change-Id: I28e4bc9593e76fc3434052182466fab4bb8ccf3a
Cc: Lorenzo Colitti <lorenzo@google.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Cong Wang <amwang@redhat.com>
Acked-by: Lorenzo Colitti <lorenzo@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Squashed update of kernel from 3.0.83 to 3.0.84