[Xperia Z Original Android Development] Supersaiyan.IV:
Got nothing to do this evening, so here's some snapshot feedback. Procedure:

Wipe phone clean

cm-12.1-20151007-SNAPSHOT-YOG4PAO339-yuga

tk_gapps-modular-mini-5.1.1-20151004-signed

There are a few errors at boot. Most importantly the Dialer seems to miss a library.

E/PackageManager( 693): updateAllSharedLibrariesLPw failed: Package com.android.dialer requires unavailable shared library com.qualcomm.qti.smartsearch; failing!

There's the subsys warning, which has a patch here.

<4>[ 0.359649] ------------[ cut here ]------------
<4>[ 0.359863] WARNING: at ../../../../../../kernel/sony/apq8064/arch/arm/mach-msm/subsystem_restart.c:664 subsys_restart_init+0xec/0x120()
<4>[ 0.360046] Modules linked in:
<4>[ 0.360351] [<c010c1c4>] (unwind_backtrace+0x0/0x11c) from [<c017d35c>] (warn_slowpath_common+0x4c/0x64)
<4>[ 0.360565] [<c017d35c>] (warn_slowpath_common+0x4c/0x64) from [<c017d404>] (warn_slowpath_null+0x18/0x20)
<4>[ 0.360748] [<c017d404>] (warn_slowpath_null+0x18/0x20) from [<c0d0bda8>] (subsys_restart_init+0xec/0x120)
<4>[ 0.360870] [<c0d0bda8>] (subsys_restart_init+0xec/0x120) from [<c0100610>] (do_one_initcall+0x8c/0x150)
<4>[ 0.361083] [<c0100610>] (do_one_initcall+0x8c/0x150) from [<c0d00be8>] (kernel_init+0xf8/0x1ac)
<4>[ 0.361297] [<c0d00be8>] (kernel_init+0xf8/0x1ac) from [<c01069d0>] (kernel_thread_exit+0x0/0x8)
<4>[ 0.361511] ---[ end trace 3857d16795e1ffc2 ]---

And the known vsprintf warning.

<4>[ 12.873840] ------------[ cut here ]------------
<4>[ 12.877716] WARNING: at ../../../../../../kernel/sony/apq8064/lib/vsprintf.c:1290 vsnprintf+0x270/0x380()
<4>[ 12.887359] Please remove ignored %n in '%n'
<4>[ 12.891296] Modules linked in:
<4>[ 12.894348] [<c010c1c4>] (unwind_backtrace+0x0/0x11c) from [<c017d35c>] (warn_slowpath_common+0x4c/0x64)
<4>[ 12.903900] [<c017d35c>] (warn_slowpath_common+0x4c/0x64) from [<c017d3a0>] (warn_slowpath_fmt+0x2c/0x3c)
<4>[ 12.913391] [<c017d3a0>] (warn_slowpath_fmt+0x2c/0x3c) from [<c03b4504>] (vsnprintf+0x270/0x380)
<4>[ 12.922210] [<c03b4504>] (vsnprintf+0x270/0x380) from [<c025b334>] (seq_printf+0x38/0x70)
<4>[ 12.930328] [<c025b334>] (seq_printf+0x38/0x70) from [<c028232c>] (show_map_vma+0x108/0x258)
<4>[ 12.938781] [<c028232c>] (show_map_vma+0x108/0x258) from [<c0282498>] (show_tid_map+0x1c/0x50)
<4>[ 12.958374] [<c0282498>] (show_tid_map+0x1c/0x50) from [<c025af34>] (seq_read+0x1bc/0x440)
<4>[ 12.966278] [<c025af34>] (seq_read+0x1bc/0x440) from [<c023ef40>] (vfs_read+0xa4/0x168)
<4>[ 12.974212] [<c023ef40>] (vfs_read+0xa4/0x168) from [<c023f3b0>] (sys_read+0x34/0x68)
<4>[ 12.981994] [<c023f3b0>] (sys_read+0x34/0x68) from [<c0105ec0>] (ret_fast_syscall+0x0/0x30)
<4>[ 12.990295] ---[ end trace afac045b4ca132d5 ]---

