From patchwork Fri Sep 27 00:24:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring \(Arm\)" X-Patchwork-Id: 174554 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2787322ill; Thu, 26 Sep 2019 17:25:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwst2yZ6QQLZ9bGZeE/RqOTtqDfb/QjCttzVexxzWwJxaMWNGx+Fn3/jsBulxG7FpapN9BQ X-Received: by 2002:a50:e791:: with SMTP id b17mr1669999edn.11.1569543904932; Thu, 26 Sep 2019 17:25:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569543904; cv=none; d=google.com; s=arc-20160816; b=nCVZm021OmLhf+cFNXnbTKzZCq6Cacs8PCe936Pwgj+5DeDVSXY+ZHjqhlcFahN6pK pg8Mbi258fCFwVjsH87EaohW/96fAqwno5bwF9g/nd5XXMm0/3EOUEujnpRl25mgepQO lBULenW52hYivfJpQyt0YdQkxJGtV0YMypzjlGtzEM1ZKAyt59uqhkzOwFsY/VzaZrPa KOAyjclD5F96rSrUPZ+kB70NJuz6eKGxAKy/htX4s51vw8flNo1xu5VnULmw5pHdX9qi crEjGXeWGrbC6EkFO82c/GyHWX2kQBCBVktWDKL866/v7/BxskbWumtOr9ZHzgMNQ3Ty ibeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=+w5IFIxhvLU+cAIOScJHHta0qaO4ZGZGm/wE8/ycgf8=; b=L2lqxiV/CNrbQGCsvOFyjPePdKRu4NGXQlXs2QahvjYMUPGAdrhc5yi4NNPHEPt82G INUe/1cSyDNG4Vi92Vm69JymBVR5LMw6mEuoNNlCjFW+fqCSwSW+U0n16M5N7n83+VFS 5OlNoJ0edYcfdFpZj77dpRpfsLCfPbjOxlwJ+6nP6FcS4CZ0vvIm2rE+jsSoLUD0dM82 6/9B+CqsR/I9xSUUk60vxTYRCIjoy9fxcwCEgETzxjQJtHzfWeoLppM3S2istifYzv8E zGgC94Q6Rr9Pg3qLBnbIX+dETVqkNEdxqd9HQm4JEC++u+KrqR0zjFoEXsqXfQvPr5yc EuWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h17si1905166ejt.173.2019.09.26.17.25.04; Thu, 26 Sep 2019 17:25:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726688AbfI0AZB (ORCPT + 8 others); Thu, 26 Sep 2019 20:25:01 -0400 Received: from mail-oi1-f196.google.com ([209.85.167.196]:37191 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725808AbfI0AZB (ORCPT ); Thu, 26 Sep 2019 20:25:01 -0400 Received: by mail-oi1-f196.google.com with SMTP id i16so3740969oie.4; Thu, 26 Sep 2019 17:24:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+w5IFIxhvLU+cAIOScJHHta0qaO4ZGZGm/wE8/ycgf8=; b=rJ8xxO+z4dT24fHthj0h9FrKmRoSWdet4bq92MPGKa+ydQYYgVLoe7mdZd8dyq+8+d tpItjzCHc4IUOVsZyAr0s4p5tG/m7dHfxeFTlJE42VohqtpDUSqVrFM5SU27t2x1rCPu VhEqOWjEgdDCRIN/EfxTa5ZSsje4P+1x3xronJL8ySpCVYvuZwjW8VIPAlDyv4IlIYTp OXZ6k9wS0cvWFxREoaNQHUVQFc3159Arqhzw6GHC4FeYsXR8DbEYec6YG4nWvO0ayO6h 0BT8XuMPkFfXBNEG73Asw82dCTVSmiNmdtvrBLsBYauEtd01IoJ6Sl+ACszkAXNXKckA cVKg== X-Gm-Message-State: APjAAAVx7jCk15PkIOrhr68qO9a00tFgXL4yFStxNgtcoeF38qxelt4O pnH46U4UNj4Wz7ONpVhXOtVitDI= X-Received: by 2002:aca:c0d6:: with SMTP id q205mr4827563oif.81.1569543898837; Thu, 26 Sep 2019 17:24:58 -0700 (PDT) Received: from xps15.herring.priv (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.googlemail.com with ESMTPSA id j11sm339866otk.80.2019.09.26.17.24.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2019 17:24:58 -0700 (PDT) From: Rob Herring To: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Robin Murphy , Florian Fainelli , Stefan Wahren , Frank Rowand , Arnd Bergmann , Marek Vasut , Geert Uytterhoeven , Simon Horman , Lorenzo Pieralisi , Oza Pawandeep Subject: [PATCH 01/11] of: Remove unused of_find_matching_node_by_address() Date: Thu, 26 Sep 2019 19:24:45 -0500 Message-Id: <20190927002455.13169-2-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190927002455.13169-1-robh@kernel.org> References: <20190927002455.13169-1-robh@kernel.org> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org of_find_matching_node_by_address() is unused, so remove it. Cc: Robin Murphy Signed-off-by: Rob Herring --- drivers/of/address.c | 19 ------------------- include/linux/of_address.h | 12 ------------ 2 files changed, 31 deletions(-) -- 2.20.1 Reviewed-by: Geert Uytterhoeven Reviewed-by: Christoph Hellwig diff --git a/drivers/of/address.c b/drivers/of/address.c index 978427a9d5e6..0c3cf515c510 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -826,25 +826,6 @@ int of_address_to_resource(struct device_node *dev, int index, } EXPORT_SYMBOL_GPL(of_address_to_resource); -struct device_node *of_find_matching_node_by_address(struct device_node *from, - const struct of_device_id *matches, - u64 base_address) -{ - struct device_node *dn = of_find_matching_node(from, matches); - struct resource res; - - while (dn) { - if (!of_address_to_resource(dn, 0, &res) && - res.start == base_address) - return dn; - - dn = of_find_matching_node(dn, matches); - } - - return NULL; -} - - /** * of_iomap - Maps the memory mapped IO for a given device_node * @device: the device whose io range will be mapped diff --git a/include/linux/of_address.h b/include/linux/of_address.h index 30e40fb6936b..e317f375374a 100644 --- a/include/linux/of_address.h +++ b/include/linux/of_address.h @@ -33,10 +33,6 @@ extern u64 of_translate_dma_address(struct device_node *dev, extern u64 of_translate_address(struct device_node *np, const __be32 *addr); extern int of_address_to_resource(struct device_node *dev, int index, struct resource *r); -extern struct device_node *of_find_matching_node_by_address( - struct device_node *from, - const struct of_device_id *matches, - u64 base_address); extern void __iomem *of_iomap(struct device_node *device, int index); void __iomem *of_io_request_and_map(struct device_node *device, int index, const char *name); @@ -71,14 +67,6 @@ static inline u64 of_translate_address(struct device_node *np, return OF_BAD_ADDR; } -static inline struct device_node *of_find_matching_node_by_address( - struct device_node *from, - const struct of_device_id *matches, - u64 base_address) -{ - return NULL; -} - static inline const __be32 *of_get_address(struct device_node *dev, int index, u64 *size, unsigned int *flags) { From patchwork Fri Sep 27 00:24:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring \(Arm\)" X-Patchwork-Id: 174557 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2787553ill; Thu, 26 Sep 2019 17:25:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqxHEWjLDYfRMkzGT6yENg72ka2zSyPng+jtZerBzxSuq1SvPFn6bKNMYmnXRqdIcgCNxvoH X-Received: by 2002:aa7:d611:: with SMTP id c17mr1741456edr.196.1569543920003; Thu, 26 Sep 2019 17:25:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569543919; cv=none; d=google.com; s=arc-20160816; b=srOJopCkccsAjDNmLCY1HqwpmlxBaAxLj6Qa3sc8zud+813hSAIV4Ya3vyfZ0lexCi 57PSlMWRHnUOoqTsQtUhYyq7iHlJ7Zs7+GF7MHKcgkl+XU4pIM0Dhb8H4cZ4Iw6aykXX Xucd3X+mL2iVdwKWJEsW0l3e75KnehmQCjoy+OB8eprugfcoAyq6Z3H/aWPdFNQnKgTE Ul5wcZD6uRj2BGTMUyn/+g/K8HeKgR6/PuUOtsjpZ8TLFWene5f5qd9Bpmsx8ZnXVoQi rkQGR/NLHR1M3KBOfeFXq5+V64WJdlxuc8DtaHxTvVn8tq3065x75/13ub3yEF9qxAJX vY8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=+Kwduh2L3Q3wglxQRQFNc0vVRF7aZPumhA9/VlLU+NE=; b=k4eIHdzktuj9tWQJcBF5qwfuHAP6wELgmIhNDD2EW8ffJKBPWk8l3nLTojLwCSXa2M X7zw2Ns6FCKRJnhWigLkIVnWRsKdXDDdhrQXlQeD+azszZKfOBORZUtFBTnAUm4DASDo UBi9GFIl6kJtOjSStpwy2r1OiL2Z/laLE/YA0VQhE8uRT2kJ0YOVsHiucviqUoAhaKIG I1Y/KlJPrTQroXP6TF67I4iou5+qZJc9twt+cZF5s5Iiluz9/q11JHQnJheqK3c64GgT b3aA6OH9pPRlCabKRBsi9ZNn3DgbmP5s4Q4b7SlcAbfhR8bNLH9/NIhShD2JNyLL8TWo 7DMQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r2si1932925ejj.90.2019.09.26.17.25.19; Thu, 26 Sep 2019 17:25:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727857AbfI0AZI (ORCPT + 8 others); Thu, 26 Sep 2019 20:25:08 -0400 Received: from mail-oi1-f196.google.com ([209.85.167.196]:38700 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727777AbfI0AZH (ORCPT ); Thu, 26 Sep 2019 20:25:07 -0400 Received: by mail-oi1-f196.google.com with SMTP id m16so3747036oic.5; Thu, 26 Sep 2019 17:25:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+Kwduh2L3Q3wglxQRQFNc0vVRF7aZPumhA9/VlLU+NE=; b=mjhcUDE8XUiETIYkOZkncJVwXFfDn3+5OtMOKkMygQtL0EMH6+dzILudd6EoFv4LRt NFOVho6exq84wuyEEwcJayqJJ6hzsSz6HAQK1rgWBpW1V52UgdUZe3AHwUtVGOGK73Y+ aw0vdIsvkAPuEyEvBkTE3pZmOdTDD7jIw35WNmM9Bx/iLhYrfQCtF7sZ0k7O4VdRjGbC LV4eBoFPJeKw4wt+FWwOuntgjxUqw9mhdypHpHS2W5oyE5EoT2EUSW7YqLecLlAfMsWl lD+3oBlaBBxy4s1L0rVECGMI0c5BFFOXhHwwxeKXX0kWFzxrj9kvJ9bT72PyFp6Uf5fX UN/A== X-Gm-Message-State: APjAAAW8KwnBEzAcWpKg7+K+BIwbrJgcq/hMxW7G8FI6SvMK3qn+OlK/ 0U7Iss5M88wxi5UOZ4txzZdhKvY= X-Received: by 2002:aca:540a:: with SMTP id i10mr4633085oib.108.1569543906002; Thu, 26 Sep 2019 17:25:06 -0700 (PDT) Received: from xps15.herring.priv (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.googlemail.com with ESMTPSA id j11sm339866otk.80.2019.09.26.17.25.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2019 17:25:05 -0700 (PDT) From: Rob Herring To: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Robin Murphy , Florian Fainelli , Stefan Wahren , Frank Rowand , Arnd Bergmann , Marek Vasut , Geert Uytterhoeven , Simon Horman , Lorenzo Pieralisi , Oza Pawandeep Subject: [PATCH 06/11] of/address: Introduce of_get_next_dma_parent() helper Date: Thu, 26 Sep 2019 19:24:50 -0500 Message-Id: <20190927002455.13169-7-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190927002455.13169-1-robh@kernel.org> References: <20190927002455.13169-1-robh@kernel.org> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Robin Murphy Add of_get_next_dma_parent() helper which is similar to __of_get_dma_parent(), but can be used in iterators and decrements the ref count on the prior parent. Signed-off-by: Robin Murphy Signed-off-by: Rob Herring --- drivers/of/address.c | 10 ++++++++++ 1 file changed, 10 insertions(+) -- 2.20.1 diff --git a/drivers/of/address.c b/drivers/of/address.c index 53d2656c2269..e9188c82fdae 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -695,6 +695,16 @@ static struct device_node *__of_get_dma_parent(const struct device_node *np) return of_node_get(args.np); } +static struct device_node *of_get_next_dma_parent(struct device_node *np) +{ + struct device_node *parent; + + parent = __of_get_dma_parent(np); + of_node_put(np); + + return parent; +} + u64 of_translate_dma_address(struct device_node *dev, const __be32 *in_addr) { struct device_node *host; From patchwork Fri Sep 27 00:24:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring \(Arm\)" X-Patchwork-Id: 174563 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2787821ill; Thu, 26 Sep 2019 17:25:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqyAUClAnYZ9WdRO+/lrzkjxQX/WJpho9ptrj0tfN/yjyQSftWNfY/8IZ5RhnC/133KyUIud X-Received: by 2002:a17:906:24c8:: with SMTP id f8mr5561614ejb.119.1569543937415; Thu, 26 Sep 2019 17:25:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569543937; cv=none; d=google.com; s=arc-20160816; b=Qfmfr97A8s5VHTZLrQ+uW6essgwOR9vtR0EXo8RJfYcH4vHuSwcLx+W1BGonl3c1Eq r0HNlTkGUiYy671fXiCUnP1lwJj/O6m4Z9m9To8IttYxheBLuuIxbUcsySmy2U9QE786 2QPt+cGaLw0Ohr11uGvFaQLgDtZwgIlM2sb/NbsQcB4UmLFKPYh8NscrI8ehRSh5VtQB NfGuT9/Y6CO0UMWPSVCCeV7Bem+l9z7CT2RFx1LmDALg2bLCsE3MmMiywl3fJFz/TfHg CEU5RXmSWGQGqkcDrwDX+s/eUmmqdo18VnXcmudhyHxrZFuIei/lnYmCAUEkoJbbBFwl QRBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=UKCh970cxpKTSE4xQt8EA5TvLAg6lDEOHEZjgVQOiEg=; b=vQ4cm64oWOkYPm5KFEInEj9GcjOkJJa9VhqhDfMZiiRJSAQz8sN6neg4jxqTzpjuxQ 3m9t8t1G5BrIqVe+0WrmgSrb2USmVL9hwjJqYotuXaIdQJmk6k0954jbd1i50dyVCCM/ NGO5LPnF7ptOyS1qRTzgsNhP5fgJGE4sSlpXKqbhqy9BwXNcLRhaJ6cEFvffVbbnhuKE LxEBAmguD14iKIgSFSWaNr1yFZr6gSmBZEML0r4CmF+gTriw3rdO34yKyiTdvLNVAbb+ rmPAxLUg/S5tX+wxEdkhn2xHr8UCM2d7Z7J7aqdB6p2dlHNwRJCd9u+u4Pq0V9yLfgLQ gWjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h13si565704edh.242.2019.09.26.17.25.35; Thu, 26 Sep 2019 17:25:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727502AbfI0AZf (ORCPT + 8 others); Thu, 26 Sep 2019 20:25:35 -0400 Received: from mail-oi1-f195.google.com ([209.85.167.195]:43244 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727901AbfI0AZK (ORCPT ); Thu, 26 Sep 2019 20:25:10 -0400 Received: by mail-oi1-f195.google.com with SMTP id t84so3722739oih.10; Thu, 26 Sep 2019 17:25:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UKCh970cxpKTSE4xQt8EA5TvLAg6lDEOHEZjgVQOiEg=; b=m5XwqiFEPWtXzRHdhcmEuQygNUQouhsLrY2JHWTLwtqq5PoobZbYBbU+pvp6Pv86T4 zKFmmaHDMIJdNrKNWILK2YLfjpagh6NpNpKk+geYxGfbyntI5DJ3lR57bAmQggJWaFNe fikGPltp5EMOy7riafYjMByhlXTfAqVaLKhMym5d84S2/CTBFDHvnVzTUjF4tG0SCMfO bTz5A6xsOi8EoYWqLJbOk/B47XR0KubRoCjwJfZtGVsznsBUcqtzuj/8q5H2DSvkcRsy zh9JTBZSoP8alAq8/dVcF6FumlTwfBSMsXi2SX9PLhowuI945KqN6mRMPxN629ktANF7 wJrg== X-Gm-Message-State: APjAAAW5ClND+nq5icmAYJQmaMe0cnWvML1G/wTJEQ1TferFYIMleKJp wvDrmcy+vbmlie1Iy0Z+i7RI+6w= X-Received: by 2002:a05:6808:316:: with SMTP id i22mr4935938oie.18.1569543908911; Thu, 26 Sep 2019 17:25:08 -0700 (PDT) Received: from xps15.herring.priv (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.googlemail.com with ESMTPSA id j11sm339866otk.80.2019.09.26.17.25.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2019 17:25:08 -0700 (PDT) From: Rob Herring To: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Robin Murphy , Florian Fainelli , Stefan Wahren , Frank Rowand , Arnd Bergmann , Marek Vasut , Geert Uytterhoeven , Simon Horman , Lorenzo Pieralisi , Oza Pawandeep Subject: [PATCH 08/11] of: Factor out #{addr,size}-cells parsing Date: Thu, 26 Sep 2019 19:24:52 -0500 Message-Id: <20190927002455.13169-9-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190927002455.13169-1-robh@kernel.org> References: <20190927002455.13169-1-robh@kernel.org> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Robin Murphy In some cases such as PCI host controllers, we may have a "parent bus" which is an OF leaf node, but still need to correctly parse ranges from the point of view of that bus. For that, factor out variants of the "#addr-cells" and "#size-cells" parsers which do not assume they have a device node and thus immediately traverse upwards before reading the relevant property. Signed-off-by: Robin Murphy [robh: don't make of_bus_n_{addr,size}_cells() public] Signed-off-by: Rob Herring --- drivers/of/address.c | 2 ++ drivers/of/base.c | 32 ++++++++++++++++++++++---------- drivers/of/of_private.h | 3 +++ 3 files changed, 27 insertions(+), 10 deletions(-) -- 2.20.1 Reviewed-by: Geert Uytterhoeven diff --git a/drivers/of/address.c b/drivers/of/address.c index 3fd34f7ad772..887c0413f648 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -14,6 +14,8 @@ #include #include +#include "of_private.h" + /* Max address size we deal with */ #define OF_MAX_ADDR_CELLS 4 #define OF_CHECK_ADDR_COUNT(na) ((na) > 0 && (na) <= OF_MAX_ADDR_CELLS) diff --git a/drivers/of/base.c b/drivers/of/base.c index 55e7f5bb0549..12b2e9287117 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -86,34 +86,46 @@ static bool __of_node_is_type(const struct device_node *np, const char *type) return np && match && type && !strcmp(match, type); } -int of_n_addr_cells(struct device_node *np) +int of_bus_n_addr_cells(struct device_node *np) { u32 cells; - do { - if (np->parent) - np = np->parent; + for (; np; np = np->parent) if (!of_property_read_u32(np, "#address-cells", &cells)) return cells; - } while (np->parent); + /* No #address-cells property for the root node */ return OF_ROOT_NODE_ADDR_CELLS_DEFAULT; } + +int of_n_addr_cells(struct device_node *np) +{ + if (np->parent) + np = np->parent; + + return of_bus_n_addr_cells(np); +} EXPORT_SYMBOL(of_n_addr_cells); -int of_n_size_cells(struct device_node *np) +int of_bus_n_size_cells(struct device_node *np) { u32 cells; - do { - if (np->parent) - np = np->parent; + for (; np; np = np->parent) if (!of_property_read_u32(np, "#size-cells", &cells)) return cells; - } while (np->parent); + /* No #size-cells property for the root node */ return OF_ROOT_NODE_SIZE_CELLS_DEFAULT; } + +int of_n_size_cells(struct device_node *np) +{ + if (np->parent) + np = np->parent; + + return of_bus_n_size_cells(np); +} EXPORT_SYMBOL(of_n_size_cells); #ifdef CONFIG_NUMA diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h index f8c58615c393..66294d29942a 100644 --- a/drivers/of/of_private.h +++ b/drivers/of/of_private.h @@ -158,6 +158,9 @@ extern void __of_sysfs_remove_bin_file(struct device_node *np, #define for_each_transaction_entry_reverse(_oft, _te) \ list_for_each_entry_reverse(_te, &(_oft)->te_list, node) +extern int of_bus_n_addr_cells(struct device_node *np); +extern int of_bus_n_size_cells(struct device_node *np); + #ifdef CONFIG_OF_ADDRESS extern int of_dma_get_range(struct device_node *np, u64 *dma_addr, u64 *paddr, u64 *size); From patchwork Fri Sep 27 00:24:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring \(Arm\)" X-Patchwork-Id: 174562 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2787779ill; Thu, 26 Sep 2019 17:25:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqxk5vhy5r8e8AdnvvF2rbFIN8tmURzNjUBsU9ENug0xGLSC6WucCz87zXhOLoSb7nCDurDU X-Received: by 2002:a17:906:c5b:: with SMTP id t27mr5503004ejf.180.1569543934014; Thu, 26 Sep 2019 17:25:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569543934; cv=none; d=google.com; s=arc-20160816; b=nznxymwLryi+qxdeSrhJoWwhLo1H0lZyCgX06nNuii31lFQx5QYmRizI3IivLOeffJ xNSrT4b5CXsil+SxzLma64EQ34fIVq5Q9liempTAjM/gZFLGY0upuMYtD2u2X6uwIjiz YFwz/s3x8oHD4FvDarYkfiNxQG35up0SuHVrc9vGByTVN9NcKaYbq94IAZE+K71iP9q7 pz44a4j5Qm7V1Su7/nXqziMrJRLVSMfjP1FZz2Gts8NfVR8fWq79nX8szxXV3vO3fqGb 1No5/FHhSArwMGPwBCQF0evJcltbwYrxhRmLWf58vM9Lxtu6eRp09EBt8j7qEE6JpQjv 3jIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=+t0HPsSboHAO+BoQ/6wZRtvX50rdRybsdCc4k/BGGOU=; b=BvdGPw4SsFmcPyFsTKFukUZmaTcDtXwF8LlLMuZZdDvPSQxW6vyR2/M+MU5TgP/2xa 0VGaAgpoWG/k9KR6r8KnwdKcWqTSf/Q0zQp2APLqJVzlx1KLWHf8zksrbeGNZ/3CGZYZ rKAvyG+NC4iGs7rCxnpBEoUNmJNNunS1D+vM2vpPr0igbTHRDzoLeeIMrWP8PLQLpT6y cSVBTIExcu4AsUsPOHA/rMvfBhIu3G81XtdH3tZgMKaIJhm/Z/bmRkTA1YFc2M/RhzrG 48FbJy5Dvp8dRjQZLurBRWqNalRxqdQq0IizvG5td/+Vvb/dgRF7NiR1cdQb65h3uTVt o55w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h13si565704edh.242.2019.09.26.17.25.33; Thu, 26 Sep 2019 17:25:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728261AbfI0AZ3 (ORCPT + 8 others); Thu, 26 Sep 2019 20:25:29 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:40639 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727502AbfI0AZL (ORCPT ); Thu, 26 Sep 2019 20:25:11 -0400 Received: by mail-ot1-f65.google.com with SMTP id y39so772543ota.7; Thu, 26 Sep 2019 17:25:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+t0HPsSboHAO+BoQ/6wZRtvX50rdRybsdCc4k/BGGOU=; b=Y2hs8wibHQWRr9khsCPMVE7x/hYmz8VyFMKZ7nsDW7EIqQ7FLtWyycylbMydY2OFwx Pdys6HOTJedGiOWVIt1qrvcRZniQPMhkminsdr3hZF0IOJ09Tc42bo7be1VJn0Co5eUX pWRbgyP/b4IUJWS92vjTzh0ubYwn/c4EN87ALJWhSeAFKTYV1rPEEBhDZkFCigjCAKLq BxApUizG0eaTvxc8xGbRKee0L5Xb0b7rZbcag6mWLMIY9O7fSZBw4m00kNdJ9pgOAIOD PvtYZE3xsca4YaRzP5yQh2XBW74ebhCI9kq5c55PPAfg5fo0kc4QaqjrMBqikEZsk0Te BT7A== X-Gm-Message-State: APjAAAWMH2ouL60j8rvfksR3DOLTw5q4EsclXPIgapS167oZhIn2X4um pm6eqnyUsRrgBl1uV3nvNv22SCY= X-Received: by 2002:a05:6830:4a5:: with SMTP id l5mr991746otd.150.1569543910071; Thu, 26 Sep 2019 17:25:10 -0700 (PDT) Received: from xps15.herring.priv (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.googlemail.com with ESMTPSA id j11sm339866otk.80.2019.09.26.17.25.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2019 17:25:09 -0700 (PDT) From: Rob Herring To: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Robin Murphy , Florian Fainelli , Stefan Wahren , Frank Rowand , Arnd Bergmann , Marek Vasut , Geert Uytterhoeven , Simon Horman , Lorenzo Pieralisi , Oza Pawandeep Subject: [PATCH 09/11] of: Make of_dma_get_range() work on bus nodes Date: Thu, 26 Sep 2019 19:24:53 -0500 Message-Id: <20190927002455.13169-10-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190927002455.13169-1-robh@kernel.org> References: <20190927002455.13169-1-robh@kernel.org> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Robin Murphy Since the "dma-ranges" property is only valid for a node representing a bus, of_dma_get_range() currently assumes the node passed in is a leaf representing a device, and starts the walk from its parent. In cases like PCI host controllers on typical FDT systems, however, where the PCI endpoints are probed dynamically the initial leaf node represents the 'bus' itself, and this logic means we fail to consider any "dma-ranges" describing the host bridge itself. Rework the logic such that of_dma_get_range() works correctly starting from a bus node containing "dma-ranges". Signed-off-by: Robin Murphy [robh: Allow for the bus child node to still be passed in] Signed-off-by: Rob Herring --- drivers/of/address.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) -- 2.20.1 diff --git a/drivers/of/address.c b/drivers/of/address.c index 887c0413f648..e918001c7798 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -922,18 +922,9 @@ int of_dma_get_range(struct device_node *np, u64 *dma_addr, u64 *paddr, u64 *siz if (!node) return -EINVAL; - while (1) { - struct device_node *parent; - - naddr = of_n_addr_cells(node); - nsize = of_n_size_cells(node); - - parent = __of_get_dma_parent(node); - of_node_put(node); - - node = parent; - if (!node) - break; + while (node) { + naddr = of_bus_n_addr_cells(node); + nsize = of_bus_n_size_cells(node); ranges = of_get_property(node, "dma-ranges", &len); @@ -941,12 +932,7 @@ int of_dma_get_range(struct device_node *np, u64 *dma_addr, u64 *paddr, u64 *siz if (ranges && len > 0) break; - /* - * At least empty ranges has to be defined for parent node if - * DMA is supported - */ - if (!ranges) - break; + node = of_get_next_dma_parent(node); } if (!ranges) { @@ -965,7 +951,7 @@ int of_dma_get_range(struct device_node *np, u64 *dma_addr, u64 *paddr, u64 *siz * size : nsize cells */ dmaaddr = of_read_number(ranges, naddr); - *paddr = of_translate_dma_address(np, ranges); + *paddr = of_translate_dma_address(node, ranges + naddr); if (*paddr == OF_BAD_ADDR) { pr_err("translation of DMA address(%llx) to CPU address failed node(%pOF)\n", dmaaddr, np); From patchwork Fri Sep 27 00:24:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring \(Arm\)" X-Patchwork-Id: 174561 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2787588ill; Thu, 26 Sep 2019 17:25:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqxOw7+KJE9kkbo1xx22sGUpD9LoxjAOUkLoB+M0kY94+g/v+EknzHjVDN7pHaGx46XFvGlx X-Received: by 2002:a50:9f42:: with SMTP id b60mr1754686edf.192.1569543921728; Thu, 26 Sep 2019 17:25:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569543921; cv=none; d=google.com; s=arc-20160816; b=KrJJO/9IQhckr5nYLhDw0/mj2zRqOb3TOpom3ZLcZ51mcnK6ixs0sDDDfhi095nEUf nDk3Ovm8Nn2PRl1ZCcaXVR+tj52YDARmfz+pJgp4+12b8XUfVAHMsH6JpPRg5lZMahLh 4qykO8/GmZXtMaRq266Hi52U3LqGEL2eo4I9m4p3PTRgeeRFSHfNMZv92gI9Z0oa+JGH OnYNrZ2rw+IQXDZCUhXgmIF/U/q3q9BYHX92XiKkzanMICKXEs3mB0FPgG7zqwuZk0Dx daPxKK0UX79eUC0nTZNkD5CQDblmNK6eriYbtQCDduBPswPknmw8YTo98CVgw26Bk0YN sQ2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=JSIM/mVNAQUFTI8poYL0tbeVsabT6n06A8LUKfKixqE=; b=YDk5UcGTgEnbAOwSe9ZAcDge76dCHyrDP2wKHJvAIU7sO+tjMjyGKHtIAmiXQS2S6G fm2JHkjaVdouCIyWA2G/pFDtLEH7A1KBNnqrRyBZw74xpGVij+WUwfVhjBy4e/p+EI0i KS1a68AhwW/FfsvsMUtB6zq8RxdmTGc8pZESMUC1vmSFwHwselCSY0A6MzirLaccZ8VR siOExdt957Gsyba2++73nXjBvjE8p1zrWoyKTl/sDLBkq+atrPkkcDaX39sP648yuVae V84uJDv3r0djXV4Q192b2sKmRT7lU7XObIVeH8ANNgIdtVcngoImJRjhhDwfnkl2Zsw7 2whw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r2si1932925ejj.90.2019.09.26.17.25.21; Thu, 26 Sep 2019 17:25:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728078AbfI0AZP (ORCPT + 8 others); Thu, 26 Sep 2019 20:25:15 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:45140 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727999AbfI0AZO (ORCPT ); Thu, 26 Sep 2019 20:25:14 -0400 Received: by mail-ot1-f68.google.com with SMTP id 41so745907oti.12; Thu, 26 Sep 2019 17:25:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JSIM/mVNAQUFTI8poYL0tbeVsabT6n06A8LUKfKixqE=; b=UwbwatXpaojKG2T+EF0sCiKPxLZzbRNJCRU/1l4Hdor8K7puYEzz/EjhB7MA6hB/Vb ReCpYSa12FvcLXDltZ458bNPHiGhEJ60H7BzzDWz7/VbBISP0kKMDqtaHQDL+CYjSnEx CfG1OhLDFNtj0XErLDT8KuDFudbktd1zwRaDwS7TwRsaJKMaVxXlgBFdCCQ+gFUwxUIX a2EcA1dMw8jmt8OkSkfgzLGNfUfyiidQRMFzXg7aCORwIRV5ynfL1byMsDfSLwbgffJg PrZqSH7tRcNwks6UQx+iWY6mmluHTHmJH3dsilME2nj3vR+wx56WlNOuSMP8eHRpNux/ sE0g== X-Gm-Message-State: APjAAAUy1TlVx2uo3KNBAj+rUIhzBoC3oIn7MeXs57P+5B3928O1fBYU /kG3dRY49RfZzU4+92MeJMfS6Xs= X-Received: by 2002:a9d:6d0a:: with SMTP id o10mr991391otp.221.1569543911563; Thu, 26 Sep 2019 17:25:11 -0700 (PDT) Received: from xps15.herring.priv (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.googlemail.com with ESMTPSA id j11sm339866otk.80.2019.09.26.17.25.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2019 17:25:11 -0700 (PDT) From: Rob Herring To: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Robin Murphy , Florian Fainelli , Stefan Wahren , Frank Rowand , Arnd Bergmann , Marek Vasut , Geert Uytterhoeven , Simon Horman , Lorenzo Pieralisi , Oza Pawandeep Subject: [PATCH 10/11] of/address: Translate 'dma-ranges' for parent nodes missing 'dma-ranges' Date: Thu, 26 Sep 2019 19:24:54 -0500 Message-Id: <20190927002455.13169-11-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190927002455.13169-1-robh@kernel.org> References: <20190927002455.13169-1-robh@kernel.org> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 'dma-ranges' frequently exists without parent nodes having 'dma-ranges'. While this is an error for 'ranges', this is fine because DMA capable devices always have a translatable DMA address. Also, with no 'dma-ranges' at all, the assumption is that DMA addresses are 1:1 with no restrictions unless perhaps the device itself has implicit restrictions. Cc: Robin Murphy Signed-off-by: Rob Herring --- drivers/of/address.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/drivers/of/address.c b/drivers/of/address.c index e918001c7798..5b835d332709 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -519,9 +519,13 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus, * * As far as we know, this damage only exists on Apple machines, so * This code is only enabled on powerpc. --gcl + * + * This quirk also applies for 'dma-ranges' which frequently exist in + * child nodes without 'dma-ranges' in the parent nodes. --RobH */ ranges = of_get_property(parent, rprop, &rlen); - if (ranges == NULL && !of_empty_ranges_quirk(parent)) { + if (ranges == NULL && !of_empty_ranges_quirk(parent) && + strcmp(rprop, "dma-ranges")) { pr_debug("no ranges; cannot translate\n"); return 1; } From patchwork Fri Sep 27 00:24:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring \(Arm\)" X-Patchwork-Id: 174559 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2787579ill; Thu, 26 Sep 2019 17:25:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqwD0/CaTVvXrngA+m9cmv0Es8G9uqhJQBxVTYJWWXyWsGtKwvuQt+XNO0/24VEPV7HpjlCz X-Received: by 2002:a17:906:1c5b:: with SMTP id l27mr5661784ejg.27.1569543921270; Thu, 26 Sep 2019 17:25:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569543921; cv=none; d=google.com; s=arc-20160816; b=W5r6vlEBBH5bhAF/qCuvWvalVkShP7rbrwpLmZzttNTD30VDkDGtPtOLcxqR+DKfJF PN7/OPrKXfgcdyDaQkuRXBh0l3oBntI9jnkg8tnqIOBW0UsLBqP4PFWsIfqokueNbsjc Q3JZI3FxiF5qMtwFRwysWiOHtGQl5k/H/S15yaTsC4BcWDVsCcMNpoLRTczlql+H9KSi CNbVhZk/TsgL2wscerhMAkeHmnEXVHOHw04z0OGHc5RHA5EwLQUv//F3nrON4ww1UwbF qZoANtfeje28ZK2k5MMmiu/GPc9AovEf0eC8x5HkcWWKVNy9CXIGCN3HoY+bdCGXFE5b D/EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=KvE1OjQp2Eo5TOhHCna2F9pDoURrQBiIlsatoh/ojtA=; b=Dk1Di/Q6E1HLW+KI9E0f/ehWpOcqhT5VAtGau46az8RyehlVJm73z2Lxlx6nkVKP9v HBM4FnOBMqU42IpfihJIwCzqO7/eAAcSEL9jSt8Aa5tcBK25gjxLtkOKYKCXJJ3cZF4Z 1KQW9iCtQ/yGa4f1aaiHDkwflHAaBheoVj0ccXRSvzixsmaaKtWWnQiBUBz2kxdnjX+1 Je3Qzj5iNmzYlRzqv9DH3GplfUbdNasSBjv9ZSrNUQe3+/MALSz4hzqK/g4Kkp1j/Xhr YLgT7RZ8zOed3RXNWatb4hUC6uYZm5F+OVSNfm+uSPwCV3CuKgrJHU1FAZgKd0OqTIbv CGtg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r2si1932925ejj.90.2019.09.26.17.25.21; Thu, 26 Sep 2019 17:25:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728041AbfI0AZP (ORCPT + 8 others); Thu, 26 Sep 2019 20:25:15 -0400 Received: from mail-oi1-f195.google.com ([209.85.167.195]:33271 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728003AbfI0AZO (ORCPT ); Thu, 26 Sep 2019 20:25:14 -0400 Received: by mail-oi1-f195.google.com with SMTP id e18so3767601oii.0; Thu, 26 Sep 2019 17:25:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KvE1OjQp2Eo5TOhHCna2F9pDoURrQBiIlsatoh/ojtA=; b=KqYGlp4pnmNRkjgrtDJgECRHf1rpz2lNXLgnDrdZTmWoQOC+25/QKZtUkGcGBZ2MuG +1x0fm1hlBsfW5UNwdciNVoIxhvFoLj0slGnorylKWqjR960G+fgqUfylYBaBtnLrEK8 BvA59sYp08yFmC61qmHiujPvI4aGdJVivsF9vnZVGiqLtWYG3zATyAsQwn8JPze4b1hS 4tKA94mxv/Vvpk32tlwmP1JpQnKx5PpNRlnHP5/TnMfxIaHNZ4RaOqo0JBU8AdntxtTn hNXqTSnwdep+F+QLxG4vFvSPHt3XQerAcY+9zpnPZ84CFKIdzhyQPDxSXGViljO2oB6b 85aQ== X-Gm-Message-State: APjAAAXIHkETXzCMwxGJlQpNnmK+FX7+eCBnqF/zKARK2svJyUm2/YtN QPEXH1JaPw0RNhjzMgz3OPEqBrs= X-Received: by 2002:a05:6808:b0d:: with SMTP id s13mr4936115oij.52.1569543912890; Thu, 26 Sep 2019 17:25:12 -0700 (PDT) Received: from xps15.herring.priv (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.googlemail.com with ESMTPSA id j11sm339866otk.80.2019.09.26.17.25.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2019 17:25:12 -0700 (PDT) From: Rob Herring To: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Robin Murphy , Florian Fainelli , Stefan Wahren , Frank Rowand , Arnd Bergmann , Marek Vasut , Geert Uytterhoeven , Simon Horman , Lorenzo Pieralisi , Oza Pawandeep Subject: [PATCH 11/11] of/address: Fix of_pci_range_parser_one translation of DMA addresses Date: Thu, 26 Sep 2019 19:24:55 -0500 Message-Id: <20190927002455.13169-12-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190927002455.13169-1-robh@kernel.org> References: <20190927002455.13169-1-robh@kernel.org> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org of_pci_range_parser_one() has a bug when parsing dma-ranges. When it translates the parent address (aka cpu address in the code), 'ranges' is always being used. This happens to work because most users are just 1:1 translation. Cc: Robin Murphy Signed-off-by: Rob Herring --- drivers/of/address.c | 15 ++++++++++++--- include/linux/of_address.h | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) -- 2.20.1 diff --git a/drivers/of/address.c b/drivers/of/address.c index 5b835d332709..54011a355b81 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -243,6 +243,7 @@ static int parser_init(struct of_pci_range_parser *parser, parser->node = node; parser->pna = of_n_addr_cells(node); parser->np = parser->pna + na + ns; + parser->dma = !strcmp(name, "dma-ranges"); parser->range = of_get_property(node, name, &rlen); if (parser->range == NULL) @@ -281,7 +282,11 @@ struct of_pci_range *of_pci_range_parser_one(struct of_pci_range_parser *parser, range->pci_space = be32_to_cpup(parser->range); range->flags = of_bus_pci_get_flags(parser->range); range->pci_addr = of_read_number(parser->range + 1, ns); - range->cpu_addr = of_translate_address(parser->node, + if (parser->dma) + range->cpu_addr = of_translate_dma_address(parser->node, + parser->range + na); + else + range->cpu_addr = of_translate_address(parser->node, parser->range + na); range->size = of_read_number(parser->range + parser->pna + na, ns); @@ -294,8 +299,12 @@ struct of_pci_range *of_pci_range_parser_one(struct of_pci_range_parser *parser, flags = of_bus_pci_get_flags(parser->range); pci_addr = of_read_number(parser->range + 1, ns); - cpu_addr = of_translate_address(parser->node, - parser->range + na); + if (parser->dma) + cpu_addr = of_translate_dma_address(parser->node, + parser->range + na); + else + cpu_addr = of_translate_address(parser->node, + parser->range + na); size = of_read_number(parser->range + parser->pna + na, ns); if (flags != range->flags) diff --git a/include/linux/of_address.h b/include/linux/of_address.h index ddda3936039c..eac7ab109df4 100644 --- a/include/linux/of_address.h +++ b/include/linux/of_address.h @@ -12,6 +12,7 @@ struct of_pci_range_parser { const __be32 *end; int np; int pna; + bool dma; }; struct of_pci_range {