From patchwork Mon Jan 12 17:00:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pantelis Antoniou X-Patchwork-Id: 427851 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 1FEB6140146 for ; Tue, 13 Jan 2015 04:00:58 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750978AbbALRA5 (ORCPT ); Mon, 12 Jan 2015 12:00:57 -0500 Received: from mail-wi0-f181.google.com ([209.85.212.181]:35675 "EHLO mail-wi0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750863AbbALRA4 (ORCPT ); Mon, 12 Jan 2015 12:00:56 -0500 Received: by mail-wi0-f181.google.com with SMTP id hi2so8359wib.2 for ; Mon, 12 Jan 2015 09:00:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=FA9za5hcc6L5OwugHlGdVGxZBjfwZAxNI1MXbHzYWMA=; b=eyLyND7GTPNWBuQh9COxVxPFHfxgVLTrogjCJyEQ46kfUM48ulRia2Ix0e4nO0sXuT 4yCYUsa4dui5mRLeJpOUXzMv2KCRn+/J27YbiZNtfXKJbMyO0RS2TAoNUyg+YDN6G3If 4lXkZYDgf2pAn1Ov+uheDz4stFFsVWVcKqezYg9hbNvej25JXKncvTmzb07XUF1h+r/t EVz3rYIPzIzVJ2GSBj0wK7J+xXCot9GkMIa13Yl5bHNLj0yUA+zkcAVNfarBouMV+cad ZFwbu1MoanWei+t0ukWgrBeutaBpDbpHsS1/foGLLdkBSXrDBU8evhP4RPPB0gnZncsL cIYQ== X-Gm-Message-State: ALoCoQkGG1emfhsPndc/h2q3MwrUWWNNuJcWH9sEvMeodhJmOxWvWmfob4ISirrC0vO9dW89VycE X-Received: by 10.194.84.240 with SMTP id c16mr32113990wjz.74.1421082055179; Mon, 12 Jan 2015 09:00:55 -0800 (PST) Received: from sles11esa.localdomain ([195.97.110.117]) by mx.google.com with ESMTPSA id r3sm10917811wic.10.2015.01.12.09.00.53 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 12 Jan 2015 09:00:54 -0800 (PST) From: Pantelis Antoniou To: Wolfram Sang Cc: Guenter Roeck , Matt Porter , Greg Kroah-Hartman , Grant Likely , linux-i2c@vger.kernel.org, Pantelis Antoniou , Pantelis Antoniou Subject: [PATCH] [RFC] i2c: Don't wait for device release in i2c_del_adapter Date: Mon, 12 Jan 2015 19:00:50 +0200 Message-Id: <1421082050-10213-1-git-send-email-pantelis.antoniou@konsulko.com> X-Mailer: git-send-email 1.7.12 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Waiting for the device release method to be called when going through i2c_del_adapter is wrong and leads to deadlock when removing an i2c mux device. For instance when using the OF i2c mux unitest removal we get this. [] (__schedule) from [] (schedule_timeout+0x18/0x198) [] (schedule_timeout) from [] (wait_for_common+0xf8/0x138) [] (wait_for_common) from [] (i2c_del_adapter+0x174/0x1cc) [] (i2c_del_adapter) from [] (i2c_del_mux_adapter+0x48/0x60) [] (i2c_del_mux_adapter) from [] (selftest_i2c_mux_remove+0x28/0x34) [] (selftest_i2c_mux_remove) from [] (i2c_device_remove+0x34/0x70) [] (i2c_device_remove) from [] (__device_release_driver+0x7c/0xc0) [] (__device_release_driver) from [] (driver_detach+0x8c/0xb4) [] (driver_detach) from [] (bus_remove_driver+0x64/0x8c) [] (bus_remove_driver) from [] (of_selftest+0x1f84/0x20f0) [] (of_selftest) from [] (do_one_initcall+0x104/0x1b4) [] (do_one_initcall) from [] (kernel_init_freeable+0x110/0x1d8) [] (kernel_init_freeable) from [] (kernel_init+0x8/0xe4) [] (kernel_init) from [] (ret_from_fork+0x14/0x3c) 2 locks held by swapper/0/1: #0: (&dev->mutex){......}, at: [] driver_detach+0x68/0xb4 #1: (&dev->mutex){......}, at: [] driver_detach+0x78/0xb4 Kernel panic - not syncing: hung_task: blocked tasks CPU: 0 PID: 16 Comm: khungtaskd Not tainted 3.19.0-rc4-00022-g261647c #443 Hardware name: Generic AM33XX (Flattened Device Tree) [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [] (show_stack) from [] (dump_stack+0x70/0x8c) [] (dump_stack) from [] (panic+0x88/0x1f0) [] (panic) from [] (watchdog+0x2d4/0x350) [] (watchdog) from [] (kthread+0xd8/0xec) [] (kthread) from [] (ret_from_fork+0x14/0x3c) The device release method is never called and we hang waiting for it. This patch is marked as an [RFC] since the original code seems to really want to protect against a race from sysfs accessors, which I don't see how it could be a problem. Signed-off-by: Pantelis Antoniou --- drivers/i2c/i2c-core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 39d25a8..e020a16 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -1185,7 +1185,7 @@ EXPORT_SYMBOL_GPL(i2c_new_dummy); static void i2c_adapter_dev_release(struct device *dev) { struct i2c_adapter *adap = to_i2c_adapter(dev); - complete(&adap->dev_released); + /* XXX complete(&adap->dev_released); */ } /* @@ -1797,11 +1797,11 @@ void i2c_del_adapter(struct i2c_adapter *adap) dev_dbg(&adap->dev, "adapter [%s] unregistered\n", adap->name); /* clean up the sysfs representation */ - init_completion(&adap->dev_released); + /* XXX init_completion(&adap->dev_released); */ device_unregister(&adap->dev); /* wait for sysfs to drop all references */ - wait_for_completion(&adap->dev_released); + /* XXX wait_for_completion(&adap->dev_released); */ /* free bus id */ mutex_lock(&core_lock);