[WCNCR00155761] sdio: Fix MMC crash when TX T.P.

[Description]
Fix MMC crash when TX T.P.

Get following oops when TX T.P. test on entry-level platform
CPU: 0 PID: 11049 Comm: hif_thread Tainted: P
Call trace:
[<ffffffc001088ea4>] dump_backtrace+0x0/0x144
[<ffffffc001089004>] show_stack+0x1c/0x28
[<ffffffc001a22040>] dump_stack+0x74/0xb8
[<ffffffc001a1fcc8>] panic+0xe8/0x20c
[<ffffffc0015ac2dc>] mmc_start_request+0x104/0x130
[<ffffffc0015ac48c>] __mmc_start_req+0x64/0x98
[<ffffffc0015ac95c>] mmc_wait_for_req+0x24/0x40
[<ffffffc0015b8548>] mmc_io_rw_extended+0x20c/0x348
[<ffffffc0015b9bcc>] sdio_io_rw_ext_helper+0xb0/0x1c8
[<ffffffc0015ba028>] sdio_writesb+0x48/0x58
[<ffffffbffc453fc0>] kalDevPortWrite+0xa8/0x238 [wlan_mt7668_sdio]
[<ffffffbffc454780>] kalDevKickData+0x90/0xc8 [wlan_mt7668_sdio]
[<ffffffbffc3f6758>] nicTxMsduQueue+0x150/0x3cc [wlan_mt7668_sdio]
[<ffffffbffc3f6a88>] nicTxMsduQueueMthread [wlan_mt7668_sdio]
[<ffffffbffc418eac>] hif_thread+0x1d4/0x2b4 [wlan_mt7668_sdio]
[<ffffffc0010bdac8>] kthread+0xd8/0xf0

Root cause:
The oops is caused by the sanity check in mmc_start_request()
BUG_ON(mrq->data->blksz > host->max_blk_size);
BUG_ON(mrq->data->blocks > host->max_blk_count);
BUG_ON(mrq->data->blocks * mrq->data->blksz > host->max_req_size);

Solution:
1. Add new API halGetValidCoalescingBufSize() to get
a valid size based on config & host capability.
2. Allocate working buffer with the valid length.

Change-Id: Ie6eb620a8b0047a87fea7bc52a944993c0289a09
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
CR-Id: WCNCR00155761
Feature: sdio
5 files changed