Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2481722pxj; Mon, 31 May 2021 03:22:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTrVnCDFuBo5Xa3IHjBc1oJXagHQkgm0sGLJBQoOrLAQaSPb8daCPtFOeZ2M/vGDCJ1oTC X-Received: by 2002:a05:6402:c8:: with SMTP id i8mr24278209edu.380.1622456524999; Mon, 31 May 2021 03:22:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622456524; cv=none; d=google.com; s=arc-20160816; b=V3snh8+0QGFUhIZZ31UQZFhmf1Sa8JNhIyteMxEXSCt8fL+nXokhyEGcpeNE2ZKouL GFrr6wcvYxbSTkeGW7t6LLjFcxhpgfv2e6ErOBO7mSbHd6mwQimp40eojnP3B/0497Gd 0iVLxO0+0wtus4ugylFLBunSRJc0BJWhjFckHd+NooECy1wtLZ/krwVEU7FlsMjzuUEc HzTx1KzPBF7Zf2B68CivCYhRICZllcVJ5SI9TRJeioqBfdl/jGS0OFVgphNlDQR7STkk QF2pqSnlkselzE+iH8QbDt8LWgnThgU9xKaJoEL4E62TM2ZBAymoEY0VrsWlu5QQtKWT 3PpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=3AfTFwMt5j2BOBNaAR4WWivZtGEWS24zMUzCZ6X9lMs=; b=w9XHQfl5W1a5/XOFlv3qMQsB9pFcalBpvzpOHwlN8T94ecGsqRgh0WKwsQI2XP4zIG QfDzypgSNKCiP9F+SdKSbZjZeOmxTxqlsQE3h0UYPwiKu5ZOqz6sxLdWvbhjcIhcw9sG THQroDK43qwi+bAq582rQz/c/bJ5H6767r998UZOCNkGuy0lcqUILTU97vcI1B+T2Iri mm/P9zt8aW8GNMQnp5JMoYDMlAksMDViXnxv5nbaX7uiwnSyeYr7/DQXjMpYyFEbpHNb kmZ0MAEoAphHguhoXssGFoQlw2y+CVaEnEoT0rkAVDnD4RP/eQD/s093siB85IOWT4c2 R0cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Hi18iMai; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jt27si12499140ejc.242.2021.05.31.03.21.42; Mon, 31 May 2021 03:22:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Hi18iMai; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231162AbhEaKVV (ORCPT + 99 others); Mon, 31 May 2021 06:21:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:33004 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230518AbhEaKVU (ORCPT ); Mon, 31 May 2021 06:21:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 315AB610E7; Mon, 31 May 2021 10:19:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622456379; bh=2E17MlRyF9jgcHRKGxx+DAw+cGznl+dPMZItWR6H9cU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Hi18iMaiTtmfV15fMTFLamQcUewXekVls0ezWCip0YAjTJLadV9l4dkfuresXmB3m kXdPZRi4PXEl5DYSIb2JhuPUic5GnjMhxqyrWQoB/sYartinPy0JzkWsiv2P89LBl6 jdxZNQBdunxmhxtZxVQZW/dNumGt7FHLQCEWgsEtzoFhHUTg8xzPBlmajJhxKaIvMu EIcUcBhxSj0LtU8PpXxKN3gyvctXo8bw5RbdMnG5c1Q1PWByBqYo/b2PzIVEm/0E0v mzrTfMFs6bZWA4gqxoaTycQ58ahtZDX4cZS6BzG2fbCjtFGwYXBrPaDap0yak6Jjmf t9wIvXfF8+dHA== Date: Mon, 31 May 2021 15:49:35 +0530 From: Vinod Koul To: Pierre-Louis Bossart Cc: Bard Liao , alsa-devel@alsa-project.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, hui.wang@canonical.com, sanyog.r.kale@intel.com, rander.wang@linux.intel.com, bard.liao@intel.com, Leon Romanovsky , Jason Gunthorpe , Dave Ertman , Ranjani Sridharan Subject: Re: [PATCH v4] soundwire: intel: move to auxiliary bus Message-ID: References: <20210511052132.28150-1-yung-chuan.liao@linux.intel.com> <21002781-0b78-3b36-952f-683482a925d7@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <21002781-0b78-3b36-952f-683482a925d7@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 25-05-21, 13:30, Pierre-Louis Bossart wrote: > On 5/11/21 12:21 AM, Bard Liao wrote: > > From: Pierre-Louis Bossart > > > > Now that the auxiliary_bus exists, there's no reason to use platform > > devices as children of a PCI device any longer. > > > > This patch refactors the code by extending a basic auxiliary device > > with Intel link-specific structures that need to be passed between > > controller and link levels. This refactoring is much cleaner with no > > need for cross-pointers between device and link structures. > > > > Note that the auxiliary bus API has separate init and add steps, which > > requires more attention in the error unwinding paths. The main loop > > needs to deal with kfree() and auxiliary_device_uninit() for the > > current iteration before jumping to the common label which releases > > everything allocated in prior iterations. > > > > Signed-off-by: Pierre-Louis Bossart > > Reviewed-by: Guennadi Liakhovetski > > Reviewed-by: Ranjani Sridharan > > Signed-off-by: Bard Liao > > --- > > v2: > > - add link_dev_register for all kzalloc, device_init, and device_add. > > v3: > > - Modify the function description of sdw_intel_probe() which was > > missing in previous version. > > v4: > > - Move intel_link_dev_unregister(ldev) before pm_runtime_put_noidle( > > ldev->link_res.dev) to fix use-after-free reported by KASAN. > > Two years ago, GregKH stated in > https://lore.kernel.org/lkml/20190509181812.GA10776@kroah.com/ > > "So soundwire is creating platform devices? Ick, no! Don't do that" > > Fast forward two years, this patch provides a solution to remove the use of > the platform devices with the auxiliary bus. This move does not add any new > functionality, it's just a replacement of one type of device by another. > > The reviews have been rather limited since the first version shared on March > 22. > > a) I updated the code to follow the model of the Mellanox driver in > > https://elixir.bootlin.com/linux/latest/source/include/linux/mlx5/driver.h#L545 > > I hope this addresses GregKH's feedback on the need for a 'register' > function to combined the two init and add steps. I didn't see a path to add > a generic register function in the auxiliary bus code since between init and > add there is a need to setup domain-specific structures. Other contributors > to the auxiliary bus (CC:ed) also didn't have a burning desire to add this > capability. > > b) Vinod commented: > > "What I would like to see the end result is that sdw driver for Intel > controller here is a simple auxdev device and no additional custom setup > layer required... which implies that this handling should be moved into > auxdev or Intel code setting up auxdev..." > > I was unable to figure out what this comment hinted at: the auxbus is > already handled in the intel_init.c and intel.c files and the auxbus is used > to model a set of links/managers below the PCI device, not the controller > itself. There is also no such thing as a simple auxdev device used in the > kernel today, the base layer is meant to be extended with domain-specific > structures. There is really no point in creating a simple auxbus device > without extensions. I would like to see that the init_init.c removed completely, that is my ask here This layer was created by me to aid in creating the platform devices. Also the mistake was not to use platform resources and instead pass a custom structure for resources (device iomem address, irq etc) I would like to see is the PCI/SOF parent driver create the sdw aux device and that should be all needed to be done. The aux device would be probed by sdw driver. No custom resource structs for resources please. If that is not possible, I would like to understand technical details of why that would be that case. If required necessary changes should be made to aux bus to handle and not have sequencing issue which you had trouble with platform approach. Thanks -- ~Vinod