History log of /linux-master/drivers/bluetooth/btmrvl_sdio.c
Revision Date Author Comments
# 04909d7b 10-Mar-2023 Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Bluetooth: btmrvl_sdio: mark OF related data as maybe unused

The driver can be compile tested with !CONFIG_OF making certain data
unused:

drivers/bluetooth/btmrvl_sdio.c:43:34: error:
‘btmrvl_sdio_of_match_table’ defined but not used
[-Werror=unused-const-variable=]

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>


# 38a523a2 27-Jun-2022 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Revert "devcoredump: remove the useless gfp_t parameter in dev_coredumpv and dev_coredumpm"

This reverts commit 77515ebaf01920e2db49e04672ef669a7c2907f2 as it
causes build problems in linux-next. It needs to be reintroduced in a
way that can allow the api to evolve and not require a "flag day" to
catch all users.

Link: https://lore.kernel.org/r/20220623160723.7a44b573@canb.auug.org.au
Cc: Duoming Zhou <duoming@zju.edu.cn>
Cc: Brian Norris <briannorris@chromium.org>
Cc: Johannes Berg <johannes@sipsolutions.net>
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 77515eba 06-Jun-2022 Duoming Zhou <duoming@zju.edu.cn>

devcoredump: remove the useless gfp_t parameter in dev_coredumpv and dev_coredumpm

The dev_coredumpv() and dev_coredumpm() could not be used in atomic
context, because they call kvasprintf_const() and kstrdup() with
GFP_KERNEL parameter. The process is shown below:

dev_coredumpv(.., gfp_t gfp)
dev_coredumpm(.., gfp_t gfp)
dev_set_name
kobject_set_name_vargs
kvasprintf_const(GFP_KERNEL, ...); //may sleep
kstrdup(s, GFP_KERNEL); //may sleep

This patch removes gfp_t parameter of dev_coredumpv() and dev_coredumpm()
and changes the gfp_t parameter of kzalloc() in dev_coredumpm() to
GFP_KERNEL in order to show they could not be used in atomic context.

Fixes: 833c95456a70 ("device coredump: add new device coredump class")
Reviewed-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
Link: https://lore.kernel.org/r/df72af3b1862bac7d8e793d1f3931857d3779dfd.1654569290.git.duoming@zju.edu.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 99c926ce 07-Jun-2022 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - gpl-2.0_390.RULE

Based on the normalized pattern:

this software file (the file ) is distributed by marvell international
ltd under the terms of the gnu general public license version 2 june
1991 (the license ) you may use redistribute and/or modify this file
in accordance with the terms and conditions of the license a copy of
which is available by writing to the free software foundation inc 51
franklin street fifth floor boston ma 02110-1301 usa or on the
worldwide web at http://www gnu org/licenses/old-licenses/gpl-2 0 txt
the file is distributed as-is without warranty of any kind and the
implied warranties of merchantability or fitness for a particular
purpose are expressly disclaimed the license provides additional
details about this warranty disclaimer

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-only

has been chosen to replace the boilerplate/reference.

Reviewed-by: Allison Randal <allison@lohutok.net>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a86974f7 14-Jan-2022 Tedd Ho-Jeong An <tedd.an@intel.com>

Bluetooth: Remove kernel-doc style comment block

This patch changes the kernel-doc style comment block to common comment
block. These files don't support kernel-doc style so no need to use the
kernel-doc style. Also, they cause the warning when W=1 option is used
as below.

drivers/bluetooth/hci_ll.c:518: warning: Function parameter or member 'lldev' not described in 'download_firmware'
drivers/bluetooth/btmrvl_debugfs.c:29: warning: cannot understand function prototype: 'struct btmrvl_debugfs_data '
drivers/bluetooth/btmrvl_sdio.c:36: warning: expecting prototype for Marvell BT-over-SDIO driver(). Prototype was for VERSION() instead

Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 785077fa 24-Jul-2021 Len Baker <len.baker@gmx.com>

Bluetooth: btmrvl_sdio: Remove all strcpy() uses

strcpy() performs no bounds checking on the destination buffer. This
could result in linear overflows beyond the end of the buffer, leading
to all kinds of misbehaviors. The safe replacement is strscpy() but in
this case it is better to use the scnprintf to simplify the arithmetic.

This is a previous step in the path to remove the strcpy() function
entirely from the kernel.

Signed-off-by: Len Baker <len.baker@gmx.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# dd912f43 16-Jun-2021 Colin Ian King <colin.king@canonical.com>

Bluetooth: btmrvl: remove redundant continue statement

The continue statement in the for-loop has no effect,
remove it.

Addresses-Coverity: ("Continue has no effect")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 7cfc21e9 02-Aug-2020 Tamás Szűcs <tszucs@protonmail.ch>

Bluetooth: btmrvl: eliminate duplicates introducing btmrvl_reg_89xx

SD89xx devices use identical card register settings. Make sure a single common
instance is used to describe them.

Signed-off-by: Tamás Szűcs <tszucs@protonmail.ch>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# e660b351 10-Jun-2020 Abhishek Pandit-Subedi <abhishekpandit@chromium.org>

Bluetooth: btmrvl_sdio: Refactor irq wakeup

Use device_init_wakeup to allow the Bluetooth dev to wake the system
from suspend. Currently, the device can wake the system but no
power/wakeup entry is created in sysfs to allow userspace to disable
wakeup.

Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 00eb0cb3 03-Jun-2020 Pali Rohár <pali@kernel.org>

btmrvl: Fix firmware filename for sd8997 chipset

Firmware for sd8997 chipset is distributed by Marvell package and also as
part of the linux-firmware repository in filename sdsd8997_combo_v4.bin.

This patch fixes mwifiex driver to load correct firmware file for sd8997.

Fixes: f0ef67485f591 ("Bluetooth: btmrvl: add sd8997 chipset support")
Signed-off-by: Pali Rohár <pali@kernel.org>
Acked-by: Ganapathi Bhat <ganapathi.bhat@nxp.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# dbec3af5 03-Jun-2020 Pali Rohár <pali@kernel.org>

btmrvl: Fix firmware filename for sd8977 chipset

Firmware for sd8977 chipset is distributed by Marvell package and also as
part of the linux-firmware repository in filename sdsd8977_combo_v2.bin.

