From nobody Fri Oct 3 08:51:13 2025 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8FA74304BC4 for ; Wed, 3 Sep 2025 13:06:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756904788; cv=none; b=jBrhNZXv1pq9BDujoDECa6I+E2lMzHkLLVb3D2icirrPssRm/b7Lo67/vWuysMwNuPHNzqY2D8NoJ+c3ntiTryAipEv8GXYr25mKkcGcR0peynYrHVkScGLTAT1zQKhXrC+bfJNBzzwvGQdeaeTVbhe2lB75J9TCvWUTwAzcRHY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756904788; c=relaxed/simple; bh=dO5AouNWL4aNepxpem6zpAWY9cfFLUMSDdsjvpTHUbY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NtVG9omP7IwVAWFWjMnv5oHLN2tS3d8sp9M3OqVIInRI7QI92ThyqivPGtemXH432GhQ26WtwLugtBSaga64/cyT2Jp2Dg2OqFw/2TRX8F1Ek4uWiQHqf8b/ylHFDP5l+d0rSRZXfIDDrLCb09AKSFb/Bjqf8uf0jIY+hIEJLCQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from dude02.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::28]) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1utnBl-00006Z-Vo; Wed, 03 Sep 2025 15:06:13 +0200 From: Marco Felsch Date: Wed, 03 Sep 2025 15:06:17 +0200 Subject: [PATCH 09/11] dmaengine: add support for device_link Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250903-v6-16-topic-sdma-v1-9-ac7bab629e8b@pengutronix.de> References: <20250903-v6-16-topic-sdma-v1-0-ac7bab629e8b@pengutronix.de> In-Reply-To: <20250903-v6-16-topic-sdma-v1-0-ac7bab629e8b@pengutronix.de> To: Vinod Koul , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Jiada Wang Cc: dmaengine@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Marco Felsch X-Mailer: b4 0.14.2 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::28 X-SA-Exim-Mail-From: m.felsch@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Add support to create device_links between dmaengine suppliers and the dma consumers. This shifts the device dep-chain teardown/bringup logic to the driver core. Moving this to the core allows the dmaengine drivers to simplify the .remove() hooks and also to ensure that no dmaengine driver is ever removed before the consumer is removed. Signed-off-by: Marco Felsch --- drivers/dma/dmaengine.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index 758fcd0546d8bde8e8dddc6039848feeb1e24475..a50652bc70b8ce9d4edabfaa781= b3432ee47d31e 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c @@ -817,6 +817,7 @@ struct dma_chan *dma_request_chan(struct device *dev, c= onst char *name) struct fwnode_handle *fwnode =3D dev_fwnode(dev); struct dma_device *d, *_d; struct dma_chan *chan =3D NULL; + struct device_link *dl; =20 if (is_of_node(fwnode)) chan =3D of_dma_request_slave_channel(to_of_node(fwnode), name); @@ -858,6 +859,13 @@ struct dma_chan *dma_request_chan(struct device *dev, = const char *name) /* No functional issue if it fails, users are supposed to test before use= */ #endif =20 + dl =3D device_link_add(dev, chan->device->dev, DL_FLAG_AUTOREMOVE_CONSUME= R); + if (!dl) { + dev_err(dev, "failed to create device link to %s\n", + dev_name(chan->device->dev)); + return ERR_PTR(-EINVAL); + } + chan->name =3D kasprintf(GFP_KERNEL, "dma:%s", name); if (!chan->name) return chan; --=20 2.47.2