diag: Remove error message

Some diag messages are marked as error messages which should
be marked as debug. This patch fixes that issue.

Change-Id: If24b6cfdfca40321ff403826d8c149e8a3032803
Signed-off-by: Katish Paran <kparan@codeaurora.org>
genalloc: Correct nbytes calculation on long boundary

In existing code we calculate nbytes based on the byte
boundary, but genalloc uses bitmap for maintaining the
memory allocation aligned to long. So while calculating
nbytes we end up getting wrong nbytes.
example: lets say nbytes comes to 9 bytes for 70 bits when
bytes aligned,but if long aligned we will have 3 long words
i.e 12 bytes. This difference may lead to choosing the
wrong api for freeing the memory i.e Between kfree() and
vfree().
Fix was inspired by an upstream commit
eedce141cd2dad8d0cefc5468ef41898949a7031, bringing same fix
into the gen_pool_detroy path.

Change-Id: I942caf59e25515c780896b328b912604df9e10bf
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
Signed-off-by: Sunil Khatri <sunilkh@codeaurora.org>
msm: kgsl: Increase IDLE_TIMEOUT for 2D core to 20secs

Increasing the hang detection time for 2D core from
10 secs to 20 secs to avoid False GPU Hangs.
Some c2d test cases are taking more than 10 secs
to process which results in a False GPU Hang.

CRs-Fixed: 454439, 644283
Change-Id: Ice5e4b719adb44cd13fb8164bafedce1049416f7
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
genalloc: stop crashing the system when destroying a pool

The genalloc code uses the bitmap API from include/linux/bitmap.h and
lib/bitmap.c, which is based on long values.  Both bitmap_set from
lib/bitmap.c and bitmap_set_ll, which is the lockless version from
genalloc.c, use BITMAP_LAST_WORD_MASK to set the first bits in a long in
the bitmap.

That one uses (1 << bits) - 1, 0b111, if you are setting the first three
bits.  This means that the API counts from the least significant bits
(LSB from now on) to the MSB.  The LSB in the first long is bit 0, then.
The same works for the lookup functions.

The genalloc code uses longs for the bitmap, as it should.  In
include/linux/genalloc.h, struct gen_pool_chunk has unsigned long
bits[0] as its last member.  When allocating the struct, genalloc should
reserve enough space for the bitmap.  This should be a proper number of
longs that can fit the amount of bits in the bitmap.

However, genalloc allocates an integer number of bytes that fit the
amount of bits, but may not be an integer amount of longs.  9 bytes, for
example, could be allocated for 70 bits.

This is a problem in itself if the Least Significat Bit in a long is in
the byte with the largest address, which happens in Big Endian machines.
This means genalloc is not allocating the byte in which it will try to
set or check for a bit.

This may end up in memory corruption, where genalloc will try to set the
bits it has not allocated.  In fact, genalloc may not set these bits
because it may find them already set, because they were not zeroed since
they were not allocated.  And that's what causes a BUG when
gen_pool_destroy is called and check for any set bits.

What really happens is that genalloc uses kmalloc_node with __GFP_ZERO
on gen_pool_add_virt.  With SLAB and SLUB, this means the whole slab
will be cleared, not only the requested bytes.  Since struct
gen_pool_chunk has a size that is a multiple of 8, and slab sizes are
multiples of 8, we get lucky and allocate and clear the right amount of
bytes.

Hower, this is not the case with SLOB or with older code that did memset
after allocating instead of using __GFP_ZERO.