This patch fixes mwifiex driver to load correct firmware file for sd8977.

Fixes: 8c57983bf7a79 ("Bluetooth: btmrvl: add support for sd8977 chipset")
Signed-off-by: Pali Rohár <pali@kernel.org>
Acked-by: Ganapathi Bhat <ganapathi.bhat@nxp.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 649c7d76 22-May-2020 Pali Rohár <pali@kernel.org>

mmc: sdio: Move SDIO IDs from btmrvl driver to common include file

Define appropriate macro names for consistency with other Marvell macros.

Signed-off-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20200522144412.19712-5-pali@kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Ganapathi Bhat <ganapathi.bhat@nxp.com>


# 73623340 14-Apr-2019 Tamás Szűcs <tszucs@protonmail.ch>

Bluetooth: btmrvl: add support for SD8987 chipset

This patch adds support for Marvell 88W8987 chipset with SDIO interface.
Register offsets and supported feature flags are updated. The corresponding
firmware image file shall be "mrvl/sd8987_uapsta.bin".

Signed-off-by: Tamás Szűcs <tszucs@protonmail.ch>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 8c57983b 09-Jan-2019 Hemantkumar Suthar <shemant@marvell.com>

Bluetooth: btmrvl: add support for sd8977 chipset

This patch adds support for 8977 chipset to mwifiex with SDIO
interface. Register offsets and supported feature flags are
updated. Firmware image used will be mrvl/sd8977_uapsta.bin.

Signed-off-by: Hemantkumar Suthar <shemant@marvell.com>
Signed-off-by: Rakesh Parmar <rakeshp@marvell.com>
Signed-off-by: Cathy Luo <cluo@marvell.com>
Signed-off-by: Ganapathi Bhat <gbhat@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 37c589ec 11-Jan-2019 Stefan Agner <stefan@agner.ch>

Bluetooth: btmrvl: lower log level of informational message

The platform specific wake-up interrupt is optional. Don't print
an error message in case it is missing, merely inform the user in
this case.

Signed-off-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 10004f81 11-Jan-2019 Stefan Agner <stefan@agner.ch>

Bluetooth: btmrvl: improve printk messages

Use dev_* variants to print messages in drivers.

Signed-off-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 436018ee 22-Jul-2018 Jia-Ju Bai <baijiaju1990@gmail.com>

bluetooth: btmrvl_sdio: Replace GFP_ATOMIC with GFP_KERNEL in btmrvl_sdio_card_to_host()

btmrvl_sdio_card_to_host() is never called in atomic context.
It calls bt_skb_alloc() with GFP_ATOMIC, which is not necessary.
GFP_ATOMIC can be replaced with GFP_KERNEL.

This is found by a static analysis tool named DCNS written by myself.
I also manually check the kernel code before reporting it.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 45650499 17-May-2018 Arend van Spriel <arend.vanspriel@broadcom.com>

Bluetooth: btmrvl: support sysfs initiated firmware coredump

Since commit 3c47d19ff4dc ("drivers: base: add coredump driver ops")
it is possible to initiate a device coredump from user-space. This
patch adds support for it in btmrvl_sdio adding the .coredump()
driver callback. This makes dump through debugfs obsolete so removing
it.

Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 9376e4a5 12-Mar-2018 Markus Elfring <elfring@users.sourceforge.net>

Bluetooth: btmrvl: Delete an unnecessary variable initialisation in btmrvl_sdio_card_to_host()

The variable "payload" will eventually be set to an appropriate pointer
a bit later. Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# a5c2f4c1 12-Mar-2018 Markus Elfring <elfring@users.sourceforge.net>

Bluetooth: btmrvl: Delete an unnecessary variable initialisation in btmrvl_sdio_register_dev()

The local variable "ret" will be set to an appropriate value a bit later.
Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 24a3a32a 25-Sep-2017 Arvind Yadav <arvind.yadav.cs@gmail.com>

Bluetooth: btmrvl: *_err() and *_info() strings should end with newlines

pr_err(), dev_err() and pr_info() messages should terminated with
a new-line to avoid other messages being concatenated onto the end.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# d98422cb 21-Jul-2017 Derek Robson <robsonde@gmail.com>

Bluetooth: Style fix - align block comments

Fixed alignment of all block comments.
Found using checkpatch

Signed-off-by: Derek Robson <robsonde@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# c8ba8044 31-Mar-2017 Xinming Hu <huxm@marvell.com>

Bluetooth: btmrvl: remove unnecessary wakeup interrupt number sanity check

Sanity check of interrupt number in interrupt handler is unnecessary and
confusion, remove it.

Reported-by: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Xinming Hu <huxm@marvell.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 6eb7bd66 31-Mar-2017 Xinming Hu <huxm@marvell.com>

Bluetooth: btmrvl: disable platform wakeup interrupt in suspend failure path

Host sleep handshake with device might been fail, disable platform wakeup
interrupt in this case.

Reported-by: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Xinming Hu <huxm@marvell.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# f1554b7b 28-Mar-2017 prasanna karthik <prasannakarthik@outlook.com>

Bluetooth: btmrvl: cleanup code in return from btmrvl_sdio_suspend()

Else is not generally useful after a break or return

Signed-off-by: Prasanna Karthik <pkarthik@outlook.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 17e41ea6 23-Feb-2017 Jeffy Chen <jeffy.chen@rock-chips.com>

Bluetooth: btmrvl: wake system up when receives a wake irq

Currrently we are disabling this wake irq after receiving it. If this
happens before we finish suspend and the pm event check is disabled,
the system will continue suspending, and this irq would not work again.

We may need to abort system suspend to avoid that.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 92322599 20-Mar-2017 Colin Ian King <colin.king@canonical.com>

Bluetooth: btmrvl: fix spelling mistake: "unregester" -> "unregister"

trivial fix to spelling mistake in debug message

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 8f91566f 18-Feb-2017 Colin Ian King <colin.king@canonical.com>

btmrvl: fix spelling mistake: "actived" -> "activated"

trivial fix to spelling mistake in error message

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# ffb955db 22-Jan-2017 Jeffy Chen <jeffy.chen@rock-chips.com>

btmrvl: use dt's irqflags for wakeup pin

Use irqflags parsed from dt.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Reviewed-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# fd1a88da 22-Jan-2017 Jeffy Chen <jeffy.chen@rock-chips.com>

