From patchwork Tue Jan 31 20:16:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nate Watterson X-Patchwork-Id: 9548405 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ADEAC60415 for ; Tue, 31 Jan 2017 20:21:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D3F42711E for ; Tue, 31 Jan 2017 20:21:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9066427F86; Tue, 31 Jan 2017 20:21:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09D262711E for ; Tue, 31 Jan 2017 20:21:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751232AbdAaUV0 (ORCPT ); Tue, 31 Jan 2017 15:21:26 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:55400 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751117AbdAaUVZ (ORCPT ); Tue, 31 Jan 2017 15:21:25 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 1F3F560BFE; Tue, 31 Jan 2017 20:21:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1485894084; bh=EqHDbi46a84NPM2mEeoGPZXjDmU30NbdlqQ5DmwOrwI=; h=From:To:Subject:Date:From; b=XbFgWocpC7u78j1cr7TPdKcou+3pRzXmJgultRgCS4oi04Sen1tcV3p8WzQVv3Xy7 pTfRQymT36xNJnD5uIm7B917UURDnIpBXG+BpyV1WBfN1S7Q+54mOu0D2PC+eoXZae lZm0TMKTJjmlbq/p7e86gd+c0x0MabcmHhrFDXtw= Received: from ssd-mint172.qualcomm.com (global_nat1_iad_fw.qualcomm.com [129.46.232.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: nwatters@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 14953607C0; Tue, 31 Jan 2017 20:21:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1485894082; bh=EqHDbi46a84NPM2mEeoGPZXjDmU30NbdlqQ5DmwOrwI=; h=From:To:Subject:Date:From; b=mD2jVac/5YzSyo3F0H5+tWwLWZIGM125FllmdriQ4BuTEjmHBTlaa1wlmhP0/SAwi lTpUisUfuzUBZ/SyMTm4w+yxzlAXwdNRRynAKXTuTx/pUtIsOABe95mmQafSj/NjKQ NlFU2GxIrLZKkbgD+xDD34H+uQB4ZQX9xfD8XuMI= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 14953607C0 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 From: Nate Watterson To: Lorenzo Pieralisi , Hanjun Guo , Sudeep Holla , "Rafael J. Wysocki" , Len Brown , Tomasz Nowicki , Will Deacon , Nate Watterson , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] ACPI/IORT: add iort_get_memory_address_limit function Date: Tue, 31 Jan 2017 15:16:00 -0500 Message-Id: <1485893763-20671-1-git-send-email-nwatters@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The memory_address_limit field present in IORT named component nodes describes the effective number of address bits that a device can use when accessing memory. Because this information has value when creating or validating device dma_masks, the aforementioned accessor function is introduced. Signed-off-by: Nate Watterson --- drivers/acpi/arm64/iort.c | 25 +++++++++++++++++++++++++ include/linux/acpi_iort.h | 3 +++ 2 files changed, 28 insertions(+) diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c index e0d2e6e..cd5d5f4 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -569,6 +569,31 @@ void iort_set_dma_mask(struct device *dev) } /** + * iort_get_memory_address_limit - If a named component node exists in the IORT + * for a device, get the number of address bits + * that the device can effectively use when + * accessing memory. + * + * @dev: The device + * + * Returns: ENOENT when no corresponding named component node found for dev + * Named component memory_address_limit field otherwise + */ +int iort_get_memory_address_limit(struct device *dev) +{ + 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 -ENOENT; + + ncomp = (struct acpi_iort_named_component *)node->node_data; + return ncomp->memory_address_limit; +} + +/** * iort_iommu_configure - Set-up IOMMU configuration for a device. * * @dev: device to configure diff --git a/include/linux/acpi_iort.h b/include/linux/acpi_iort.h index 77e0809..677b9c4 100644 --- a/include/linux/acpi_iort.h +++ b/include/linux/acpi_iort.h @@ -36,6 +36,7 @@ struct irq_domain *iort_get_device_domain(struct device *dev, u32 req_id); /* IOMMU interface */ void iort_set_dma_mask(struct device *dev); +int iort_get_memory_address_limit(struct device *dev); const struct iommu_ops *iort_iommu_configure(struct device *dev); #else static inline void acpi_iort_init(void) { } @@ -47,6 +48,8 @@ static inline struct irq_domain *iort_get_device_domain(struct device *dev, { return NULL; } /* IOMMU interface */ static inline void iort_set_dma_mask(struct device *dev) { } +static inline int iort_get_memory_address_limit(struct device *dev) +{ return -ENOENT; } static inline const struct iommu_ops *iort_iommu_configure(struct device *dev) { return NULL; }