From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23865C433ED for ; Tue, 13 Apr 2021 12:20:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F19CF61278 for ; Tue, 13 Apr 2021 12:20:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240712AbhDMMVG (ORCPT ); Tue, 13 Apr 2021 08:21:06 -0400 Received: from mga12.intel.com ([192.55.52.136]:33073 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230025AbhDMMVE (ORCPT ); Tue, 13 Apr 2021 08:21:04 -0400 IronPort-SDR: qTWGQHDbT0MJjB7eYo4rY/nPbaaWwU/OwTS11eb7F50GZAZvGf6w4hqqBUPnXhWAvTCD7w/bsd ccUe4NLVTpaw== X-IronPort-AV: E=McAfee;i="6200,9189,9952"; a="173891937" X-IronPort-AV: E=Sophos;i="5.82,219,1613462400"; d="scan'208";a="173891937" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2021 05:20:45 -0700 IronPort-SDR: Z7bA1j7jkyVDLB8y+D1HMUEnWYRwrRWxYQ3a2xSzv5qVl/Ztlwvao5G5bfXwrTg2vzcO7KnNHD /GOjmhdXbBWg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,219,1613462400"; d="scan'208";a="521581070" Received: from kuha.fi.intel.com ([10.237.72.162]) by fmsmga001.fm.intel.com with SMTP; 13 Apr 2021 05:20:41 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Tue, 13 Apr 2021 15:20:41 +0300 Date: Tue, 13 Apr 2021 15:20:41 +0300 From: Heikki Krogerus To: Pierre-Louis Bossart Cc: Cezary Rojewski , Kai Vehmanen , linux-kernel@vger.kernel.org, Jie Yang , Takashi Iwai , Liam Girdwood , Hans de Goede , Mark Brown , alsa-devel@alsa-project.org, Bard Liao Subject: Re: [PATCH] ASoC: Intel: Handle device properties with software node API Message-ID: References: <20210322110638.2681-1-heikki.krogerus@linux.intel.com> <786795eb-6832-fd7d-4674-65be394c083d@linux.intel.com> <39e2ab87-3b70-8659-6282-5b03d30f901b@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <39e2ab87-3b70-8659-6282-5b03d30f901b@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 12, 2021 at 03:36:20PM -0500, Pierre-Louis Bossart wrote: > I took the code and split it in two for BYT/CHT (modified to remove devm_) > and SoundWire parts (added as is). > > https://github.com/thesofproject/linux/pull/2810 > > Both cases result in a refcount error on device_remove_sof when removing the > platform device. I don't understand the code well enough to figure out what > happens, but it's likely a case of the software node being removed twice? Right. Because you are injecting the node to an already existing device, the node does not get linked with the device in sysfs. That would increment the reference count in a normal case. It all happens in the function software_node_notify(). Driver core calls it when a device is added and also when it's removed. In this case it is only called when it's removed. I think the best way to handle this now is to simply not decrementing the ref count when you add the properties, so don't call fwnode_handle_put() there (but add a comment explaining why you are not calling it). For a better solution you would call device_reprobe() after you have injected the software node, but before that you need to modify device_reprobe() so it calls device_platform_notify() (which it really should call in any case). But this should probable be done later, separately. thanks, P.S. Have you guys considered the possibility of describing the connections between all these components by using one of the methods that we now have for that in kernel, for example device graph? It can now be used also with software nodes (OF graph and ACPI device graph are of course already fully supported). -- heikki