btmrvl: set irq_bt to -1 when failed to parse it

The irq_of_parse_and_map will return 0 as a invalid irq.

Set irq_bt to -1 in this case, so that the btmrvl resume/suspend code
would not try to enable/disable it.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Reviewed-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 9af02d86 22-Jan-2017 Jeffy Chen <jeffy.chen@rock-chips.com>

btmrvl: avoid double-disable_irq() race

It's much the same as what we did for mwifiex in:
b9da4d2 mwifiex: avoid double-disable_irq() race

"We have a race where the wakeup IRQ might be in flight while we're
calling mwifiex_disable_wake() from resume(). This can leave us
disabling the IRQ twice.

Let's disable the IRQ and enable it in case if we have double-disabled
it."

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Reviewed-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# e7acf430 15-Jul-2016 Amitkumar Karwar <akarwar@marvell.com>

Bluetooth: btmrvl: reset is_suspending flag in failure path

is_suspending flag remains on when host sleep fails to enable. Data
path is unnecessarily blocked after this. This patch ensures to
reset the flag in failure path.

Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# d2f30240 28-Jun-2016 Ricky Liang <jcliang@chromium.org>

Bluetooth: btmrvl: fix slab-out-of-bounds access in btmrvl_sdio

Kasan reported slab-out-of-bounds access in btmrvl_sdio:

[ 33.055400] ==================================================================
[ 33.062585] BUG: KASAN: slab-out-of-bounds in memcpy+0x24/0x50 at addr ffffffc0d89b4a00
[ 33.070529] Read of size 256 by task btmrvl_main_ser/3576
[ 33.075885] =============================================================================
[ 33.084002] BUG kmalloc-256 (Tainted: G B ): kasan: bad access detected
[ 33.091511] -----------------------------------------------------------------------------
<snip...>
[ 33.413498] Call trace:
[ 33.415928] [<ffffffc00020a440>] dump_backtrace+0x0/0x190
[ 33.421288] [<ffffffc00020a5ec>] show_stack+0x1c/0x28
[ 33.426305] [<ffffffc000b3288c>] dump_stack+0xa0/0xf8
[ 33.431320] [<ffffffc000396130>] print_trailer+0x158/0x16c
[ 33.436765] [<ffffffc0003962cc>] object_err+0x48/0x5c
[ 33.441780] [<ffffffc00039be24>] kasan_report+0x344/0x510
[ 33.447141] [<ffffffc00039afd8>] __asan_loadN+0x20/0x150
[ 33.452413] [<ffffffc00039b60c>] memcpy+0x20/0x50
[ 33.457084] [<ffffffc000595fcc>] swiotlb_tbl_map_single+0x2ec/0x310
[ 33.463305] [<ffffffc000596b54>] map_single+0x24/0x30
[ 33.468320] [<ffffffc0005970c8>] swiotlb_map_sg_attrs+0xec/0x21c
[ 33.474286] [<ffffffc000219d4c>] __swiotlb_map_sg_attrs+0x48/0xec
[ 33.480339] [<ffffffc0008ea610>] msdc_prepare_data.isra.11+0xf0/0x11c
[ 33.486733] [<ffffffc0008ecbd0>] msdc_ops_request+0x74/0xf0
[ 33.492266] [<ffffffc0008c6b38>] __mmc_start_request+0x78/0x8c
[ 33.498057] [<ffffffc0008c6d6c>] mmc_start_request+0x220/0x240
[ 33.503848] [<ffffffc0008c6e04>] mmc_wait_for_req+0x78/0x250
[ 33.509468] [<ffffffc0008d70fc>] mmc_io_rw_extended+0x2ec/0x388
[ 33.515347] [<ffffffc0008d8fc0>] sdio_io_rw_ext_helper+0x160/0x268
[ 33.521483] [<ffffffc0008d93fc>] sdio_writesb+0x40/0x50
[ 33.526677] [<ffffffbffc338b38>] btmrvl_sdio_host_to_card+0x124/0x1bc [btmrvl_sdio]
[ 33.534283] [<ffffffbffc3290a0>] btmrvl_service_main_thread+0x384/0x428 [btmrvl]
[ 33.541626] [<ffffffc0002518e8>] kthread+0x140/0x158
[ 33.546550] Memory state around the buggy address:
[ 33.551305] ffffffc0d89b4980: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[ 33.558474] ffffffc0d89b4a00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[ 33.565643] >ffffffc0d89b4a80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fc
[ 33.572809] ^
[ 33.579889] ffffffc0d89b4b00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[ 33.587055] ffffffc0d89b4b80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[ 33.594221] ==================================================================

The cause of this is that btmrvl_sdio_host_to_card can access memory region
out of its allocated space due to:

1. the requested block size is smaller than SDIO_BLOCK_SIZE, and/or
2. the allocated memory is not BTSDIO_DMA_ALIGN-aligned.

This patch fixes the issue by allocating a buffer which is big enough for
SDIO_BLOCK_SIZE transfer and/or BTSDIO_DMA_ALIGN address relocation.

Signed-off-by: Ricky Liang <jcliang@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# bb7f4f0b 26-Apr-2016 Xinming Hu <huxm@marvell.com>

btmrvl: add platform specific wakeup interrupt support

On some arm-based platforms, we need to configure platform specific
parameters by device tree node and also define our node as a child
node of parent SDIO host controller.
This patch parses these parameters from device tree. It includes
calibration data download to firmware, wakeup pin configured to firmware,
and soc specific wake up gpio, which will be set as wakeup interrupt pin.

Signed-off-by: Xinming Hu <huxm@marvell.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 9a01242d 07-Mar-2016 Wei-Ning Huang <wnhuang@chromium.org>

Bluetooth: btmrvl_sdio: fix firmware activation failure

In some case, the btmrvl_sdio firmware would fail to active within the
polling time. Increase the polling interval to 100 msec to fix the
issue.

Signed-off-by: Wei-Ning Huang <wnhuang@chromium.org>
Signed-off-by: Wei-Ning Huang <wnhuang@google.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 8cf60cf2 06-Jan-2016 Chin-Ran Lo <crlo@marvell.com>

Bluetooth: btmrvl: don't send data to firmware while processing suspend