The WLAN seems to load ok. There are no region code settings available in settings, and only CH 1-11 work at 2.4 Ghz. Couldn't test all 5 GHz channels, but I know that 5 GHz seems to work.

<6>[ 34.888916] DefaultCountry is US
<3>[ 35.011993] wlan: WCNSS WLAN Version 1.5.1.2, Host expected 1.4.1.2
<6>[ 35.017913] wlan: WCNSS software version AAAAAANAZW1248017
<6>[ 35.023132] wlan: WCNSS hardware version WCN v2.0 RadioPhy vIris_TSMC_2.0 with 48MHz XO
<7>[ 35.041290] ieee80211 phy0: info: cfg80211 reg_notifier callback for country 00
<3>[ 35.041290] wlan: [929:E :VOS] wlan_hdd_crda_reg_notifier load/unload or SSR is in progress Ignore
<3>[ 35.080169] wlan: [929:E :HDD] wlan_hdd_tdls_init TDLS not enabled (0) or FW doesn't support (1)!
<7>[ 35.098419] ieee80211 phy0: info: cfg80211 reg_notifier callback for country 00
<7>[ 35.098449] ieee80211 phy0: country: US set by driver

But all of the sudden magic happens and regulatory domain changes to SE. My 20MHz wide g/n network now works at CH 13.