So, a simple module as this (running 3.6.0), will cause a crash when
rmmod'ed.

  [root@phantom-lp2 foo]# cat foo.c
  #include <linux/kernel.h>
  #include <linux/module.h>
  #include <linux/init.h>
  #include <linux/genalloc.h>

  MODULE_LICENSE("GPL");
  MODULE_VERSION("0.1");

  static struct gen_pool *foo_pool;

  static __init int foo_init(void)
  {
          int ret;
          foo_pool = gen_pool_create(10, -1);
          if (!foo_pool)
                  return -ENOMEM;
          ret = gen_pool_add(foo_pool, 0xa0000000, 32 << 10, -1);
          if (ret) {
                  gen_pool_destroy(foo_pool);
                  return ret;
          }
          return 0;
  }

  static __exit void foo_exit(void)
  {
          gen_pool_destroy(foo_pool);
  }

  module_init(foo_init);
  module_exit(foo_exit);
  [root@phantom-lp2 foo]# zcat /proc/config.gz | grep SLOB
  CONFIG_SLOB=y
  [root@phantom-lp2 foo]# insmod ./foo.ko
  [root@phantom-lp2 foo]# rmmod foo
  ------------[ cut here ]------------
  kernel BUG at lib/genalloc.c:243!
  cpu 0x4: Vector: 700 (Program Check) at [c0000000bb0e7960]
      pc: c0000000003cb50c: .gen_pool_destroy+0xac/0x110
      lr: c0000000003cb4fc: .gen_pool_destroy+0x9c/0x110
      sp: c0000000bb0e7be0
     msr: 8000000000029032
    current = 0xc0000000bb0e0000
    paca    = 0xc000000006d30e00   softe: 0        irq_happened: 0x01
      pid   = 13044, comm = rmmod
  kernel BUG at lib/genalloc.c:243!
  [c0000000bb0e7ca0] d000000004b00020 .foo_exit+0x20/0x38 [foo]
  [c0000000bb0e7d20] c0000000000dff98 .SyS_delete_module+0x1a8/0x290
  [c0000000bb0e7e30] c0000000000097d4 syscall_exit+0x0/0x94
  --- Exception: c00 (System Call) at 000000800753d1a0
  SP (fffd0b0e640) is in userspace

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@linux.vnet.ibm.com>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Benjamin Gaignard <benjamin.gaignard@stericsson.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Git-commit: eedce141cd2dad8d0cefc5468ef41898949a7031
Git-repo: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git
Change-Id: Ic8a8a2d05ee16d59af61d0cc79c88e6e7ab442ae
Signed-off-by: Sunil Khatri <sunilkh@codeaurora.org>
msm: qdsp6v2: Increase max ports in APR

Increase the maximum ports in APR. Some Apps may support
multiple clients which exceeds the number of clients
supported in APR. This change increases number of ports
used in APR upto 8 sessions.

CRs-Fixed: 634388
Change-Id: I06624330845681b4414dd470ab7aed669d690ba0
Signed-off-by: Aravind Kumar <akumark@codeaurora.org>
msm: kgsl: Fix GPU hang recovery logic

During new commands submission, if the write pointer
is ahead of read pointer fill ringbuffer data with
KGSL_NOP_DATA_FILLER after NOP command. This will
avoids getting incorrect context ID from the ringbuffer
extraction logic during GPU recovery.

CRs-Fixed: 620533
Change-Id: If4d25770b7288bc6fb618611c150e3876cc87c6f
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
msm: kgsl: Reset VSC control registers

Configure the A2xx VSC register in context switch,
which helps GPU to recover from the bad state.

CRs-Fixed: 637288
Change-Id: I2000a579614c491a015c618a52808500541329c5
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
msm: kgsl: Fix for panic in z180 postmortem dumps

We were accessing z180 registers without holding
device mutex. This change ensures that we hold the
mutex before accessing z180's registers

CRs-Fixed: 644283
Change-Id: Ib6496c427fc6c9a3f97a6720adb80a390fe21b0d
Signed-off-by: Gaurav Gagrani <ggagrani@codeaurora.org>
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
wlan: Don't Invoke hdd_connRemoveConnectInfo incase of successful Assoc.

As a part of hdd_smeRoamCallback for eCSR_ROAM_ASSOCIATION_COMPLETION
roamstatus, saved connection info is getting cleared because of
hdd_connRemoveConnectInfo being invoked even for successful assoc

