Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2917544pxb; Tue, 24 Aug 2021 10:33:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvVJZGI+zyQg/V+1Xs2eUiXCsZvDAW8rwWtgdquVk4kIg0xOhXT+G45gy9UK5G0OUp0X64 X-Received: by 2002:a92:b749:: with SMTP id c9mr27406840ilm.160.1629826393529; Tue, 24 Aug 2021 10:33:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629826393; cv=none; d=google.com; s=arc-20160816; b=FuUqq44RbXa5D9BgrhEcvGmWNPiMCP3nCwlRm8KdxNaqsyjh9zPJxmPKxNCnDmxml9 qH0XObr6G+3s+c2kg96r2Tl5eMZ8Yt5U+3IH2KXhsMGspX/4Sp9KYUTEp+PT4tODw7Hj pg0IuhIMq5ssqoweSmf0j6QyhkcNwg1D/RKfVQSKu+IeFdtEGfHBVSGWphkgEqGlFV/l hyrKp8YxtPdvjSLwDf1hZhfDpdTMQJnonn8DZ36jPovRTTtCS1quJIB+gv77rIB5j7fe 53qkOPt80j0s5TWtP5ci7GXW+HhPtucWyfedbJmWlP3W3aBOYtV+anGColof/heNJH8S 98Bg== 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=Tzh+L2UVV+NhSPiHSTdMerjzNzbtny0L6dynMLZvq+w=; b=jCYch+C4lj9DJSW6uR1xNcgmAgm/LrwEpW2K67uMFVNNNB6tMDPfTKBddO5BUWUXmW V48Xjdmvnw5dTule8qF+wkTxtwD0CLnSjg4OgiOXIHRbYNf0Jb34BZTfCsMoBH7WLazI 4zkrXsxAQFpmN5t5qQRPbtrhqa3eCpNkHqM23Eq6jJqiNp8b3esgpc8UcY00nJqBP6Cy wm/pnn0a3XendTVVq5IY5Wd+s0CN7aAJ1EoI/wYo1OWOtgvlftmskHt1s1YbmUjJn8Vt rvNXLXFHuei+VjPihTw1xfmRz9F5FdX0odBZI7a+AHmUzhYC9TLduPhUNIE6tzJxyBV0 shnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UBNPpj9l; 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 y21si4013407jat.7.2021.08.24.10.33.01; Tue, 24 Aug 2021 10:33:13 -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=UBNPpj9l; 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 S241483AbhHXRdB (ORCPT + 99 others); Tue, 24 Aug 2021 13:33:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:35158 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240057AbhHXRaD (ORCPT ); Tue, 24 Aug 2021 13:30:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 82D6461B56; Tue, 24 Aug 2021 17:05:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629824738; bh=ePZz+sF9yOD/Cf5qf8TlpbkemcR8a+vrRB0qNX7C4KA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UBNPpj9lc4u9tQnwfHwFvKAsZmmpjjGimqWnKEZsBfhEBDZSep3jIy5gEKiX6bvLp 2bL+Rx220AG74CRxvxsEhPIF8LJdjyopy5WP0q7Uz/YInfsfGW8i9+Hr3a6wQAYO5k HunYbtKfrQUJZXN9E1byVHs3xGnloUdKO9rCtmzvztaw0s5L/sCB7I5BTjUPjdcX2z 3+86+HtWkl6xUEbjXZc6TAV6KzWwNCDqZhSh40I1mTkodtH7Bc1LvbNg+FcZGdfIBa oVYj7GHOb+Ph8lvcfaTcUDFSMkLBwSimcx/1B7koWXLJJaq+p3FzKnXpcf/1HU6Qth kOFD4pxXLG3VA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Peter Ujfalusi , Vinod Koul , Sasha Levin Subject: [PATCH 4.14 41/64] dmaengine: of-dma: router_xlate to return -EPROBE_DEFER if controller is not yet available Date: Tue, 24 Aug 2021 13:04:34 -0400 Message-Id: <20210824170457.710623-42-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210824170457.710623-1-sashal@kernel.org> References: <20210824170457.710623-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.245-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-4.14.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.14.245-rc1 X-KernelTest-Deadline: 2021-08-26T17:04+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 8344a60c2131..a9d3ab94749b 100644 --- a/drivers/dma/of-dma.c +++ b/drivers/dma/of-dma.c @@ -68,8 +68,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)) { @@ -80,6 +84,7 @@ static struct dma_chan *of_dma_router_xlate(struct of_phandle_args *dma_spec, chan->route_data = route_data; } +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