Usually when driver sends data to firmware it receives TX_DONE
(DN_LD_HOST_INT_STATUS) interrupt from firmware right away.
It's also observed that some times the fireware could delay
sending DN_LD_HOST_INT_STATUS interrupt. If driver sends data to
firmware during suspend processing and the TX_DONE interrupt is
delayed, it may come back at wrong time when SDIO host driver is
in the middle of suspending.

Block any data from stack while suspending. Also skip sending
data that are already in driver tx_queue.

Don't purge the skb queue on suspend to avoid intermittent music
after system resumes from S3.

Signed-off-by: Chin-Ran Lo <crlo@marvell.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 86f7ac77 29-Dec-2015 Chin-Ran Lo <crlo@marvell.com>

Bluetooth: btmrvl: fix hung task warning dump

It's been observed that when bluetooth driver fails to
activate the firmware, below hung task warning dump is
displayed after 120 seconds.

[ 36.461022] Bluetooth: vendor=0x2df, device=0x912e, class=255, fn=2
[ 56.512128] Bluetooth: FW failed to be active in time!
[ 56.517264] Bluetooth: Downloading firmware failed!
[ 240.252176] INFO: task kworker/3:2:129 blocked for more than 120 seconds.
[ 240.258931] Not tainted 3.18.0 #254
[ 240.262972] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 240.270751] kworker/3:2 D ffffffc000205760 0 129 2 0x00000000
[ 240.277825] Workqueue: events request_firmware_work_func
[ 240.283134] Call trace:
[ 240.285581] [<ffffffc000205760>] __switch_to+0x80/0x8c
[ 240.290693] [<ffffffc00088dae0>] __schedule+0x540/0x7b8
[ 240.295921] [<ffffffc00088ddd0>] schedule+0x78/0x84
[ 240.300764] [<ffffffc0006dfd48>] __mmc_claim_host+0xe8/0x1c8
[ 240.306395] [<ffffffc0006edd6c>] sdio_claim_host+0x74/0x84
[ 240.311840] [<ffffffbffc163d08>] 0xffffffbffc163d08
[ 240.316685] [<ffffffbffc165104>] 0xffffffbffc165104
[ 240.321524] [<ffffffbffc130cf8>] mwifiex_dnld_fw+0x98/0x110 [mwifiex]
[ 240.327918] [<ffffffbffc12ee88>] mwifiex_remove_card+0x2c4/0x5fc [mwifiex]
[ 240.334741] [<ffffffc000596780>] request_firmware_work_func+0x44/0x80
[ 240.341127] [<ffffffc00023b934>] process_one_work+0x2ec/0x50c
[ 240.346831] [<ffffffc00023c6a0>] worker_thread+0x350/0x470
[ 240.352272] [<ffffffc0002419bc>] kthread+0xf0/0xfc
[ 240.357019] 2 locks held by kworker/3:2/129:
[ 240.361248] #0: ("events"){.+.+.+}, at: [<ffffffc00023b840>] process_one_work+0x1f8/0x50c
[ 240.369562] #1: ((&fw_work->work)){+.+.+.}, at: [<ffffffc00023b840>] process_one_work+0x1f8/0x50c
[ 240.378589] task PC stack pid father
[ 240.384501] kworker/1:1 D ffffffc000205760 0 40 2 0x00000000
[ 240.391524] Workqueue: events mtk_atomic_work
[ 240.395884] Call trace:
[ 240.398317] [<ffffffc000205760>] __switch_to+0x80/0x8c
[ 240.403448] [<ffffffc00027279c>] lock_acquire+0x128/0x164
[ 240.408821] kworker/3:2 D ffffffc000205760 0 129 2 0x00000000
[ 240.415867] Workqueue: events request_firmware_work_func
[ 240.421138] Call trace:
[ 240.423589] [<ffffffc000205760>] __switch_to+0x80/0x8c
[ 240.428688] [<ffffffc00088dae0>] __schedule+0x540/0x7b8
[ 240.433886] [<ffffffc00088ddd0>] schedule+0x78/0x84
[ 240.438732] [<ffffffc0006dfd48>] __mmc_claim_host+0xe8/0x1c8
[ 240.444361] [<ffffffc0006edd6c>] sdio_claim_host+0x74/0x84
[ 240.449801] [<ffffffbffc163d08>] 0xffffffbffc163d08
[ 240.454649] [<ffffffbffc165104>] 0xffffffbffc165104
[ 240.459486] [<ffffffbffc130cf8>] mwifiex_dnld_fw+0x98/0x110 [mwifiex]
[ 240.465882] [<ffffffbffc12ee88>] mwifiex_remove_card+0x2c4/0x5fc [mwifiex]
[ 240.472705] [<ffffffc000596780>] request_firmware_work_func+0x44/0x80
[ 240.479090] [<ffffffc00023b934>] process_one_work+0x2ec/0x50c
[ 240.484794] [<ffffffc00023c6a0>] worker_thread+0x350/0x470
[ 240.490231] [<ffffffc0002419bc>] kthread+0xf0/0xfc

This patch adds missing sdio_release_host() call so that wlan driver
thread can claim sdio host.

Fixes: 4863e4cc31d647e1 ("Bluetooth: btmrvl: release sdio bus after firmware is up")
Signed-off-by: Chin-Ran Lo <crlo@marvell.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 618e8bc2 04-Nov-2015 Marcel Holtmann <marcel@holtmann.org>

Bluetooth: Use new hci_skb_pkt_* wrappers for drivers

The new hci_skb_pkt_* wrappers are mainly intented for drivers to
require less knowledge about bt_cb(sbk) handling. So after converting
the core packet handling, convert all drivers.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>


# 1f438c61 25-Sep-2015 Prasanna Karthik <mkarthi3@visteon.com>

Bluetooth: btmrvl: Comparison to NULL re-written

NOT NULL comparison modified to be readable, reported
by checkpatch.

Signed-off-by: Prasanna Karthik <mkarthi3@visteon.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# f0ef6748 21-Sep-2015 Amitkumar Karwar <akarwar@marvell.com>

Bluetooth: btmrvl: add sd8997 chipset support

This patch adds support for Marvell's new chipset SD8997.
Register offsets and supported feature flags are updated.

