Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752816AbdHBRbM (ORCPT ); Wed, 2 Aug 2017 13:31:12 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:50548 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751192AbdHBRbK (ORCPT ); Wed, 2 Aug 2017 13:31:10 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org A5E16607E2 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=nwatters@codeaurora.org Subject: Re: [PATCH v2 5/5] ACPI/IORT: Add IORT named component memory address limits To: Lorenzo Pieralisi , linux-acpi@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Will Deacon , Robin Murphy , Robert Moore , Hanjun Guo , Feng Kan , Jon Masters , Zhang Rui , "Rafael J. Wysocki" References: <20170731152323.32488-1-lorenzo.pieralisi@arm.com> <20170731152323.32488-6-lorenzo.pieralisi@arm.com> From: Nate Watterson Message-ID: Date: Wed, 2 Aug 2017 13:31:03 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170731152323.32488-6-lorenzo.pieralisi@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2741 Lines: 87 Hi Lorenzo, I ran a quick test and this seems to work for memory_address_limit < 64, however memory_address_limit == 64 yields a mask of 0x0. -Nate On 7/31/2017 11:23 AM, Lorenzo Pieralisi wrote: > IORT named components provide firmware configuration describing > how many address bits a given device is capable of generating > to address memory. > > Add code to the kernel to retrieve memory address limits > configuration for IORT named components and configure DMA masks > accordingly. > > Signed-off-by: Lorenzo Pieralisi > Cc: Will Deacon > Cc: Robin Murphy > Cc: Nate Watterson > --- > drivers/acpi/arm64/iort.c | 40 ++++++++++++++++++++++++++++++---------- > 1 file changed, 30 insertions(+), 10 deletions(-) > > diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c > index 67b85ae..b85d19f 100644 > --- a/drivers/acpi/arm64/iort.c > +++ b/drivers/acpi/arm64/iort.c > @@ -680,6 +680,24 @@ static const struct iommu_ops *iort_iommu_xlate(struct device *dev, > return ret ? NULL : ops; > } > > +static int nc_dma_get_range(struct device *dev, u64 *size) > +{ > + struct acpi_iort_node *node; > + struct acpi_iort_named_component *ncomp; > + > + node = iort_scan_node(ACPI_IORT_NODE_NAMED_COMPONENT, > + iort_match_node_callback, dev); > + if (!node) > + return -ENODEV; > + > + ncomp = (struct acpi_iort_named_component *)node->node_data; > + > + *size = ncomp->memory_address_limit >= 64 ? ~0ULL : > + 1ULL<memory_address_limit; > + > + return 0; > +} > + > /** > * iort_dma_setup() - Set-up device DMA parameters. > * > @@ -708,17 +726,19 @@ void iort_dma_setup(struct device *dev, u64 *dma_addr, u64 *dma_size) > > size = max(dev->coherent_dma_mask, dev->coherent_dma_mask + 1); > > - if (dev_is_pci(dev)) { > + if (dev_is_pci(dev)) > ret = acpi_dma_get_range(dev, &dmaaddr, &offset, &size); > - if (!ret) { > - mask = __roundup_pow_of_two(dmaaddr + size) - 1; > - /* > - * Limit coherent and dma mask based on size > - * retrieved from firmware. > - */ > - dev->coherent_dma_mask = mask; > - *dev->dma_mask = mask; > - } > + else > + ret = nc_dma_get_range(dev, &size); > + > + if (!ret) { > + mask = __roundup_pow_of_two(dmaaddr + size) - 1; > + /* > + * Limit coherent and dma mask based on size > + * retrieved from firmware. > + */ > + dev->coherent_dma_mask = mask; > + *dev->dma_mask = mask; > } > > *dma_addr = dmaaddr; > -- Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.