From patchwork Tue Aug 9 09:33:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 9270733 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 13CA26082E for ; Tue, 9 Aug 2016 09:35:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 044CF26598 for ; Tue, 9 Aug 2016 09:35:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED3FC28308; Tue, 9 Aug 2016 09:35:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8CA2326598 for ; Tue, 9 Aug 2016 09:35:41 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bX3QX-0000yW-FT; Tue, 09 Aug 2016 09:34:25 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:3201:214:fdff:fe10:1be6]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bX3QS-0000qp-8V for linux-arm-kernel@lists.infradead.org; Tue, 09 Aug 2016 09:34:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2014; h=Date:Sender:Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From; bh=gg4Sqqw1MqGr5bvSFAEiVDU6xt2D+sIU/6wIiE7juOI=; b=o9WTqA5vaPqGcb9ujsp7f3mquLQBGT0f3NdTB3bu3BZHDnT8xCnymIiNxp6Iq2W1wEkWnx5lH+tur9YBYvQTAdsANvUsubPzyCVw7Y+TIx32OjYu3dHS+aisgyJ21cNF0jtpJqE3tGz2n5JHv/kOinkKuFaH0aRny4zzkg6Z0h8=; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:57074 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1bX3Px-0002sY-FK; Tue, 09 Aug 2016 10:33:49 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1bX3Pw-00088i-KU; Tue, 09 Aug 2016 10:33:48 +0100 From: Russell King To: Rob Herring , Frank Rowand , devicetree@vger.kernel.org Subject: [PATCH] OF: mark released devices as no longer populated MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Tue, 09 Aug 2016 10:33:48 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160809_023420_669249_DE6F3A25 X-CRM114-Status: GOOD ( 13.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fabio Estevam , linux-arm-kernel@lists.infradead.org, horia.geanta@nxp.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When a Linux device is released and cleaned up, we left the OF device node marked as populated. This causes the Freescale CAAM driver (drivers/crypto/caam) problems when the module is removed and re- inserted: JR0 Platform device creation error JR0 Platform device creation error caam 2100000.caam: no queues configured, terminating caam: probe of 2100000.caam failed with error -12 The reason is that CAAM creates platform devices for each job ring: for_each_available_child_of_node(nprop, np) if (of_device_is_compatible(np, "fsl,sec-v4.0-job-ring") || of_device_is_compatible(np, "fsl,sec4.0-job-ring")) { ctrlpriv->jrpdev[ring] = of_platform_device_create(np, NULL, dev); which sets OF_POPULATED on the device node, but then it cleans these up: /* Remove platform devices for JobRs */ for (ring = 0; ring < ctrlpriv->total_jobrs; ring++) { if (ctrlpriv->jrpdev[ring]) of_device_unregister(ctrlpriv->jrpdev[ring]); } which leaves OF_POPULATED set. Arrange for platform devices with a device node to clear the OF_POPULATED bit when they are released. Signed-off-by: Russell King --- Please check this carefully - it may have issues where an of_node pointer is copied from one platform device to another, but IMHO doing that is itself buggy behaviour. Resending due to wrong list address, sorry. include/linux/of_device.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/of_device.h b/include/linux/of_device.h index cc7dd687a89d..7a8362d0c6d2 100644 --- a/include/linux/of_device.h +++ b/include/linux/of_device.h @@ -43,6 +43,7 @@ extern int of_device_uevent_modalias(struct device *dev, struct kobj_uevent_env static inline void of_device_node_put(struct device *dev) { + of_node_clear_flag(dev->of_node, OF_POPULATED); of_node_put(dev->of_node); }