Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp338471pxb; Mon, 16 Aug 2021 06:38:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpJ5fAyv5wpJothcPx75ACgHeUALjDQmnzuUEb3KmpukwgIbY19bCaEEEMQtpb9Gf/jTrr X-Received: by 2002:a17:906:fb91:: with SMTP id lr17mr16201887ejb.110.1629121133169; Mon, 16 Aug 2021 06:38:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629121133; cv=none; d=google.com; s=arc-20160816; b=Fh3kSK97T6X4X83zRO+006tCtAfg8iBz5SyzSZJm2OX00/VPxGxtJAdqReBEz2dFpq BiLtZdbGgHk0GU7vrT8fKbdAlpRDYNHV9yjYLnQ6M+6TkxmO0CPRcm5XODckgWv6XbQN fOjI8ZOM0OqGIF19k2j0mj7uhTyGDQ1DTIF04YHPC29Gn20GSOoFQN3fG4RoHzTUneHO FARmFXNji1A/rZhP92492EIOdsycY1EHUZKVZHwy9vYZmQ6MsNw4/EA0EfX/2NG6/h94 Ys+TUxFFkqkyNPSxFTZH7WmMx+FVuqt39vNeVzNC8idoqKJgxdEjN9T8NrZXwHeKz+s1 RyYw== 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=JMEZ+JI0ORtCHPjhiUMOYuXy0E8TiDUyhaWvEAEWafU=; b=AgCqUQxom0efD27IRzddZQnaz4lQ2uAkAZg19kZXHF5VQtYbq6pJgripOQpX+jlJ5P eB6hoOcNOo4fXKJwV5EEmLI0Z3qj6SCZG96rIFDz+fB681wL/j3OmEF2pMrk3dk6jqkf BlPVmVoTmCsmEHPvmna/pM1Ktfj5O/qD5Qo4oN9zaAfwCGSZbPhB53k9bSkxJeGP4IWI Nm288UcuLc+6FFjBKNXt+w6DI7RcbhamNQvN+6tOJFvvS0aWNaOH8lRLkK+pyLWtDsHf HW9EsBmDemlRJYnNaqwQqjJGQMORyY4L08UFPCmMhLWYnQ80CUwHRYz0oNZFGipEsJNO Ib9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kOZp7YvJ; 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 hk6si9020976ejb.587.2021.08.16.06.38.29; Mon, 16 Aug 2021 06:38:53 -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=kOZp7YvJ; 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 S241493AbhHPNeI (ORCPT + 99 others); Mon, 16 Aug 2021 09:34:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:49828 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239387AbhHPN06 (ORCPT ); Mon, 16 Aug 2021 09:26:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 61404632BE; Mon, 16 Aug 2021 13:26:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629120386; bh=77Qk2RGPl8adrRUvGjCdFbgEWfKIq77VmbOlU67gcKA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kOZp7YvJwiUnyQ2uWHujW/TdXZsZdU+eO0rBMbz4Hmtox3/wVdJ3f89rv8spkr7Nc CBnFBeYbk5FWObWJT0vbQsIE7Zr1v9QSJFCgNMf4xqndqWwcHqQR6mc3k16JArXrxV 7AYftRTO+aT4W3F4vQGYRkKBZVJ+dI+dhhuZOwt24d1vXcgp2Mur5DHf4ND7SslKRD 4QBUgnbouSWL6yH/H5+XSnAh1CN6NHoqiV6TxRiUxxB1nsd5d0t0qpATP5IjP+b9jM +cdYCqUo+XmvPzJ99JzlYyHeHCpK8QIbY99JFohDrD66r1kAJLVmvnkKYEvx5OG0Jo zgETEeXn+GwYQ== From: Will Deacon To: linux-kernel@vger.kernel.org Cc: iommu@lists.linux-foundation.org, Will Deacon , Claire Chang , Konrad Rzeszutek Wilk , Christoph Hellwig , Rob Herring , Robin Murphy Subject: [PATCH v2 2/2] of: restricted dma: Don't fail device probe on rmem init failure Date: Mon, 16 Aug 2021 14:26:17 +0100 Message-Id: <20210816132618.11707-3-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210816132618.11707-1-will@kernel.org> References: <20210816132618.11707-1-will@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If CONFIG_DMA_RESTRICTED_POOL=n then probing a device with a reference to a "restricted-dma-pool" will fail with a reasonably cryptic error: | pci-host-generic: probe of 10000.pci failed with error -22 Rework of_dma_set_restricted_buffer() so that it does not cause probing failure and instead either returns early if CONFIG_DMA_RESTRICTED_POOL=n or emits a diagnostic if the reserved DMA pool fails to initialise. Cc: Claire Chang Cc: Konrad Rzeszutek Wilk Cc: Christoph Hellwig Cc: Rob Herring Cc: Robin Murphy Signed-off-by: Will Deacon --- drivers/of/device.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/of/device.c b/drivers/of/device.c index 089c5b4b97fb..5b043ee30824 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -53,12 +53,15 @@ int of_device_add(struct platform_device *ofdev) return device_add(&ofdev->dev); } -static int +static void of_dma_set_restricted_buffer(struct device *dev, struct device_node *np) { struct device_node *node, *of_node = dev->of_node; int count, i; + if (!IS_ENABLED(CONFIG_DMA_RESTRICTED_POOL)) + return; + count = of_property_count_elems_of_size(of_node, "memory-region", sizeof(u32)); /* @@ -79,11 +82,11 @@ of_dma_set_restricted_buffer(struct device *dev, struct device_node *np) */ if (of_device_is_compatible(node, "restricted-dma-pool") && of_device_is_available(node)) - return of_reserved_mem_device_init_by_idx(dev, of_node, - i); + break; } - return 0; + if (i != count && of_reserved_mem_device_init_by_idx(dev, of_node, i)) + dev_warn(dev, "failed to initialise \"restricted-dma-pool\" memory node\n"); } /** @@ -200,7 +203,7 @@ int of_dma_configure_id(struct device *dev, struct device_node *np, arch_setup_dma_ops(dev, dma_start, size, iommu, coherent); if (!iommu) - return of_dma_set_restricted_buffer(dev, np); + of_dma_set_restricted_buffer(dev, np); return 0; } -- 2.33.0.rc1.237.g0d66db33f3-goog