hdd_connRemoveConnectInfo should not be invoked incase
successfull Associations.

Change-Id: Ibb1acac0bb23b86b7be20a1e83d77fa1afa10a8f
CRs-Fixed: 606949
prima : Handling race condition in driver unload in FTM

wlan_hdd_process_ftm_cmd() function is called in one context
and try to post message to HAL, in the mean time the
wlan_hdd_ftm_close() is called in other context and unload
the driver which causes the crash some times.

Change-Id: I7b7cd4a3449ceb0e8973a37744f86ce67678b1a1
CRs-fixed: 631639
wlan: TL: Flush cache frames when clean STA.

We need to flush cache frames when cleaning STA even though STA
isn't still register with TL, to avoid race condition where
continious lim state machine changes cause number of cache
packets to grow large in number which cause low rx resource.
CRs-fixed: 638523

Change-Id: Ie44e98d0891f3a669ecf3e22b3416b434774807b
wlan: HDD: add logpinprogress check for ioctl calls

Add logpinprogress check to prevent powerstate
change during loading through wlan_hdd_enter_bmps.
This helps to prevent access to any uninitialized null pointer
during loading stage of driver.

CRs-fixed: 637285
Change-Id: I196c42bd1f7b3791a1825ac9250aff60556569d0
wlan: wdi: Replace VosAssert with VosTrace for bus packets failure

There is need to decrease excessive logging in case of messages
being dropped by SMD Bus during SSR. This generally happens when
bus state is WCTS_STATE_REM_CLOSED. For this reason removing
VosAssert and adding additional info in VosTrace.
CRs-Fixed: 636462
Change-Id: Ic03e51a7c45e102782613bb0fc368655d904adf0
TDLS: replace mutex_lock_interruptible with mutex_lock for tdls lock

Use  mutex_lock instead of mutex_lock_interruptible to avoid race
condition which can occur due to interrupts.

CRs-fixed: 637112
Change-Id: I367afd789e568f87080caeebf2e3ec09df51bc13
TDLS: Set tdls hdd context to NULL after freeing

While exiting the tdls hdd context after freeing the peer list
we should also set TDLS context in STA session context of adapter
to NULL.

CRs-Fixed: 637112
Change-Id: I5d8f99b74d1421434e28dc3d0a43dde306292fe3
wlan: Delay SSR during active entry points

Changes for delaying SSR if any identified entry points are active.
This is required to avoid any access to uninitialized or
deallocated data structure.

Change-Id: I2a78ef9df62713b5803d88e99ff4371dcd60f5a9
CRs-Fixed: 642329
wlan: Fix for Static analysis issues in vos_nvitem.c

The 'request->alpha2' of size 2 is passed to sme_ChangeCountryCode
but in sme_ChangeCountryCode it is considered as size of 3.

Pass ccode of length 3 to sme_ChangeCountryCode insted of
request->alpha2.

Change-Id: I579c29e038565e21555bc555e3e3fa6473398293
CRs-Fixed: 633938
wlan: Protect wlan_hdd_cfg80211_change_iface function from SSR

Protect wlan_hdd_cfg80211_change_iface function from accessing
uninitialized or deallocated data structures while SSR is in
progress.

Change-Id: I3472eccc41d2a6f2f4526d99dacbb8bbde61aaab
CRs-Fixed: 633889
wlan: do not enter IMPS if DXE rings have pending TX data

It has been observed that if WCNSS goes to IMPS if data
is pending DXE will try to push that data once the WCNSS
comes out of IMPS. The Data pushed by DXE is leading to
a WCNSS crash in certain cases, so add a check in the host
to defer IMPS if DXE rings are not empty.

Change-Id: Ie4c729285495a96914e792833e26d6ec78a03302
CRs-Fixed: 634187
Merge "wlan: Delay SSR during active entry points"