Signed-off-by: Zhaoyang Liu <liuzy@marvell.com>
Signed-off-by: Cathy Luo <cluo@marvell.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 53d6cfa5 21-Sep-2015 Amitkumar Karwar <akarwar@marvell.com>

Bluetooth: btmrvl: remove extra space in cast

Coding style fix, extra spaces are removed to make casting
consistent.

Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 475b9eac 18-Sep-2015 Nachiket Kukade <kukaden@marvell.com>

Bluetooth: btmrvl: fix firmware dump issue

First firmware dump attempt from user works fine, but firmware goes
into bad state after this. Subsequent attempts fails.

As required by the firmware dump implementation, this change writes
FW_DUMP_READ_DONE value to dump ctrl register to address this issue.

Signed-off-by: Nachiket Kukade <kukaden@marvell.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# d4902632 19-Aug-2015 Shengzhen Li <szli@marvell.com>

Bluetooth: btmrvl: change device pointer passed to dev_coredumpv

This change ensures we will get driver name as 'btmrvl_sdio'
in udev event.

Signed-off-by: Shengzhen Li <szli@marvell.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 4863e4cc 06-Aug-2015 Aniket Nagarnaik <aniketn@marvell.com>

Bluetooth: btmrvl: release sdio bus after firmware is up

We will not release sdio bus until firmware is completely
downloaded and becomes ready. Our 8887 A2 chip can have
separate firmware images for WLAN and bluetooth. This
patch fixes an issue observed when both drivers
simultaneously try to download respective firmwares.

Signed-off-by: Aniket Nagarnaik <aniketn@marvell.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# a1e85f04 21-Apr-2015 Xinming Hu <huxm@marvell.com>

Bluetooth: btmrvl: fix compilation warning

This patch fixes a compile warnning "dump_num maybe used uninitialized in
this function".

Signed-off-by: Xinming Hu <huxm@marvell.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 1c6098eb 01-Jan-2015 Amitkumar Karwar <akarwar@marvell.com>

bluetooth: btmrvl: increase the priority of firmware download message

When driver is loaded, it is important to know if FW was already
active or it is freshly downloaded. This patch increases the
priority of the message.

Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 7b4b8740 01-Jan-2015 Amitkumar Karwar <akarwar@marvell.com>

Bluetooth: btmrvl: add surprise_removed flag

This flag will be set in unload path to make sure that we skip
sending further commands, ignore interrupts and stop main thread
when unload starts.

Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# dc759613 24-Nov-2014 Xinming Hu <huxm@marvell.com>

Bluetooth: btmrvl add firmware dump support

This patch adds firmware dump support for marvell
bluetooth chipset. Currently only SD8897 is supported.
This is implemented based on dev_coredump, a new mechnism
introduced in kernel 3.18rc3

Firmware dump can be trigger by
echo 1 > /sys/kernel/debug/bluetooth/hci*/config/fw_dump
and when the dump operation is completed, data can be read by
cat /sys/class/devcoredump/devcd*/data

We have prepared following script to divide fw memory
dump data into multiple files based on memory type.

[root]# cat btmrvl_split_dump_data.sh
#!/bin/bash
# usage: ./btmrvl_split_dump_data.sh dump_data

fw_dump_data=$1

mem_type="ITCM DTCM SQRAM APU CIU ICU MAC EXT7 EXT8 EXT9 EXT10 EXT11 EXT12 EXT13 EXTLAST"

for name in ${mem_type[@]}
do
sed -n "/Start dump $name/,/End dump/p" $fw_dump_data > tmp.$name.log
if [ ! -s tmp.$name.log ]
then
rm -rf tmp.$name.log
else
# Remove the describle info "Start dump" and "End dump"
sed '1d' tmp.$name.log | sed '$d' > /data/$name.log
if [ -s /data/$name.log ]
then
echo "generate /data/$name.log"
else
sed '1d' tmp.$name.log | sed '$d' > /var/$name.log
echo "generate /var/$name.log"
fi
rm -rf tmp.$name.log
fi
done

Signed-off-by: Xinming Hu <huxm@marvell.com>
Signed-off-by: Cathy Luo <cluo@marvell.com>
Signed-off-by: Avinash Patil <patila@marvell.com>
Reviewed-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 7365d475 24-Nov-2014 Amitkumar Karwar <akarwar@marvell.com>

Bluetooth: btmrvl: remove extra newline character

BT_INFO/BT_DBG etc. already takes care of adding a newline
An extra newline character inside message is removed in this
patch.

Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 3907d558 30-Sep-2014 Xinming Hu <huxm@marvell.com>

Bluetooth: btmrvl: support Marvell Bluetooth device SD8887

This patch adds driver support for marvell SD8887 chip.

Signed-off-by: Xinming Hu <huxm@marvell.com>
Signed-off-by: Kevin Gan <ganhy@marvell.com>
Signed-off-by: Cathy Luo <cluo@marvell.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 1e3e492c 30-Sep-2014 Amitkumar Karwar <akarwar@marvell.com>

Bluetooth: btmrvl: rename definitions from 88xx to 8897

Register offsets are different for SD8897 and newer chip SD8887.
We can not have common btmrvl_sdio_card_reg map for them.

Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 5bf8a748 14-Jul-2014 Chin-Ran Lo <crlo@marvell.com>

Bluetooth: btmrvl: avoid sending data to firmware after hs_activated

We should suspend hci device and purge remaining data in tx queue
before enabling host sleep in firmware. If any data is sent to
firmware after host sleep is activated, firmware may end up
sending a TX_DONE interrupt to driver. If this interrupt gets
delivered to host while the SDIO host controller is suspending,
it may crash the system.

Conversely, in resume handler, we should resume hci device after
host sleep is de-activated.

Signed-off-by: Chin-Ran Lo <crlo@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 4df82b59 31-Mar-2014 Bing Zhao <bzhao@marvell.com>

Bluetooth: btmrvl: indicate pscan scheduling instant in a debug event

A vendor specific command is sent to firmware during
initialization to enable this feature. This command is for
SD8897 only.

Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 0d367408 28-Mar-2014 Bing Zhao <bzhao@marvell.com>

Bluetooth: btmrvl: implement read-to-clear for SD8897 interrupts

