From patchwork Tue Jan 22 11:35:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 156292 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7467569jaa; Tue, 22 Jan 2019 03:35:39 -0800 (PST) X-Google-Smtp-Source: ALg8bN4ay3nUH3NEsbgOaM7p/TBe3o78gGmU8cIZ/OlqxdQ2amg3mTlQIxWzA6pVOYkzkuSqFa6R X-Received: by 2002:a62:13c3:: with SMTP id 64mr33218686pft.93.1548156939139; Tue, 22 Jan 2019 03:35:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548156939; cv=none; d=google.com; s=arc-20160816; b=dxpklzB0KynKCO6av/6RARS022mULGekJyoc3vrrw5+v4kkrnVoRtbwiYKCZpPM+Zc NiM+XrQiWgP7ZY7eKgZaSHEhLKR8+PKS3b5dwMKvAv7t+EHGoBVEfFvFz0jBfUHARTTC TByAI+b1plbbGMiheci1YVNUcGYpbOAqSCOUco3WKeKygFt3S8ys8sB2oNIcQJ+jZd4z 7jnxbzDzp5+UwtP0vovMJO6UVevpV8ZK1r66cR+cVewy6PM1NN7T/q1XikmuKaS24X3M nQRd8HI0dTR2YJb8Edcq0V4xK9jzx3mXa8CxsOOSAdcvh6zvW/2tmqq/e1a3EzViScUy mfMg== 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; bh=Q+L7ZS9sbBBHkFIVUlzpXmBO7HCm12Y90swYNlfCUKA=; b=moW/J0X4S7SWWsjmg3rzdpq3e401D/kwgFNCPFI78x976OFG1Je5IJpoufHD2c+TPz k00k73gna2kapb6aaAVQYAElFikEyFAU8TLJ5muI+FiFvwnwm1srCfN9r5zWGFspI85T YypRMDFKkiE6lSMoBEcjsHnCmHJ/r1AVMC8Xw5B63kWn6MdNuCk83Yj9LiSPIjlzFCG1 IkvlGi+eIQRCt1Na6r1ey1ARm/VJxFSFt0VPI1Lf905bG8fCxqGAXIs35tCdO2caB0jL uqqVZimgH+ow7G9mIFR3VA9BBz+Un2zSoixNuwWtulNEV2iZYjGx9DxsmwwISMGiGdM6 okEQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u17si13928172pgl.586.2019.01.22.03.35.38; Tue, 22 Jan 2019 03:35:39 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728162AbfAVLfh (ORCPT + 27 others); Tue, 22 Jan 2019 06:35:37 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:51654 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727925AbfAVLfg (ORCPT ); Tue, 22 Jan 2019 06:35:36 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 19A78A78; Tue, 22 Jan 2019 03:35:36 -0800 (PST) Received: from usa.arm.com (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B6F4B3F6A8; Tue, 22 Jan 2019 03:35:34 -0800 (PST) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org, ARM SoC Team Cc: Sudeep Holla , linux-kernel@vger.kernel.org, Kevin Hilman , Olof Johansson , Arnd Bergmann Subject: [PATCH] firmware: arm_scmi: provide the mandatory device release callback Date: Tue, 22 Jan 2019 11:35:25 +0000 Message-Id: <20190122113525.13705-1-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The device/driver model clearly mandates that bus driver that discover and allocate the device must set the release callback. This callback will be used to free the device after all references have gone away. scmi bus driver is missing the obvious callback which will result in the following warning if the device is unregistered: Device 'scmi_dev.1' does not have a release() function, it is broken and must be fixed. See Documentation/kobject.txt. WARNING at drivers/base/core.c:922 device_release+0x8c/0xa0 Hardware name: ARM LTD Juno Development Platform BIOS EDK II Jan 21 2019 Workqueue: events deferred_probe_work_func pstate: 60000005 (nZCv daif -PAN -UAO) pc : device_release+0x8c/0xa0 lr : device_release+0x8c/0xa0 Call trace: device_release+0x8c/0xa0 kobject_put+0x8c/0x208 device_unregister+0x30/0x78 scmi_device_destroy+0x28/0x50 scmi_probe+0x354/0x5b0 platform_drv_probe+0x58/0xa8 really_probe+0x2c4/0x3e8 driver_probe_device+0x12c/0x148 __device_attach_driver+0xac/0x150 bus_for_each_drv+0x78/0xd8 __device_attach+0xe0/0x168 device_initial_probe+0x24/0x30 bus_probe_device+0xa0/0xa8 deferred_probe_work_func+0x8c/0xe0 process_one_work+0x1f0/0x478 worker_thread+0x22c/0x450 kthread+0x134/0x138 ret_from_fork+0x10/0x1c ---[ end trace 420bdb7f6af50937 ]--- Fix the issue by providing scmi_device_release callback. We have everything required for device release already in scmi_device_destroy, so we just need to move freeing of the device to scmi_device_release. Fixes: 933c504424a2 ("firmware: arm_scmi: add scmi protocol bus to enumerate protocol devices") Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/bus.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) Hi ARM-SoC team, Can you apply this one patch directly or I can send pull request if you prefer ? Regards, Sudeep -- 2.17.1 diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c index 472c88ae1c0f..92f843eaf1e0 100644 --- a/drivers/firmware/arm_scmi/bus.c +++ b/drivers/firmware/arm_scmi/bus.c @@ -119,6 +119,11 @@ void scmi_driver_unregister(struct scmi_driver *driver) } EXPORT_SYMBOL_GPL(scmi_driver_unregister); +static void scmi_device_release(struct device *dev) +{ + kfree(to_scmi_dev(dev)); +} + struct scmi_device * scmi_device_create(struct device_node *np, struct device *parent, int protocol) { @@ -138,6 +143,7 @@ scmi_device_create(struct device_node *np, struct device *parent, int protocol) scmi_dev->dev.parent = parent; scmi_dev->dev.of_node = np; scmi_dev->dev.bus = &scmi_bus_type; + scmi_dev->dev.release = scmi_device_release; dev_set_name(&scmi_dev->dev, "scmi_dev.%d", id); retval = device_register(&scmi_dev->dev); @@ -156,9 +162,8 @@ scmi_device_create(struct device_node *np, struct device *parent, int protocol) void scmi_device_destroy(struct scmi_device *scmi_dev) { scmi_handle_put(scmi_dev->handle); - device_unregister(&scmi_dev->dev); ida_simple_remove(&scmi_bus_id, scmi_dev->id); - kfree(scmi_dev); + device_unregister(&scmi_dev->dev); } void scmi_set_handle(struct scmi_device *scmi_dev)