Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752767AbaBXNYQ (ORCPT ); Mon, 24 Feb 2014 08:24:16 -0500 Received: from ring0.de ([5.45.105.125]:35673 "EHLO smtp.ring0.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752658AbaBXNYK (ORCPT ); Mon, 24 Feb 2014 08:24:10 -0500 X-Spam-Report: * -0.0 NO_RELAYS Informational: message was not relayed via SMTP * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * -0.0 NO_RECEIVED Informational: message has no Received headers From: Sebastian Reichel To: Sebastian Reichel , Dmitry Eremin-Solenikov , David Woodhouse Cc: =?UTF-8?q?Pali=20Roh=C3=A1r?= , linux-kernel@vger.kernel.org, Sebastian Reichel Subject: [PATCH] bq2415x_charger: Fix Atomic Sleep Bug Date: Mon, 24 Feb 2014 14:23:58 +0100 Message-Id: <1393248238-995-1-git-send-email-sre@debian.org> X-Mailer: git-send-email 1.8.5.3 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move sysfs_notify and i2c_transfer calls from bq2415x_notifier_call to bq2415x_timer_work to avoid sleeping in atomic context. This fixes the following bug: [ 7.667449] Workqueue: events power_supply_changed_work [ 7.673034] [] (unwind_backtrace+0x0/0xe0) from [] (show_stack+0x10/0x14) [ 7.682098] [] (show_stack+0x10/0x14) from [] (dump_stack+0x78/0xac) [ 7.690704] [] (dump_stack+0x78/0xac) from [] (__schedule_bug+0x48/0x60) [ 7.699645] [] (__schedule_bug+0x48/0x60) from [] (__schedule+0x74/0x638) [ 7.708618] [] (__schedule+0x74/0x638) from [] (schedule_timeout+0x1dc/0x24c) [ 7.718017] [] (schedule_timeout+0x1dc/0x24c) from [] (wait_for_common+0x138/0x17c) [ 7.727966] [] (wait_for_common+0x138/0x17c) from [] (omap_i2c_xfer+0x340/0x4a0) [ 7.737640] [] (omap_i2c_xfer+0x340/0x4a0) from [] (__i2c_transfer+0x40/0x74) [ 7.747039] [] (__i2c_transfer+0x40/0x74) from [] (i2c_transfer+0x6c/0x90) [ 7.756195] [] (i2c_transfer+0x6c/0x90) from [] (bq2415x_i2c_write+0x48/0x78) [ 7.765563] [] (bq2415x_i2c_write+0x48/0x78) from [] (bq2415x_set_weak_battery_voltage+0x4c/0x50) [ 7.776824] [] (bq2415x_set_weak_battery_voltage+0x4c/0x50) from [] (bq2415x_set_mode+0xdc/0x14c) [ 7.788085] [] (bq2415x_set_mode+0xdc/0x14c) from [] (bq2415x_notifier_call+0xa8/0xb4) [ 7.798309] [] (bq2415x_notifier_call+0xa8/0xb4) from [] (notifier_call_chain+0x38/0x68) [ 7.808715] [] (notifier_call_chain+0x38/0x68) from [] (__atomic_notifier_call_chain+0x2c/0x3c) [ 7.819732] [] (__atomic_notifier_call_chain+0x2c/0x3c) from [] (atomic_notifier_call_chain+0x14/0x18) [ 7.831420] [] (atomic_notifier_call_chain+0x14/0x18) from [] (power_supply_changed_work+0x6c/0xb8) [ 7.842864] [] (power_supply_changed_work+0x6c/0xb8) from [] (process_one_work+0x248/0x440) [ 7.853546] [] (process_one_work+0x248/0x440) from [] (worker_thread+0x208/0x350) [ 7.863372] [] (worker_thread+0x208/0x350) from [] (kthread+0xc8/0xdc) [ 7.872131] [] (kthread+0xc8/0xdc) from [] (ret_from_fork+0x14/0x3c) Signed-off-by: Sebastian Reichel --- Hi Dmitry, I think this patch should be applied to 3.14-rc. -- Sebastian --- drivers/power/bq2415x_charger.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/power/bq2415x_charger.c b/drivers/power/bq2415x_charger.c index 79a37f6..8bf14fc 100644 --- a/drivers/power/bq2415x_charger.c +++ b/drivers/power/bq2415x_charger.c @@ -840,8 +840,7 @@ static int bq2415x_notifier_call(struct notifier_block *nb, if (bq->automode < 1) return NOTIFY_OK; - sysfs_notify(&bq->charger.dev->kobj, NULL, "reported_mode"); - bq2415x_set_mode(bq, bq->reported_mode); + schedule_delayed_work(&bq->work, 0); return NOTIFY_OK; } @@ -892,6 +891,11 @@ static void bq2415x_timer_work(struct work_struct *work) int error; int boost; + if (bq->automode == 1 && (bq->reported_mode != bq->mode)) { + sysfs_notify(&bq->charger.dev->kobj, NULL, "reported_mode"); + bq2415x_set_mode(bq, bq->reported_mode); + } + if (!bq->autotimer) return; -- 1.8.5.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/