* [PATCHv1 1/5] Bluetooth: board support for pm_limits
2010-10-01 12:47 [PATCHv1 0/5] Bluetooth: experimental support for pm_limits Emeltchenko Andrei
@ 2010-10-01 12:47 ` Emeltchenko Andrei
2010-10-01 12:47 ` [PATCHv1 2/5] Bluetooth: rm581: pm constraints support Emeltchenko Andrei
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Emeltchenko Andrei @ 2010-10-01 12:47 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
---
arch/arm/plat-omap/include/plat/board-nokia.h | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/arch/arm/plat-omap/include/plat/board-nokia.h b/arch/arm/plat-omap/include/plat/board-nokia.h
index 62718e5..489466d 100644
--- a/arch/arm/plat-omap/include/plat/board-nokia.h
+++ b/arch/arm/plat-omap/include/plat/board-nokia.h
@@ -55,6 +55,7 @@ struct omap_bluetooth_config {
u8 bt_uart;
u8 bd_addr[6];
u8 bt_sysclk;
+ void (*set_pm_limits)(struct device *dev, bool set);
};
struct omap_wlan_cx3110x_config {
--
1.7.0.4
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCHv1 2/5] Bluetooth: rm581: pm constraints support
2010-10-01 12:47 [PATCHv1 0/5] Bluetooth: experimental support for pm_limits Emeltchenko Andrei
2010-10-01 12:47 ` [PATCHv1 1/5] Bluetooth: board " Emeltchenko Andrei
@ 2010-10-01 12:47 ` Emeltchenko Andrei
2010-10-01 12:47 ` [PATCHv1 3/5] Bluetooth: rm680: " Emeltchenko Andrei
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Emeltchenko Andrei @ 2010-10-01 12:47 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
Add pm_limits callback
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
---
arch/arm/mach-omap2/board-rm581-peripherals.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-omap2/board-rm581-peripherals.c b/arch/arm/mach-omap2/board-rm581-peripherals.c
index 4e98c6b..673f270 100644
--- a/arch/arm/mach-omap2/board-rm581-peripherals.c
+++ b/arch/arm/mach-omap2/board-rm581-peripherals.c
@@ -45,6 +45,7 @@
#include <plat/mmc.h>
#include <plat/board-nokia.h>
#include <plat/ssi.h>
+#include <plat/omap-pm.h>
#include "hsmmc.h"
@@ -1124,6 +1125,12 @@ static int __init rm581_i2c_init(void)
return 0;
}
+/* Use wakeup latency only for now */
+static void rm581_bt_set_pm_limits(struct device *dev, bool set)
+{
+ omap_pm_set_max_mpu_wakeup_lat(dev, set ? 10 : -1);
+}
+
static struct omap_bluetooth_config rm581_bt_config = {
.chip_type = BT_CHIP_TI,
.bt_wakeup_gpio = 37,
@@ -1131,6 +1138,7 @@ static struct omap_bluetooth_config rm581_bt_config = {
.reset_gpio = 26,
.bt_uart = 2,
.bt_sysclk = BT_SYSCLK_38_4,
+ .set_pm_limits = rm581_bt_set_pm_limits,
};
static struct omap_ssi_board_config __initdata rm581_ssi_config = {
--
1.7.0.4
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCHv1 3/5] Bluetooth: rm680: pm constraints support
2010-10-01 12:47 [PATCHv1 0/5] Bluetooth: experimental support for pm_limits Emeltchenko Andrei
2010-10-01 12:47 ` [PATCHv1 1/5] Bluetooth: board " Emeltchenko Andrei
2010-10-01 12:47 ` [PATCHv1 2/5] Bluetooth: rm581: pm constraints support Emeltchenko Andrei
@ 2010-10-01 12:47 ` Emeltchenko Andrei
2010-10-01 12:47 ` [PATCHv1 4/5] Bluetooth: rm696: " Emeltchenko Andrei
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Emeltchenko Andrei @ 2010-10-01 12:47 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
Add pm_limits callback
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
---
arch/arm/mach-omap2/board-rm680-peripherals.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-omap2/board-rm680-peripherals.c b/arch/arm/mach-omap2/board-rm680-peripherals.c
index a8b03f0..94dde4c 100644
--- a/arch/arm/mach-omap2/board-rm680-peripherals.c
+++ b/arch/arm/mach-omap2/board-rm680-peripherals.c
@@ -50,6 +50,7 @@
#include <plat/board-nokia.h>
#include <plat/mmc.h>
#include <plat/ssi.h>
+#include <plat/omap-pm.h>
#include "hsmmc.h"
#include "board-gpio-export.h"
#include "board-rm680-types.h"
@@ -1323,6 +1324,12 @@ static int __init rm680_i2c_init(void)
return 0;
}
+/* Use wakeup latency only for now */
+static void rm680_bt_set_pm_limits(struct device *dev, bool set)
+{
+ omap_pm_set_max_mpu_wakeup_lat(dev, set ? 10 : -1);
+}
+
static struct omap_bluetooth_config rm680_bt_config = {
.chip_type = BT_CHIP_TI,
.bt_wakeup_gpio = 37,
@@ -1330,6 +1337,7 @@ static struct omap_bluetooth_config rm680_bt_config = {
.reset_gpio = 26,
.bt_uart = 2,
.bt_sysclk = BT_SYSCLK_38_4,
+ .set_pm_limits = rm680_bt_set_pm_limits,
};
static struct omap_ssi_board_config __initdata rm680_ssi_config = {
--
1.7.0.4
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCHv1 4/5] Bluetooth: rm696: pm constraints support
2010-10-01 12:47 [PATCHv1 0/5] Bluetooth: experimental support for pm_limits Emeltchenko Andrei
` (2 preceding siblings ...)
2010-10-01 12:47 ` [PATCHv1 3/5] Bluetooth: rm680: " Emeltchenko Andrei
@ 2010-10-01 12:47 ` Emeltchenko Andrei
2010-10-01 12:47 ` [PATCHv1 5/5] Bluetooth: pm constraints in bt transfer mode Emeltchenko Andrei
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Emeltchenko Andrei @ 2010-10-01 12:47 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
Add pm_limits callback
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
---
arch/arm/mach-omap2/board-rm696-peripherals.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-omap2/board-rm696-peripherals.c b/arch/arm/mach-omap2/board-rm696-peripherals.c
index 5bc416a..5ee7667 100644
--- a/arch/arm/mach-omap2/board-rm696-peripherals.c
+++ b/arch/arm/mach-omap2/board-rm696-peripherals.c
@@ -49,6 +49,7 @@
#include <plat/board-nokia.h>
#include <plat/ssi.h>
#include <plat/mmc.h>
+#include <plat/omap-pm.h>
#include "hsmmc.h"
#include "board-gpio-export.h"
#include "twl4030.h"
@@ -1337,6 +1338,12 @@ static int __init rm696_i2c_init(void)
return 0;
}
+/* Use wakeup latency only for now */
+static void rm696_bt_set_pm_limits(struct device *dev, bool set)
+{
+ omap_pm_set_max_mpu_wakeup_lat(dev, set ? 10 : -1);
+}
+
static struct omap_bluetooth_config rm696_bt_config = {
.chip_type = BT_CHIP_TI,
.bt_wakeup_gpio = 37,
@@ -1344,6 +1351,7 @@ static struct omap_bluetooth_config rm696_bt_config = {
.reset_gpio = 26,
.bt_uart = 2,
.bt_sysclk = BT_SYSCLK_38_4,
+ .set_pm_limits = rm696_bt_set_pm_limits,
};
static struct omap_ssi_board_config __initdata rm696_ssi_config = {
--
1.7.0.4
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCHv1 5/5] Bluetooth: pm constraints in bt transfer mode
2010-10-01 12:47 [PATCHv1 0/5] Bluetooth: experimental support for pm_limits Emeltchenko Andrei
` (3 preceding siblings ...)
2010-10-01 12:47 ` [PATCHv1 4/5] Bluetooth: rm696: " Emeltchenko Andrei
@ 2010-10-01 12:47 ` Emeltchenko Andrei
2010-10-01 12:50 ` [PATCHv1 0/5] Bluetooth: experimental support for pm_limits Andrei Emeltchenko
2010-10-05 7:49 ` Marcel Holtmann
6 siblings, 0 replies; 8+ messages in thread
From: Emeltchenko Andrei @ 2010-10-01 12:47 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
When entering BT transfer mode set up pm limits using constraints
to achive maximum BT throughput.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
---
drivers/bluetooth/hci_h4p/core.c | 92 ++++++++++++++++++++++++++++++++++-
drivers/bluetooth/hci_h4p/hci_h4p.h | 1 +
2 files changed, 92 insertions(+), 1 deletions(-)
diff --git a/drivers/bluetooth/hci_h4p/core.c b/drivers/bluetooth/hci_h4p/core.c
index 74e6cfe..10cf8a4 100644
--- a/drivers/bluetooth/hci_h4p/core.c
+++ b/drivers/bluetooth/hci_h4p/core.c
@@ -35,6 +35,7 @@
#include <linux/interrupt.h>
#include <linux/gpio.h>
#include <linux/timer.h>
+#include <linux/kthread.h>
#include <mach/hardware.h>
#include <mach/irqs.h>
@@ -45,6 +46,10 @@
#include "hci_h4p.h"
+#define H4P_SCHED_TRANSFER_MODE 1
+
+static struct task_struct *h4p_thread;
+
/* This should be used in function that cannot release clocks */
static void hci_h4p_set_clk(struct hci_h4p_info *info, int *clock, int enable)
{
@@ -105,6 +110,17 @@ void hci_h4p_smart_idle(struct hci_h4p_info *info, bool enable)
hci_h4p_outb(info, UART_OMAP_SYSC, v);
}
+static inline void h4p_schedule(struct hci_h4p_info *info, uint event)
+{
+ if (unlikely(!h4p_thread))
+ return;
+
+ if (unlikely(!test_bit(event, &info->event))) {
+ set_bit(event, &info->event);
+ wake_up_process(h4p_thread);
+ }
+}
+
static void hci_h4p_disable_tx(struct hci_h4p_info *info)
{
NBT_DBG_POWER("\n");
@@ -128,6 +144,8 @@ void hci_h4p_enable_tx(struct hci_h4p_info *info)
if (!info->pm_enabled)
return;
+ h4p_schedule(info, H4P_SCHED_TRANSFER_MODE);
+
spin_lock_irqsave(&info->lock, flags);
del_timer(&info->lazy_release);
hci_h4p_set_clk(info, &info->tx_clocks_en, 1);
@@ -167,6 +185,8 @@ static void hci_h4p_enable_rx(struct hci_h4p_info *info)
if (!info->pm_enabled)
return;
+ h4p_schedule(info, H4P_SCHED_TRANSFER_MODE);
+
hci_h4p_set_clk(info, &info->rx_clocks_en, 1);
info->rx_enabled = 1;
@@ -613,6 +633,68 @@ static irqreturn_t hci_h4p_wakeup_interrupt(int irq, void *dev_inst)
return IRQ_HANDLED;
}
+static inline void __hci_h4p_change_pm_constraints(struct hci_h4p_info *info,
+ bool set)
+{
+ struct omap_bluetooth_config *bt_config = info->dev->platform_data;
+
+ if (likely(bt_config && bt_config->set_pm_limits)) {
+ BT_DBG("Change pm constraints to: %s", set ? "set" : "clear");
+ bt_config->set_pm_limits(info->dev, set);
+ }
+}
+
+static int h4p_run(void *data)
+{
+#define TIMEOUT_MIN msecs_to_jiffies(100)
+#define TIMEOUT_MAX msecs_to_jiffies(2000)
+ struct hci_h4p_info *info = data;
+ unsigned long last_jiffies = jiffies;
+ unsigned long timeout = TIMEOUT_MIN;
+ BT_DBG("");
+ set_user_nice(current, -10);
+
+ while (!kthread_should_stop()) {
+ set_current_state(TASK_INTERRUPTIBLE);
+ if (!test_bit(H4P_SCHED_TRANSFER_MODE, &info->event)) {
+ /* No pending events. Let's sleep.
+ * Incoming connections and data will wake us up. */
+ BT_DBG("Nothing to do... sleeping.");
+ schedule();
+ }
+
+ BT_DBG("Wake up. %u msec expired since last BT activity.",
+ jiffies_to_msecs(jiffies - last_jiffies));
+
+ /* Empiric analyzer :-) */
+ if (jiffies - last_jiffies < TIMEOUT_MIN) {
+ timeout <<= 1;
+ timeout = (timeout > TIMEOUT_MAX) ?
+ TIMEOUT_MAX : timeout;
+ } else {
+ timeout >>= 1;
+ timeout = (timeout < TIMEOUT_MIN) ?
+ TIMEOUT_MIN : timeout;
+ }
+
+ __hci_h4p_change_pm_constraints(info, true);
+
+ BT_DBG("Set active mode for %u msec.",
+ jiffies_to_msecs(timeout));
+
+ set_current_state(TASK_INTERRUPTIBLE);
+ schedule_timeout(timeout);
+
+ __hci_h4p_change_pm_constraints(info, false);
+
+ clear_bit(H4P_SCHED_TRANSFER_MODE, &info->event);
+ last_jiffies = jiffies;
+ BT_DBG("Return from active mode. Restore constraints.");
+ }
+
+ return 0;
+}
+
static int hci_h4p_reset(struct hci_h4p_info *info)
{
int err;
@@ -835,6 +917,8 @@ static int hci_h4p_hci_close(struct hci_dev *hdev)
if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))
return 0;
+ __hci_h4p_change_pm_constraints(info, false);
+
hci_h4p_hci_flush(hdev);
hci_h4p_set_clk(info, &info->tx_clocks_en, 1);
hci_h4p_set_clk(info, &info->rx_clocks_en, 1);
@@ -942,7 +1026,7 @@ static int hci_h4p_register_hdev(struct hci_h4p_info *info)
return 0;
}
-static int hci_h4p_probe(struct platform_device *pdev)
+static int __init hci_h4p_probe(struct platform_device *pdev)
{
struct omap_bluetooth_config *bt_config;
struct hci_h4p_info *info;
@@ -1104,6 +1188,12 @@ static int hci_h4p_probe(struct platform_device *pdev)
goto cleanup_irq;
}
+ h4p_thread = kthread_run(h4p_run, info, "h4p_pm");
+ if (IS_ERR(h4p_thread)) {
+ err = PTR_ERR(h4p_thread);
+ goto cleanup_irq;
+ }
+
return 0;
cleanup_irq:
diff --git a/drivers/bluetooth/hci_h4p/hci_h4p.h b/drivers/bluetooth/hci_h4p/hci_h4p.h
index cd72bba..7d7a0fa 100644
--- a/drivers/bluetooth/hci_h4p/hci_h4p.h
+++ b/drivers/bluetooth/hci_h4p/hci_h4p.h
@@ -98,6 +98,7 @@ struct hci_h4p_info {
int tx_enabled;
int autorts;
int rx_enabled;
+ unsigned long event;
int tx_clocks_en;
int rx_clocks_en;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCHv1 0/5] Bluetooth: experimental support for pm_limits
2010-10-01 12:47 [PATCHv1 0/5] Bluetooth: experimental support for pm_limits Emeltchenko Andrei
` (4 preceding siblings ...)
2010-10-01 12:47 ` [PATCHv1 5/5] Bluetooth: pm constraints in bt transfer mode Emeltchenko Andrei
@ 2010-10-01 12:50 ` Andrei Emeltchenko
2010-10-05 7:49 ` Marcel Holtmann
6 siblings, 0 replies; 8+ messages in thread
From: Andrei Emeltchenko @ 2010-10-01 12:50 UTC (permalink / raw)
To: linux-bluetooth
On Fri, Oct 1, 2010 at 3:47 PM, Emeltchenko Andrei
<Andrei.Emeltchenko.news@gmail.com> wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
>
> First version of using power constraints interface to achieve
> maximum bluetooth transfer speed. Otherwise HW goes to idle mode
> and speed decreases 3 times.
>
> Use empirical power management analyzer (TM) to define amount
> of time device set high power constraints for.
>
> May include hacks :-)
>
> Andrei Emeltchenko (5):
> Bluetooth: board support for pm_limits
> Bluetooth: rm581: pm constraints support
> Bluetooth: rm680: pm constraints support
> Bluetooth: rm696: pm constraints support
> Bluetooth: pm constraints in bt transfer mode
>
> arch/arm/mach-omap2/board-rm581-peripherals.c | 8 ++
> arch/arm/mach-omap2/board-rm680-peripherals.c | 8 ++
> arch/arm/mach-omap2/board-rm696-peripherals.c | 8 ++
> arch/arm/plat-omap/include/plat/board-nokia.h | 1 +
> drivers/bluetooth/hci_h4p/core.c | 92 ++++++++++++++++++++++++-
> drivers/bluetooth/hci_h4p/hci_h4p.h | 1 +
> 6 files changed, 117 insertions(+), 1 deletions(-)
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
Sorry our driver is not in upstream yet.
Please discard.
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCHv1 0/5] Bluetooth: experimental support for pm_limits
2010-10-01 12:47 [PATCHv1 0/5] Bluetooth: experimental support for pm_limits Emeltchenko Andrei
` (5 preceding siblings ...)
2010-10-01 12:50 ` [PATCHv1 0/5] Bluetooth: experimental support for pm_limits Andrei Emeltchenko
@ 2010-10-05 7:49 ` Marcel Holtmann
6 siblings, 0 replies; 8+ messages in thread
From: Marcel Holtmann @ 2010-10-05 7:49 UTC (permalink / raw)
To: Emeltchenko Andrei; +Cc: linux-bluetooth
Hi Andrei,
> First version of using power constraints interface to achieve
> maximum bluetooth transfer speed. Otherwise HW goes to idle mode
> and speed decreases 3 times.
>
> Use empirical power management analyzer (TM) to define amount
> of time device set high power constraints for.
>
> May include hacks :-)
please send these as [RFC] and not as [PATCH] if they are meant for
review.
Regards
Marcel
^ permalink raw reply [flat|nested] 8+ messages in thread