From patchwork Wed Jul 5 09:12:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 107053 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp578492obb; Wed, 5 Jul 2017 02:12:50 -0700 (PDT) X-Received: by 10.98.53.134 with SMTP id c128mr19404856pfa.36.1499245970586; Wed, 05 Jul 2017 02:12:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499245970; cv=none; d=google.com; s=arc-20160816; b=aeomfNAjX0EDHh8yAOYWSg2Mazg9FOW2ALbEmIHTgSZVQ438ybQTacNfbONEgsS/y+ bAxf9WT09109ELGbCu2UqpwWhy6cIyBYXo8rUyxRWd4JQP+Pl9jZ4WVRS+7C63ZS97+h 1bLMq0lHkGbsiLo+8TucUIaS39XowcJpvKzhFyYx7ysirBWZi6IKZv4imzlAuqR2pY5z hQSJGQ19fgDDaJN3rWn4K5SfFnyTL6u4skC1KF6WzYm2ZnCpNV8toKEL26/lxJrQwTSk +1/UR/zZLcBfltFpapJmsTg39efCVv+njRehiFNByVnOlmtwXccgC4lTHpbYNMFjeYeL yZ3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=nQfHp1Y+tWLwAIjqh3GqPDb/GSHrHbtCHlNo5y3NOVc=; b=q94r2bpG4xee0LkJ5988H1K5xiK5xmJ67QFOIgOaZUrisfG0BBNpFRPykW/3UT2txm jxGbIaBBCPCs3ywo/J0DL3ptuVSYOkQqb45LNTwB3IiYJcouQauT8ENk2M5BCcF0dzNa 27MFxFoVlTM7tH+qmpC55GvczuqZToRD1uPFGMjua7HTYyK+MZWiQFMdu2EpS3rkxUna CKa2reOfN71646QLzXnGpTDXOk+oowEU39wMcwY4jcbI9Xs/aXdmHjSQvKKqCmwC1pEa oHMYX9P+yO8WJXJs3MHY/GOjAIzfitojg9QRDEA4E6mrjA4DfizBuIKFEc90MjpX5Hd8 POtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=ibJK1VvK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c1si16139028pgn.109.2017.07.05.02.12.50; Wed, 05 Jul 2017 02:12:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=ibJK1VvK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752451AbdGEJMm (ORCPT + 25 others); Wed, 5 Jul 2017 05:12:42 -0400 Received: from mail-io0-f179.google.com ([209.85.223.179]:34403 "EHLO mail-io0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751599AbdGEJMk (ORCPT ); Wed, 5 Jul 2017 05:12:40 -0400 Received: by mail-io0-f179.google.com with SMTP id r36so82451718ioi.1 for ; Wed, 05 Jul 2017 02:12:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=nQfHp1Y+tWLwAIjqh3GqPDb/GSHrHbtCHlNo5y3NOVc=; b=ibJK1VvKDWHVcjCFug6Ko0km2zxtRLqsz7vscPqAmQemlqPQq/UsQV+z/ES90VnioX HKnhROa6QtBik84dU8elkJKzMHlOcemxRlUT2Tdxy9Pcjtj/1ccYWE1medGvymGiV4VT nI4Xnow3vgqdikCqwLJIiknWprA7gZFciONdg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=nQfHp1Y+tWLwAIjqh3GqPDb/GSHrHbtCHlNo5y3NOVc=; b=YEJEW67a4WGAO2kVf8Bz0LsCPmVBNq7WpSPiP8qs/mZmleQYRKrE9ciWzd28Hy5bno NLB1fLjnfyJEjAWBm9jJ5VkS6l/Y+pafC0dL5/Uns79YVq0hnaxMfrv4wLjV55B1n3ju 6swy0G8lD8/kE/Xakarl3qFJ1/GKu9yDPL69dTOj9oxwdAryy9ugcCIAbK3TcQh5O9WY o3wC9aSklSTXyw+c/3yRA6UCUAoyMUnQeP4OJduOfUFAvgmtDgmS4C3/0i3Hf/MikwjJ qsWvZ98FPP5I2jjWucY43ak0RtrcG5HPPyxXv9ZFPDNN2cDxPtvXvV66wEKq0HC3vUxx Li5g== X-Gm-Message-State: AKS2vOzaaDLCecw+9v+L3Qw3IQWerK/4pyL+ilD03PgaSW9ZLc8TOq57 xM9HsT3L2bMr3qpQ X-Received: by 10.107.137.68 with SMTP id l65mr40558976iod.13.1499245959958; Wed, 05 Jul 2017 02:12:39 -0700 (PDT) Received: from localhost.localdomain (static.8.26.4.46.clients.your-server.de. [46.4.26.8]) by smtp.gmail.com with ESMTPSA id 131sm12737832itk.10.2017.07.05.02.12.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 05 Jul 2017 02:12:39 -0700 (PDT) From: srinivas.kandagatla@linaro.org To: rafael.j.wysocki@intel.com, Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [RFC PATCH] driver core: purge device links after device release updates link state. Date: Wed, 5 Jul 2017 11:12:28 +0200 Message-Id: <20170705091228.6942-1-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Srinivas Kandagatla Usecase: device_link consumer driver is removed when a remote processor is crashed or force stopped. In this case the device_link supplier is arm-smmu driver and consumer is rpmsg driver. device_link state in such case is updated from DL_STATE_ACTIVE to DL_STATE_AVAILABLE in __device_release_driver() call, However if device_links_purge() is called before this happens, then it would throw a warning about ACTIVE state of the link as shown in below log. This patch moves call to device_links_purge() after bus_remove_device(), so that device link state is updated correctly before purge. ------------[ cut here ]------------ WARNING: CPU: 0 PID: 2180 at drivers/base/core.c:599 device_del+0x90/0x300 Modules linked in: CPU: 0 PID: 2180 Comm: bash Not tainted 4.11.0-00279-g4a4a8de-dirty #19 Hardware name: Qualcomm Technologies, Inc. DB820c (DT) task: ffff8000d74b0d80 task.stack: ffff8000d6d58000 PC is at device_del+0x90/0x300 LR is at device_del+0x4c/0x300 pc : [] lr : [] pstate: 60000145 sp : ffff8000d6d5b9c0 x29: ffff8000d6d5b9c0 x28: ffff8000d74b0d80 x27: ffff000008b52000 x26: 0000000000000040 x25: 0000000000000124 x24: ffff8000d75c5410 x23: ffff8000d75c68b0 x22: ffff8000d75c5400 x21: ffff000009245000 x20: ffff8000d75c6810 x19: ffff8000d75c6890 x18: 0000000000000000 x17: 0000ffff9963f110 x16: ffff00000820132c x15: 0000000000000000 x14: 0000000000000000 x13: 0000000000000000 x12: 0000000000000018 x11: 0101010101010101 x10: 7f7f7f7f7f7f7f7f x9 : 0000000040000000 x8 : 0000000000210d00 x7 : 0000000000000000 x6 : 0000000000000001 x5 : 0000000000000000 x4 : 0000000000000000 x3 : 0000000000000000 x2 : 0000000000000000 x1 : 0000000000000003 x0 : ffff8000d74e7380 ---[ end trace 73ceac58f2b5affd ]--- Call trace: Exception stack(0xffff8000d6d5b7f0 to 0xffff8000d6d5b920) b7e0: ffff8000d75c6890 0001000000000000 b800: ffff8000d6d5b9c0 ffff0000085eee90 ffff8000d6d5b860 ffff000008274fdc b820: ffff8000d6d5b940 ffff0000081e3ab0 ffff7e00035d7100 ffff8000d74b0d80 b840: ffff8000d6d5b960 ffff0000081e3ab0 ffff7e00035d6400 ffff8000d74b0d80 b860: ffff8000d6d5b980 ffff0000081e3ab0 ffff7e0003663200 ffff8000d74b0d80 b880: 00000000002f19c0 ffff8000d98c8100 ffff8000d74e7380 0000000000000003 b8a0: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 b8c0: 0000000000000001 0000000000000000 0000000000210d00 0000000040000000 b8e0: 7f7f7f7f7f7f7f7f 0101010101010101 0000000000000018 0000000000000000 b900: 0000000000000000 0000000000000000 ffff00000820132c 0000ffff9963f110 [] device_del+0x90/0x300 [] platform_device_del+0x28/0x94 [] platform_device_unregister+0x14/0x2c [] of_platform_device_destroy+0xa4/0xa8 [] device_for_each_child+0x44/0x88 [] of_platform_depopulate+0x30/0x4c [] qcom_rpmsg_q6_remove+0x44/0x54 [] rpmsg_dev_remove+0x38/0x68 [] device_release_driver_internal+0x148/0x1c8 [] device_release_driver+0x14/0x1c [] bus_remove_device+0xdc/0x150 [] device_del+0x1f8/0x300 [] device_unregister+0x1c/0x6c [] qcom_smd_remove_device+0xc/0x18 [] device_for_each_child+0x44/0x88 [] qcom_smd_unregister_edge+0x3c/0x6c [] smd_subdev_remove+0x18/0x28 [] rproc_shutdown+0x84/0x168 [] state_store+0x94/0xec [] dev_attr_store+0x18/0x28 [] sysfs_kf_write+0x40/0x50 [] kernfs_fop_write+0xb0/0x1d0 [] __vfs_write+0x28/0x110 [] vfs_write+0xa0/0x190 [] SyS_write+0x44/0xa0 [] el0_svc_naked+0x24/0x28 msm-pcm-dsp adsp-pil:smd-edge:apr:pcm0: Dropping the link to 1600000.arm,smmu-lpass_q6 iommu: Removing device adsp-pil:smd-edge:apr:pcm0 from group 1 remoteproc remoteproc0: stopped remote processor adsp-pil Signed-off-by: Srinivas Kandagatla --- drivers/base/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.11.0 diff --git a/drivers/base/core.c b/drivers/base/core.c index 8dde934f8d15..6e38c6fdc3f4 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1826,7 +1826,6 @@ void device_del(struct device *dev) blocking_notifier_call_chain(&dev->bus->p->bus_notifier, BUS_NOTIFY_DEL_DEVICE, dev); - device_links_purge(dev); dpm_sysfs_remove(dev); if (parent) klist_del(&dev->p->knode_parent); @@ -1851,6 +1850,7 @@ void device_del(struct device *dev) device_remove_file(dev, &dev_attr_uevent); device_remove_attrs(dev); bus_remove_device(dev); + device_links_purge(dev); device_pm_remove(dev); driver_deferred_probe_del(dev); device_remove_properties(dev);