<7>[ 40.538940] ieee80211 phy0: info: cfg80211 reg_notifier callback for country 00
<7>[ 40.538970] ieee80211 phy0: country: SE set by driver
<6>[ 47.433471] cfg80211: Calling CRDA to update world regulatory domain
<7>[ 47.433654] ieee80211 phy0: info: cfg80211 reg_notifier callback for country 00
<7>[ 47.433654] ieee80211 phy0: country: SE set by driver
<6>[ 47.433654] cfg80211: World regulatory domain updated:
<6>[ 47.433685] cfg80211: (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
<6>[ 47.433685] cfg80211: (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
<6>[ 47.433685] cfg80211: (2457000 KHz - 2482000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
<6>[ 47.433685] cfg80211: (2474000 KHz - 2494000 KHz @ 20000 KHz), (300 mBi, 2000 mBm)
<6>[ 47.433715] cfg80211: (5170000 KHz - 5250000 KHz @ 80000 KHz), (300 mBi, 2000 mBm)
<6>[ 47.433715] cfg80211: (5735000 KHz - 5835000 KHz @ 80000 KHz), (300 mBi, 2000 mBm)
<6>[ 47.433715] cfg80211: (57240000 KHz - 63720000 KHz @ 2160000 KHz), (N/A, 0 mBm)

Then the driver trips over a HW arp offload that probably should've been off to begin with. Or, the HW arp offload is off, but driver thinks it was on, and tries to free unallocated memory - i have no idea.

<3>[ 52.850616] wlan: [1173:E :HDD] hdd_conf_arp_offload: 903: fenable = 0
<3>[ 52.850616]
<3>[ 52.858795] wlan: [1086:E :CTL] WDI_ProcessHostOffloadReq : Association for this BSSID does not exist 00:25:9c:d5:a8:cc
<3>[ 52.872161] wlan: [1086:E :WDA] Failure in host offload REQ WDI API, free all the memory
<2>[ 53.005035] wlan: [1086:F :CTL] Received response WDI_SET_PREF_NETWORK_RESP (63) when expecting WDI_EXIT_IMPS_RESP (35) - catastrophic failure
<3>[ 53.019104] wlan: [1086:E :CTL] WDI_ProcessExitImpsRsp: Exit IMPS response is a failure with halStatus 5
<3>[ 53.029541] wlan: [1086:E :PMC] pmcProcessResponse: 1352: Response message to request to exit IMPS indicates failure, status 233

The above repeats a few times. Suddenly the wlan module begins coughing.

<3>[ 599.035400] wlan: [1086:E :WDA] WDA_TxPacket: Status 15 when waiting for TX Frame Event
<3>[ 609.035400] wlan: [1086:E :VOS] WDA_HALDumpCmdReq: Timeout occurred before WDA_HALDUMP complete
<3>[ 609.035400]
<2>[ 609.045043] VOS ASSERT in WDA_HALDumpCmdReq Line 10088
<4>[ 609.050659] ------------[ cut here ]------------
<4>[ 609.055145] WARNING: at ../../../../../../kernel/sony/apq8064/drivers/staging/prima/CORE/WDA/src/wlan_qct_wda.c:10088 WDA_HALDumpCmdReq+0x160/0x198 [wlan]()
<4>[ 609.069061] Modules linked in: wlan(C)
<4>[ 609.072418] [<c010c1c4>] (unwind_backtrace+0x0/0x11c) from [<c017d35c>] (warn_slowpath_common+0x4c/0x64)
<4>[ 609.082061] [<c017d35c>] (warn_slowpath_common+0x4c/0x64) from [<c017d404>] (warn_slowpath_null+0x18/0x20)
<4>[ 609.092926] [<c017d404>] (warn_slowpath_null+0x18/0x20) from [<bf139374>] (WDA_HALDumpCmdReq+0x160/0x198 [wlan])
<4>[ 609.103302] [<bf139374>] (WDA_HALDumpCmdReq+0x160/0x198 [wlan]) from [<bf13bd78>] (WDA_TransportChannelDebug+0x44/0x5c [wlan])
<4>[ 609.114990] [<bf13bd78>] (WDA_TransportChannelDebug+0x44/0x5c [wlan]) from [<bf13c024>] (WDA_TxPacket+0x294/0x3d8 [wlan])
<4>[ 609.126159] [<bf13c024>] (WDA_TxPacket+0x294/0x3d8 [wlan]) from [<bf081a10>] (limSendProbeReqMgmtFrame+0x4c4/0x530 [wlan])
<4>[ 609.138031] [<bf081a10>] (limSendProbeReqMgmtFrame+0x4c4/0x530 [wlan]) from [<bf07045c>] (limContinuePostChannelScan+0x134/0x3c4 [wlan])
<4>[ 609.150512] [<bf07045c>] (limContinuePostChannelScan+0x134/0x3c4 [wlan]) from [<bf06cefc>] (limProcessMessages+0x8f4/0x18d4 [wlan])
<4>[ 609.162536] [<bf06cefc>] (limProcessMessages+0x8f4/0x18d4 [wlan]) from [<bf06e1e4>] (limMessageProcessor+0x274/0x980 [wlan])
<4>[ 609.173950] [<bf06e1e4>] (limMessageProcessor+0x274/0x980 [wlan]) from [<bf05458c>] (peProcessMessages+0x44/0x4c [wlan])
<4>[ 609.184997] [<bf05458c>] (peProcessMessages+0x44/0x4c [wlan]) from [<bf1274a8>] (VosMCThread+0x43c/0x678 [wlan])
<4>[ 609.195770] [<bf1274a8>] (VosMCThread+0x43c/0x678 [wlan]) from [<c0199f34>] (kthread+0xa0/0xac)
<4>[ 609.203735] [<c0199f34>] (kthread+0xa0/0xac) from [<c01069d0>] (kernel_thread_exit+0x0/0x8)
<4>[ 609.212341] ---[ end trace afac045b4ca132d6 ]---

After that the Wlan driver seems to go into what looks like 100% debug mode, practically spilling its guts into dmesg.

<2>[ 609.216979] wlan: [1086:F :DAT] Host power state 0, RIVA power state 0
<2>[ 609.223388] wlan: [1086:F :DAT] TX Pending frames count 1, Current available BD 215
<2>[ 609.231201] wlan: [1088:F :DAT] === ******** Get Descriptor Snapshot Channel Number 1, Channel Type RX_LOW_PRI
<3>[ 609.241882] wlan: [1087:E :DAT] dxeDebugTxDescReSync: Check for DXE TX Async
<3>[ 609.248291] wlan: [1086:E :PE ] limSendProbeReqMgmtFrame: 397: could not send Probe Request frame!
<2>[ 609.257568] wlan: [1088:F :DAT] numDesc 256, numFreeDesc 0, numResvDesc 0
<2>[ 609.264129] wlan: [1088:F :DAT] headCB 0xec0796c0, next 0xec079700, DESC 0xaea24b4c
<3>[ 609.271728] wlan: [1086:E :PE ] limContinuePostChannelScan: 458: send ProbeReq failed for SSID on channel: 1
<2>[ 609.281860] wlan: [1087:F :DAT] TX Async
<2>[ 609.286621] wlan: [1087:F :DAT] === !!! TX Async !!! Channel Number 4, Channel Type TX_HIGH_PRI
<2>[ 609.294586] wlan: [1087:F :DAT] numDesc 256, numFreeDesc 254, numResvDesc 2
<2>[ 609.301849] wlan: [1088:F :DAT] tailCB 0xec0796c0, next 0xec079700, DESC 0xaea24b4c
<3>[ 609.309753] wlan: [1086:E :CTL] Timeout occurred but not waiting for any response 96 timeStampTmrStart: 1134187692, timeStampTmrExp: 1134197959
<2>[ 609.322418] wlan: [1088:F :DAT] headCB Order 90, tailCB Order 90
<2>[ 609.328186] wlan: [1087:F :DAT] headCB 0xebbdf380, next 0xebbdf3c0, DESC 0xaea201cc
<2>[ 609.336730] wlan: [1088:F :DAT] numFragmentCurrentChain 1, numTotalFrame 90 ===
<2>[ 609.343505] wlan: [1088:F :DAT] +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<3>[ 609.352661] wlan: [1086:E :CTL] WDI_ProcessHostOffloadReq : Association for this BSSID does not exist 00:25:9c:d5:a8:cc
<2>[ 609.363494] wlan: [1087:F :DAT] tailCB 0xebbdf300, next 0xebbdf340, DESC 0xaea2018c
<3>[ 609.371002] wlan: [1086:E :WDA] Failure in host offload REQ WDI API, free all the memory
<2>[ 609.379364] wlan: [1087:F :DAT] headCB Order 14, tailCB Order 12
<2>[ 609.385040] wlan: [1087:F :DAT] numFragmentCurrentChain 2, numTotalFrame 1543 ===
<2>[ 609.393402] wlan: [1088:F :DAT] Descriptor Dump for channel RX_LOW_PRI, 1 / 1 fragment
<2>[ 609.401123] wlan: [1088:F :DAT] CTRL WORD 0x12ad2f, TransferSize 0
<3>[ 609.407043] wlan: [1086:E :CTL] WDI_ProcessHostOffloadReq : Association for this BSSID does not exist 00:25:9c:d5:a8:cc
<2>[ 609.417938] wlan: [1087:F :DAT] TX_HIGH_PRI Channel register dump for !!! TX Async !!!, base address 0x3202500
<2>[ 609.427886] wlan: [1088:F :DAT] SRC ADD 0xb, DST ADD 0xaba17000, NEXT DESC 0xaea24b6c
<2>[ 609.436401] wlan: [1088:F :DAT] +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

There's a lot more of that in the dmesg.txt, but impressively enough, the Wlan driver recovers, and even more noteworthy is that all problems described until now have not impacted normal phone usage.

Apart from Wlan, there was also a random memory leak. Which is nice.

10-07 20:57:23.098 1616 1632 E DataBuffer: Internal data leak within a DataBuffer object detected! Be sure to explicitly call release() on all DataBuffer extending objects when you are done with them. (internal object: com.google.android.gms.common.data.DataHolder@3f3e856b)

So, yeah. Hot tip of the day is to ctrl+f "Internal data leak" logcat for goodies.

qsnc, tell me if there's some use scenario you want me to check.

[EDIT]

I've triaged the bug that causes Wifi to sleep despite the "Keep Wifi always on during sleep", when USB Tethering. This happens before the Wlan disconnects:

<2>[19589.592131] wlan: [1094:F :CTL] WDI Process Enter BMPS RSP failed With HAL Status Code: 1
<3>[19589.599547] wlan: [1094:E :PMC] pmmInitBmpsResponseHandler: 268: pmmBmps: BMPS_INIT_PWR_SAVE_REQ failed, informing SME
<3>[19589.610900] wlan: [1094:E :PMC] pmmInitBmpsResponseHandler: 285: Unexpected heartbeat timer not running
<3>[19589.619597] wlan: [1094:E :PMC] pmcProcessResponse: 1388: Response message to request to enter BMPS indicates failure, status 234
<2>[19590.633452] wlan: [1094:F :CTL] WDI Process Enter BMPS RSP failed With HAL Status Code: 1
<3>[19590.642211] wlan: [1094:E :PMC] pmmInitBmpsResponseHandler: 268: pmmBmps: BMPS_INIT_PWR_SAVE_REQ failed, informing SME
<3>[19590.652495] wlan: [1094:E :PMC] pmmInitBmpsResponseHandler: 285: Unexpected heartbeat timer not running
<3>[19590.661864] wlan: [1094:E :PMC] pmcProcessResponse: 1388: Response message to request to enter BMPS indicates failure, status 234
<2>[19591.684050] wlan: [1094:F :CTL] WDI Process Enter BMPS RSP failed With HAL Status Code: 1
<3>[19591.691802] wlan: [1094:E :PMC] pmmInitBmpsResponseHandler: 268: pmmBmps: BMPS_INIT_PWR_SAVE_REQ failed, informing SME
<3>[19591.702544] wlan: [1094:E :PMC] pmmInitBmpsResponseHandler: 285: Unexpected heartbeat timer not running
<3>[19591.711852] wlan: [1094:E :PMC] pmcProcessResponse: 1388: Response message to request to enter BMPS indicates failure, status 234
<2>[19592.733519] wlan: [1094:F :CTL] WDI Process Enter BMPS RSP failed With HAL Status Code: 1
<3>[19592.741271] wlan: [1094:E :PMC] pmmInitBmpsResponseHandler: 268: pmmBmps: BMPS_INIT_PWR_SAVE_REQ failed, informing SME
<3>[19592.753905] wlan: [1094:E :PMC] pmmInitBmpsResponseHandler: 285: Unexpected heartbeat timer not running
<3>[19592.762725] wlan: [1094:E :PMC] pmcProcessResponse: 1388: Response message to request to enter BMPS indicates failure, status 234
<2>[19593.783416] wlan: [1094:F :CTL] WDI Process Enter BMPS RSP failed With HAL Status Code: 1
<3>[19593.792266] wlan: [1094:E :PMC] pmmInitBmpsResponseHandler: 268: pmmBmps: BMPS_INIT_PWR_SAVE_REQ failed, informing SME
<3>[19593.812743] wlan: [1094:E :PMC] pmmInitBmpsResponseHandler: 285: Unexpected heartbeat timer not running
<3>[19593.832915] wlan: [1094:E :PMC] pmcProcessResponse: 1388: Response message to request to enter BMPS indicates failure, status 234
<3>[19594.164427] wlan: [1094:E :PE ] limDeleteStaContext: 133: Deleting station: staId = 3, reasonCode = 1
<6>[19594.189543] wlan: disconnected
<6>[19594.191619] wlan(0) 00:00:00:00:00:00 Standalone
<6>[19594.206908] cfg80211: Calling CRDA to update world regulatory domain
<7>[19594.218779] ieee80211 phy0: info: cfg80211 reg_notifier callback for country 00
<7>[19594.218810] ieee80211 phy0: country: SE set by driver
<6>[19594.218810] cfg80211: World regulatory domain updated:
<3>[19594.223082] wlan: [1094:E :SME] sme_8023MulticastList: Unable to find the right session
<6>[19594.246794] cfg80211: (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
<6>[19594.254637] cfg80211: (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
<6>[19594.261809] cfg80211: (2457000 KHz - 2482000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
<6>[19594.269652] cfg80211: (2474000 KHz - 2494000 KHz @ 20000 KHz), (300 mBi, 2000 mBm)
<6>[19594.277312] cfg80211: (5170000 KHz - 5250000 KHz @ 80000 KHz), (300 mBi, 2000 mBm)
<6>[19594.285247] cfg80211: (5735000 KHz - 5835000 KHz @ 80000 KHz), (300 mBi, 2000 mBm)
<6>[19594.292693] cfg80211: (57240000 KHz - 63720000 KHz @ 2160000 KHz), (N/A, 0 mBm)

In an attempt to rescue the connection the following fails:

<3>[20044.564727] wlan: [1150:E :HDD] hdd_conf_arp_offload: 903: fenable = 0
<3>[20044.564727]
<3>[20044.572112] wlan: [1150:E :SME] sme_8023MulticastList: Unable to find the right session
<3>[20044.580962] wlan: [1094:E :CTL] WDI_ProcessHostOffloadReq : Association for this BSSID does not exist 00:0b:0e:71:0a:05
<3>[20044.591063] wlan: [1094:E :WDA] Failure in host offload REQ WDI API, free all the memory

Then the circus settles down as the Wlan begins working again.

<3>[20059.409911]
<3>[20059.417571] wlan: [1150:E :SME] sme_8023MulticastList: Unable to find the right session
<3>[20059.417632] wlan: [1094:E :CTL] WDI_ProcessHostOffloadReq : Association for this BSSID does not exist 00:0b:0e:71:0a:05
<3>[20059.417632] wlan: [1094:E :WDA] Failure in host offload REQ WDI API, free all the memory
<3>[20059.608550] wlan: [1094:E :CTL] WDI_ProcessExitImpsRsp: Exit IMPS response is a failure with halStatus 5
<3>[20059.617705] wlan: [1094:E :PMC] pmcProcessResponse: 1352: Response message to request to exit IMPS indicates failure, status 233
<6>[20059.664183] mipi_dsi_panel mipi_dsi_panel.0: panel_display_on: DISPLAY_ON sent
<3>[20062.192473] qup_i2c qup_i2c.0: QUP: I2C status flags :0x1300c8, irq:226
<3>[20062.198149] qup_i2c qup_i2c.0: I2C slave addr:0x28 not connected
<3>[20062.214568] pn544 0-0028: pn544_dev_write: i2c write err -107, but retry 1
<3>[20070.454131] wlan: [1094:E :PE ] wlan_cfgGetInt: 348: Not valid cfg id 1
<6>[20070.469420] wlan: connected to 00:0b:0e:71:0a:05
<6>[20070.475096] wlan(36) 00:0b:0e:71:0a:05 Standalone
<6>[20070.479888] ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready

Now, i'd suggest disabling any power saving that the Wlan is was trying to init, and see where that takes us.

[EDIT2]

In case you're making a another snapshot, i have feature request for FauxSound. The patches are here.

It allows to reduce the analog amplification, while keeping digital volume the same. The result is less circuit distortion - it's definitely easier on the ear.

Amplification beyond standard is also possible.