For SD8897, CMD52 write_to_clear may have missing interrupts
under certain corner case condition. Use CMD53 read-to-clear
to fix the problem.

Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 8af4840a 27-Mar-2014 Bing Zhao <bzhao@marvell.com>

Bluetooth: btmrvl: separate write-to-clear function from interrupt handler

This patch improves readability and makes future changes easier.

Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 433a9389 01-Nov-2013 Bing Zhao <bzhao@marvell.com>

Bluetooth: btmrvl: use cal-data from device-tree instead of conf file

Some ARM versions of Chromebook need to download a new calibration
data from host driver to firmware. They do have EEPROM but still
need a piece of new calibration data in test mode.

The cal-data is platform dependent. It's simpler and more feasible
to use device tree based cal-data instead of configuration file
based cal-data.

This patch remove configuration file based cal-data downloading
and replace it using cal-data from device tree.

When CONFIG_OF is not selected, or the specific property is not
present in the device tree, the calibration downloading will not
happen.

Cc: Mike Frysinger <vapier@chromium.org>
Cc: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Hyuckjoo Lee <hyuckjoo.lee@samsung.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# e1a26170 10-Oct-2013 Marcel Holtmann <marcel@holtmann.org>

Bluetooth: Provide hdev parameter to hci_recv_frame() driver callback

To avoid casting skb->dev into hdev, just let the drivers provide
the hdev directly when calling hci_recv_frame() function.

This patch also fixes up all drivers to provide the hdev.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>


# 2cc86890 01-Oct-2013 Amitkumar Karwar <akarwar@marvell.com>

Bluetooth: btmrvl: add calibration data download support

A text file containing calibration data in hex format can
be provided at following path:

/lib/firmware/mrvl/sd8797_caldata.conf

The data will be downloaded to firmware during initialization.

Reviewed-by: Mike Frysinger <vapier@chromium.org>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Hyuckjoo Lee <hyuckjoo.lee@samsung.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 4b245722 01-Oct-2013 Amitkumar Karwar <akarwar@marvell.com>

Bluetooth: btmrvl: add setup handler

Move initialization code to hdev's setup handler.

Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# ba34dd3d 02-Aug-2013 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Bluetooth: use DIV_ROUND_UP in suitable places in btmrvl_sdio

There are two places where DIV_ROUND_UP may be used. It makes code a bit
clearer.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>


# 6ea81c41 04-Jun-2013 Wei Yongjun <yongjun_wei@trendmicro.com.cn>

Bluetooth: btmrvl: fix error return code in btmrvl_sdio_card_to_host()

Fix to return -ENOMEM in the skb alloc error handling case
instead of 0, as done elsewhere in this function.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 22f2efed 13-May-2013 Bing Zhao <bzhao@marvell.com>

Bluetooth: btmrvl: support Marvell Bluetooth device SD8897

The register offsets have been changed in SD8897 and newer chips.
Define a new btmrvl_sdio_card_reg map for SD88xx.

Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Frank Huang <frankh@marvell.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 69676b1c 22-Apr-2013 Andreas Fenkart <andreas.fenkart@streamunlimited.com>

Bluetooth: btmrvl: report error if verify_fw_download times out

FW does the synchronization of the different modules during init.
It will report different modules, that it is ready at different times.
The fw download 'winner' will be reported fw ready first. Without this
patch, btmrvl was already continuing before the FW told it too. Probably
on behalf of the 'winner' which then never sees FW ready and times out.

Signed-off-by: Andreas Fenkart <andreas.fenkart@streamunlimited.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>


# c1c999e2 22-Apr-2013 Andreas Fenkart <andreas.fenkart@streamunlimited.com>

Bluetooth: btmrvl: release lock while waiting for fw download complete

If not winner, driver must release the sdio host lock, so the fw
download can progress. While holding the lock fw download is stalled
and the following error is produced:

[ 235.746015] Bluetooth: FW failed to be active in time!
[ 235.752799] Bluetooth: Downloading firmware failed!

Signed-off-by: Andreas Fenkart <andreas.fenkart@streamunlimited.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>


# faff7f74 18-Apr-2013 Gustavo Padovan <gustavo.padovan@collabora.co.uk>

Bluetooth: remove unneeded var initialization in btmrvl

There is no need to init ret to zero in btmrvl_sdio_download_fw().

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>


# 77189df4 12-Mar-2013 Lubomir Rintel <lkundrak@v3.sk>

bluetooth: btmrvl_sdio: look for sd8688 firmware in proper location

The firmware images are shared with libertas_sdio WiFi chip and used to be
in libertas/ subtree in linux-firmware. As btmrvl_sdio used to look into
the linux-firmware root, it ended up being unsuccessful. Since the
firmware files are not specific to the libertas hardware, they're being
moved into mrvl/ now.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>


# 78c1b8e8 10-Oct-2012 Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Bluetooth: btmrv: Use %*ph specifier instead of print_hex_dump_bytes

Use standard print specifier and remove print_hex_dump_bytes call.
Makes output more sensible:

