From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932531AbdECUHD (ORCPT ); Wed, 3 May 2017 16:07:03 -0400 Received: from mail.kernel.org ([198.145.29.136]:40998 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932452AbdECUGy (ORCPT ); Wed, 3 May 2017 16:06:54 -0400 MIME-Version: 1.0 In-Reply-To: <1493786795-28153-3-git-send-email-oza.oza@broadcom.com> References: <1493786795-28153-1-git-send-email-oza.oza@broadcom.com> <1493786795-28153-3-git-send-email-oza.oza@broadcom.com> From: Rob Herring Date: Wed, 3 May 2017 15:06:27 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 3/3] PCI/of fix of_dma_get_range; get PCI specific dma-ranges To: Oza Pawandeep Cc: Joerg Roedel , Robin Murphy , Linux IOMMU , "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "devicetree@vger.kernel.org" , "bcm-kernel-feedback-list@broadcom.com" , Oza Pawandeep Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 2, 2017 at 11:46 PM, Oza Pawandeep wrote: > current device framework and of framework integration assumes > dma-ranges in a way where memory-mapped devices define their > dma-ranges. (child-bus-address, parent-bus-address, length). > > of_dma_configure is specifically written to take care of memory > mapped devices. but no implementation exists for pci to take > care of pcie based memory ranges. > > for e.g. iproc based SOCs and other SOCs(suc as rcar) have PCI > world dma-ranges. > dma-ranges = <0x43000000 0x00 0x00 0x00 0x00 0x80 0x00>; > > this patch fixes this patch fixes the bug in of_dma_get_range, > which with as is, parses the PCI memory ranges and return wrong > size as 0. > > in order to get largest possible dma_mask. this patch also > retuns the largest possible size based on dma-ranges, > > for e.g. > dma-ranges = <0x43000000 0x00 0x00 0x00 0x00 0x80 0x00>; > we should get dev->coherent_dma_mask=0x7fffffffff. > > based on which iova allocation space will honour PCI host > bridge limitations. > > Bug: SOC-5216 > Change-Id: I4c534bdd17e70c6b27327d39d1656e8ed0cf56d6 > Signed-off-by: Oza Pawandeep > Reviewed-on: http://gerrit-ccxsw.broadcom.net/40762 > Reviewed-by: vpx_checkpatch status > Reviewed-by: CCXSW > Reviewed-by: Scott Branden > Tested-by: vpx_autobuild status > Tested-by: vpx_smoketest status > > diff --git a/drivers/of/address.c b/drivers/of/address.c > index 02b2903..f7734fc 100644 > --- a/drivers/of/address.c > +++ b/drivers/of/address.c > @@ -6,6 +6,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -830,6 +831,54 @@ int of_dma_get_range(struct device_node *np, u64 *dma_addr, u64 *paddr, u64 *siz > int ret = 0; > u64 dmaaddr; > > +#ifdef CONFIG_PCI > + struct resource_entry *window; > + LIST_HEAD(res); > + > + if (!node) > + return -EINVAL; > + > + if (of_bus_pci_match(np)) { You are not following what I'm saying. Let me spell it out: - Add a get_dma_ranges() function to of_bus struct. Or maybe should cover ranges too (e.g. get_ranges). I'm not sure. - Convert existing contents of this function to of_bus_default_dma_get_ranges and add that to the default of_bus struct. - Make of_dma_get_range call of_bus_match() and then bus->get_dma_ranges. Rob