Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2891648pxb; Tue, 24 Aug 2021 10:00:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8Q7J6/JyB1xReMQIAneUhA/g+NWL+LGikJUDw10UqXbJVaWpQxdgdq+v3NWgBaI/jrFTI X-Received: by 2002:a50:f690:: with SMTP id d16mr13125194edn.369.1629824408675; Tue, 24 Aug 2021 10:00:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629824408; cv=none; d=google.com; s=arc-20160816; b=hdAFmdVSSfJB3W5/TvpfSU4pGvzt6rAc7cqgRNpH3yvSAMcImSF+nWlHuQIaReAhpW +CZD18rv75gE0vZlJBoDvn2pPMX9gVfI408cxmOJvMPA/7rCPsPN4y66hOSNoN1dksai DFopkNzMgQT7jT1Js8g0kSvv3TxLO9zLwpWgeNwMZDRUaeNHksp/O/W2M/Q8YUGdTXj/ vTYDobiJ/m2xq5LSzDBLOTlUEIWQuMuYSZ5cIn4vUGplgIktcbwVssTKik6rBmcdA1Yh UHFYLOIozRZM2BWrwQEVdPcZsQNLQAArmk3JC65C14PzL7pUgTBu+vV6Lfs5FZ0SfTHi 9+Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=b00F4dzqwGbouY+ZRL51q84Y0Ov1ERDvv/MRpdzUzf4=; b=nevgicobm8U46e6cM9qKxJSZcO4HOnkLMVYIx+BrbtLgvm+julHK4hk/MsmefIYP8W iv8xWlJI9tu0WR1fYfG+RQtFqL+F16n7CbMHBC0pu2+/ex/7fubiKnnMvmesIdH0uUj/ Fjpc0JBxFAxXZydqs17L0H+zQ6LH/cCmwyXEjC5k5omydevZnWvr2v8kUW0NiYsukERP PGo53pZwI6JqVRSAqvY0ISfE6Ma7Qk0oMyO3T+9XoUEt7JJ6VJwxkUDwxfcVLC1FW1IF GjDWAzv0J9pX7zgZLTYrorCHERoBXdZ0wk8+iiRtSx6vnLqK7Cro/MSBqfJ8VFcDZzH0 RtFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gBKFErL8; 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 e10si22798943edj.183.2021.08.24.09.59.45; Tue, 24 Aug 2021 10:00:08 -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=gBKFErL8; 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 S234027AbhHXQ5V (ORCPT + 99 others); Tue, 24 Aug 2021 12:57:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:38858 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233836AbhHXQ5D (ORCPT ); Tue, 24 Aug 2021 12:57:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8CA2661374; Tue, 24 Aug 2021 16:56:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629824179; bh=YepSXCU2ju4mtjkbVuCQPJaTKoncqIMO34FMAlD89l0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gBKFErL80eG78Ucs/7LBqS/gf57QWbqDdZ2blxh9l35NH6GPXW8PZtZAfU6Cbypwf 4rYjeJGOVds+1s5gCzFtDar3zveqTnWNasLV/B1UF1k9kmsPzIg644fBeWUeu9DjSR g/dR83k/TfWiOU/mJYkcv141lXUP/+6wTazzzcfYGrP1RQaaDhN7BX7GBNxK2MDYBb sKGbOLbenGmk70r0eyCjB/jBZGNc+LJovJ8w3MGeR6bbsSCN0zJkNwLuDLb7Bb8G3i YESM03GxwcIjiOtcUxlLLDhrogsrwOQiLWULLbxN3/X335BvW4Zs44lbvvMqdiq5rD 9DSbFjZ8APKRQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Peter Ujfalusi , Vinod Koul , Sasha Levin Subject: [PATCH 5.13 010/127] dmaengine: of-dma: router_xlate to return -EPROBE_DEFER if controller is not yet available Date: Tue, 24 Aug 2021 12:54:10 -0400 Message-Id: <20210824165607.709387-11-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210824165607.709387-1-sashal@kernel.org> References: <20210824165607.709387-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.13.13-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.13.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.13.13-rc1 X-KernelTest-Deadline: 2021-08-26T16:55+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Ujfalusi [ Upstream commit eda97cb095f2958bbad55684a6ca3e7d7af0176a ] If the router_xlate can not find the controller in the available DMA devices then it should return with -EPORBE_DEFER in a same way as the of_dma_request_slave_channel() does. The issue can be reproduced if the event router is registered before the DMA controller itself and a driver would request for a channel before the controller is registered. In of_dma_request_slave_channel(): 1. of_dma_find_controller() would find the dma_router 2. ofdma->of_dma_xlate() would fail and returned NULL 3. -ENODEV is returned as error code with this patch we would return in this case the correct -EPROBE_DEFER and the client can try to request the channel later. Signed-off-by: Peter Ujfalusi Link: https://lore.kernel.org/r/20210717190021.21897-1-peter.ujfalusi@gmail.com Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/dma/of-dma.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/dma/of-dma.c b/drivers/dma/of-dma.c index ec00b20ae8e4..ac61ecda2926 100644 --- a/drivers/dma/of-dma.c +++ b/drivers/dma/of-dma.c @@ -67,8 +67,12 @@ static struct dma_chan *of_dma_router_xlate(struct of_phandle_args *dma_spec, return NULL; ofdma_target = of_dma_find_controller(&dma_spec_target); - if (!ofdma_target) - return NULL; + if (!ofdma_target) { + ofdma->dma_router->route_free(ofdma->dma_router->dev, + route_data); + chan = ERR_PTR(-EPROBE_DEFER); + goto err; + } chan = ofdma_target->of_dma_xlate(&dma_spec_target, ofdma_target); if (IS_ERR_OR_NULL(chan)) { @@ -89,6 +93,7 @@ static struct dma_chan *of_dma_router_xlate(struct of_phandle_args *dma_spec, } } +err: /* * Need to put the node back since the ofdma->of_dma_route_allocate * has taken it for generating the new, translated dma_spec -- 2.30.2