...
[18809.401218] 00000000: 0b 00 00 fe 5b fc 01 f2 00 00 00 ....[......
...

would be changed to

...
[18809.401218] Bluetooth: hex: 0b 00 00 fe 5b fc 01 f2 00 00 00
...

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>


# 9cb23dd4 28-Sep-2012 Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Bluetooth: btmrvl: Fix skb buffer overflow

Add extra check to avoid skb buffer overflow. Fixes crash below:

[ 101.030427] ------------[ cut here ]------------
[ 101.030459] kernel BUG at net/core/skbuff.c:127!
[ 101.030486] invalid opcode: 0000 [#1] SMP
...
[ 101.030806] Pid: 2010, comm: btmrvl_main_ser Not tainted 3.5.0+ #80 Laptop
[ 101.030859] EIP: 0060:[<c14f2ba9>] EFLAGS: 00010282 CPU: 0
[ 101.030894] EIP is at skb_put+0x99/0xa0
[ 101.030919] EAX: 00000080 EBX: f129380b ECX: ef923540 EDX: 00000001
[ 101.030956] ESI: f00a4000 EDI: 00001003 EBP: ed4a5efc ESP: ed4a5ecc
[ 101.030992] DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
[ 101.031024] CR0: 8005003b CR2: 08fca014 CR3: 30960000 CR4: 000407f0
[ 101.031062] DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
[ 101.031100] DR6: ffff0ff0 DR7: 00000400
[ 101.031125] Process btmrvl_main_ser (pid: 2010, ti=ed4a4000 task=ef923540 task.ti=ed4a4000)
[ 101.031174] Stack:
[ 101.031188] c18126f8 c1651938 f853f8d2 00001003 00001003 f1292800 f1292808 f129380b
[ 101.031250] f1292940 f00a4000 eddb1280 efc0f9c0 ed4a5f44 f853f8d2 00000040 00000000
[ 101.031312] ef923540 c15ee096 ef923540 eddb12d4 00000004 f00a4000 00000040 00000000
[ 101.031376] Call Trace:
[ 101.031396] [<f853f8d2>] ? btmrvl_sdio_process_int_status+0x272/0x3d0 [btmrvl_sdio]
[ 101.031444] [<f853f8d2>] btmrvl_sdio_process_int_status+0x272/0x3d0 [btmrvl_sdio]
[ 101.031488] [<c15ee096>] ? _raw_spin_unlock_irqrestore+0x36/0x70
[ 101.031526] [<f85a46e4>] btmrvl_service_main_thread+0x244/0x300 [btmrvl]
[ 101.031568] [<f853fb50>] ? btmrvl_sdio_poll_card_status.isra.6.constprop.7+0x90/0x90 [btmrvl_sdio]
[ 101.031619] [<c107eda0>] ? try_to_wake_up+0x270/0x270
[ 101.031648] [<f85a44a0>] ? btmrvl_process_event+0x3b0/0x3b0 [btmrvl]
[ 101.031686] [<c106d19d>] kthread+0x7d/0x90
[ 101.031713] [<c106d120>] ? flush_kthread_work+0x150/0x150
[ 101.031745] [<c15f5a82>] kernel_thread_helper+0x6/0x10
...
[ 101.032008] EIP: [<c14f2ba9>] skb_put+0x99/0xa0 SS:ESP 0068:ed4a5ecc
[ 101.056125] ---[ end trace a0bd01d1a9a796c8 ]---

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>


# e678bad5 28-Sep-2012 Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Bluetooth: btmrvl: Use DIV_ROUND_UP macro

The kernel.h macro DIV_ROUND_UP performs the computation
(((n) + (d) - 1) / (d))

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>


# 42632805 28-Sep-2012 Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Bluetooth: btmrvl: Correct num_block name

Make code readable by correcting name from buf_block_len to num_blocks
since it represent number of blocks; NOT a length of a block buffer.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>


# 7923296f 28-Aug-2012 Wei Yongjun <yongjun_wei@trendmicro.com.cn>

Bluetooth: btmrvl: remove pointless conditional before kfree_skb()

Remove pointless conditional before kfree_skb().

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>


# eb17ea3b 26-Jul-2012 Sachin Kamat <sachin.kamat@linaro.org>

Bluetooth: Use devm_kzalloc in btmrvl_sdio.c file

devm_kzalloc() eliminates the need to free memory explicitly
thereby saving some cleanup code.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>


# 2c2453f3 09-Jul-2012 Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Bluetooth: btmrvl: trivial style fixes

Patch shortens locals scope and adds missing braces. This is a diff
between v1 which was applied and v2 of patch "Bluetooth: btmrvl: Do
not send vendor events to bluetooth stack".

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>


# ea1e76a3 13-Jun-2012 Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Bluetooth: btmrvl: Do not send vendor events to bluetooth stack

Vendor-specific events shall be processed in driver and not sent
to bluetooth stack where they screw up HCI command countings.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>


# 37ed561e 23-May-2012 Bing Zhao <bzhao@marvell.com>

Bluetooth: btmrvl: add SD8787 Bluetooth AMP device ID

SD8787 SDIO function 3 (device ID 0x911B) is for Bluetooth AMP.

Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>


# ba54a16f 25-Apr-2012 Amitkumar Karwar <akarwar@marvell.com>

Bluetooth: btmrvl: add support for SDIO suspend/resume callbacks

Host sleep is activated using already configured host sleep
parameters in suspend handler and it is cancelled in resume
handler.

Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>


# 2a8ff611 24-Apr-2012 Amitkumar Karwar <akarwar@marvell.com>

Bluetooth: btmrvl: configure default host sleep parameters

Currently debugfs commands "hscfgcmd" and "gpiogap" are provided
for host sleep configuration. But if user doesn't configure host
sleep parameters using these commands, host sleep activation is
failed during suspend (support for suspend and resume handlers is
added in next patch).

Default host sleep configuration is done during driver initialisation
in this patch.

Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>


# 59f34fb3 09-Apr-2012 Jesper Juhl <jj@chaosbits.net>

Bluetooth: btmrvl_sdio: remove pointless conditional before release_firmware()

release_firmware() deals gracefullt with NULL pointers so there's no
reason to test for one prior to calling the function.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>


# 2ac654f7 16-Nov-2011 Bing Zhao <bzhao@marvell.com>

Bluetooth: btmrvl: support Marvell Bluetooth device SD8797

The SD8797 firmware image is shared with mwifiex driver.
Whoever gets loaded first will be responsible for firmware
downloading.

Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Frank Huang <frankh@marvell.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>


# a59b968e 29-Aug-2011 Paul Gortmaker <paul.gortmaker@windriver.com>

bluetooth: add module.h to drivers/bluetooth files as required.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>


# c675786a 05-Oct-2011 Paul Bolle <pebolle@tiscali.nl>

btmrvl_sdio: fix typo 'btmrvl_sdio_sd6888'

It should be 'btmrvl_sdio_sd8688', of course.

Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 9f72c1d9 08-Apr-2011 Kevin Gan <ganhy@marvell.com>

Bluetooth: btmrvl: support Marvell Bluetooth device SD8787

The SD8787 firmware image is shared with mwifiex driver.
Whoever gets loaded first will be responsible for firmware
downloading.

Signed-off-by: Kevin Gan <ganhy@marvell.com>
Signed-off-by: Tristan Xu <xurf@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>


# f8df39f1 13-May-2010 Julia Lawall <julia@diku.dk>

Bluetooth: Use kzalloc for drivers

Use kzalloc rather than the combination of kmalloc and memset.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression x,size,flags;
statement S;
@@

-x = kmalloc(size,flags);
+x = kzalloc(size,flags);
if (x == NULL) S
-memset(x, 0, size);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Acked-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# d1d10d78 27-May-2010 Amitkumar Karwar <akarwar@marvell.com>

Bluetooth: Process interrupt in main thread of btmrvl driver as well

When driver is sending a command or data and the firmware is also
sending a sleep event, sometimes it is observed that driver will
continue to send the command/data to firmware right after processing
sleep event. Once sleep event is processed driver is not supposed to
send anything because firmware is in sleep state after that. Previously
interrupt processing was done in SDIO interrupt callback handler.
Now it is done in btmrvl driver main thread to solve the
cross-sending properly.

Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 278be27f 04-Jul-2010 Kulikov Vasiliy <segooon@gmail.com>

Bluetooth: Silence warning in btmrvl SDIO driver

Clone checking of ret to simplify the code.

This patch silences a compiler warning:
drivers/bluetooth/btmrvl_sdio.c: In function ‘btmrvl_sdio_verify_fw_download’:
drivers/bluetooth/btmrvl_sdio.c:80: warning: ‘fws1’ may be used uninitialized in this function
drivers/bluetooth/btmrvl_sdio.c:80: note: ‘fws1’ was declared here

Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
Reviewed-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 64061607 03-Mar-2010 Bing Zhao <bzhao@marvell.com>

Bluetooth: Separate btmrvl_register_hdev() from btmrvl_add_card()

Move btmrvl hdev registration code out of btmrvl_add_card().
New function btmrvl_register_hdev() is added.

Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 5a0e3ad6 24-Mar-2010 Tejun Heo <tj@kernel.org>

include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h

percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.

percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.

http://userweb.kernel.org/~tj/misc/slabh-sweep.py

The script does the followings.

* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.

* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.

* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.

The conversion was done in the following steps.

1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.

2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.

3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.

4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.

5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.

6. percpu.h was updated not to include slab.h.

7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).

* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig

8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.

Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.

Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>


# 8e5b2308 22-Dec-2009 Peter Huewe <peterhuewe@gmx.de>

Bluetooth: Add __init/__exit macros to Marvell SDIO driver

Trivial patch which adds the __init/__exit macros to the module_init/
module_exit functions of btmrvl_sdio.c driver.

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 88d1a0cf 03-Feb-2010 Yoichi Yuasa <yuasa@linux-mips.org>

Bluetooth: Fix memory leak in Marvell BT-over-SDIO driver

Signed-off-by: Yoichi Yuasa <yuasa@linux-mips.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# af901ca1 14-Nov-2009 André Goddard Rosa <andre.goddard@gmail.com>

tree-wide: fix assorted typos all over the place

That is "success", "unknown", "through", "performance", "[re|un]mapping"
, "access", "default", "reasonable", "[con]currently", "temperature"
, "channel", "[un]used", "application", "example","hierarchy", "therefore"
, "[over|under]flow", "contiguous", "threshold", "enough" and others.

Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 2861453b 07-Nov-2009 Ben Hutchings <ben@decadent.org.uk>

Bluetooth: Declare MODULE_FIRMWARE for Marvell SDIO driver

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 32fd6398 30-Sep-2009 Amitkumar Karwar <akarwar@marvell.com>

Bluetooth: Enable auto sleep mode for btmrvl driver

The auto sleep mode for btmrvl driver is not enabled by default.
This patch enables auto sleep mode when card is probed.

Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 5959809d 06-Aug-2009 Julia Lawall <julia@diku.dk>

Bluetooth: Add missing kmalloc NULL tests to Marvell driver

Check that the result of kmalloc is not NULL before dereferencing it.
The patch also replaces kmalloc + memset by kzalloc.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression *x;
identifier f;
constant char *C;
@@

x = \(kmalloc\|kcalloc\|kzalloc\)(...);
... when != x == NULL
when != x != NULL
when != (x || ...)
(
kfree(x)
|
f(...,C,...,x,...)
|
*f(...,x,...)
|
*x->f
)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 3318b236 08-Jul-2009 Bing Zhao <bzhao@marvell.com>

Bluetooth: Fix incorrect alignment in Marvell BT-over-SDIO driver

The driver uses "u32" for alignment check and calculation which
works only on 32-bit system. It will crash the 64-bit system.
Replace "u32" with "unsigned long" to fix this issue.

Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 9374253f 12-Jun-2009 Marcel Holtmann <marcel@holtmann.org>

Bluetooth: Remove Enter/Leave debug statements from Marvell driver

The Marvell Bluetooth driver is full of Enter/Leave debug statements and
all of them are really pointless and only clutter the code. Seems to be
some left-overs when they ported the driver from Windows. For the Linux
driver lets remove these.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 60dee5cc 09-Jun-2009 Marcel Holtmann <marcel@holtmann.org>

Bluetooth: Remove private device name of Marvell SDIO driver

For some reason the btmrvl_device struct has a name field that the SDIO
fills in, but then never ever uses again. That is totally pointless and
so just remove it.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 9666fb35 09-Jun-2009 Marcel Holtmann <marcel@holtmann.org>

Bluetooth: Fix module description strings for Marvell driver

Make the module description entries for the core and also the Marvell
SDIO driver match common practive inside the Bluetooth subsystem.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# dcf47f3b 09-Jun-2009 Marcel Holtmann <marcel@holtmann.org>

Bluetooth: Fix complicated assignment of firmware for Marvell devices

The Marvell Bluetooth SDIO driver has a really complicated concept on how
firmware names are assigned to specific device ids. Fix that by doing a
proper structure and assign it to the module device table.

And while at it fix various coding style weirdness that is still present
in this driver.

Signed-off-by: Marcel Holtman <marcel@holtmann.org>


# 789221ec 02-Jun-2009 Bing Zhao <bzhao@marvell.com>

Bluetooth: Add Marvell BT-over-SDIO driver

This driver supports Marvell Bluetooth enabled devices with SDIO
interface. Currently only SD8688 chip is supported.

The helper/firmware images of SD8688 can be downloaded from this tree:
git://git.infradead.org/users/dwmw2/linux-firmware.git

This patch incorporates a lot of comments given by
Nicolas Pitre <nico@marvell.com>. Many thanks to Nicolas Pitre.

Signed-off-by: Rahul Tank <rahult@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>