From patchwork Fri Nov 6 13:22:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 7569201 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0CB609F71A for ; Fri, 6 Nov 2015 13:23:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 480B82073E for ; Fri, 6 Nov 2015 13:23:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 80C43206A2 for ; Fri, 6 Nov 2015 13:23:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033223AbbKFNWy (ORCPT ); Fri, 6 Nov 2015 08:22:54 -0500 Received: from mga02.intel.com ([134.134.136.20]:59671 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033190AbbKFNWw (ORCPT ); Fri, 6 Nov 2015 08:22:52 -0500 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP; 06 Nov 2015 05:22:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,252,1444719600"; d="scan'208,223";a="679719070" Received: from dwli-mobl2.ccr.corp.intel.com (HELO [10.255.27.57]) ([10.255.27.57]) by orsmga003.jf.intel.com with ESMTP; 06 Nov 2015 05:22:46 -0800 Subject: Re: [Patch v7 4/7] PCI/ACPI: Add interface acpi_pci_root_create() To: Tomasz Nowicki References: <1444804182-6596-1-git-send-email-jiang.liu@linux.intel.com> <1444804182-6596-5-git-send-email-jiang.liu@linux.intel.com> <563B65EE.7000406@semihalf.com> <20151105181959.GA352@red-moon> <563C6A5F.5030500@linux.intel.com> <563C82FA.7050707@semihalf.com> <563C930F.4060206@linux.intel.com> <563C9FBE.2090303@semihalf.com> Cc: Lorenzo Pieralisi , Bjorn Helgaas , "Rafael J . Wysocki" , Marc Zyngier , Hanjun Guo , Liviu Dudau , linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org From: Jiang Liu Organization: Intel Message-ID: <563CA9A6.7050309@linux.intel.com> Date: Fri, 6 Nov 2015 21:22:46 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <563C9FBE.2090303@semihalf.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 2015/11/6 20:40, Tomasz Nowicki wrote: > On 06.11.2015 12:46, Jiang Liu wrote: >> On 2015/11/6 18:37, Tomasz Nowicki wrote: >>> On 06.11.2015 09:52, Jiang Liu wrote: >>> Sure, ARM64 (0-16M IO space) QEMU example: >>> DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, >>> 0x00000000, // Granularity >>> 0x00000000, // Range Minimum >>> 0x0000FFFF, // Range Maximum >>> 0x3EFF0000, // Translation Offset >>> 0x00010000, // Length >>> ,, , TypeStatic) >> The above DWordIO resource descriptor doesn't confirm to the ACPI spec. >> According to my understanding, ARM/ARM64 has no concept of IO port >> address space, so the PCI host bridge will map IO port on PCI side >> onto MMIO on host side. In other words, PCI host bridge on ARM64 >> implement a IO Port->MMIO translation instead of a IO Port->IO Port >> translation. If that's true, it should use 'TypeTranslation' instead >> of 'TypeStatic'. And kernel ACPI resource parsing interface doesn't >> support 'TypeTranslation' yet, so we need to find a solution for it. > > I think you are right, we need TypeTranslation flag for ARM64 DWordIO > descriptors and an extra kernel patch to support it. How about the attached to patch to support TypeTranslation? It only passes compilation:) > > Thanks, > Tomasz From 51f5cddd8c4301b731805074ebc3e3a6c7dbaf59 Mon Sep 17 00:00:00 2001 From: Liu Jiang Date: Fri, 6 Nov 2015 20:01:59 +0800 Subject: [PATCH] Signed-off-by: Liu Jiang --- drivers/acpi/resource.c | 25 +++++++++++++++++++++++-- include/linux/resource_ext.h | 7 +++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c index cdc5c2599beb..1bd3e21f56fe 100644 --- a/drivers/acpi/resource.c +++ b/drivers/acpi/resource.c @@ -215,8 +215,29 @@ static bool acpi_decode_space(struct resource_win *win, else if (attr->translation_offset) pr_debug("ACPI: translation_offset(%lld) is invalid for non-bridge device.\n", attr->translation_offset); - start = attr->minimum + offset; - end = attr->maximum + offset; + start = attr->minimum; + end = attr->maximum; + + /* + * Convert bus local address into system global address if it's an + * IO Port->IO Port or MMIO->MMIO translation. + */ + switch (addr->resource_type) { + case ACPI_MEMORY_RANGE: + if (addr->info.mem.translation) + win->translation_type = RESOURCE_TRANS_MMIO_TO_IOPORT; + else + start += offset; + break; + case ACPI_IO_RANGE: + if (addr->info.io.translation) + win->translation_type = RESOURCE_TRANS_IOPORT_TO_MMIO; + else + start += offset; + break; + default: + break; + } win->offset = offset; res->start = start; diff --git a/include/linux/resource_ext.h b/include/linux/resource_ext.h index e2bf63d881d4..f06d358c1f22 100644 --- a/include/linux/resource_ext.h +++ b/include/linux/resource_ext.h @@ -22,8 +22,15 @@ struct resource_win { struct resource res; /* In master (CPU) address space */ resource_size_t offset; /* Translation offset for bridge */ + int translation_type; /* Translation type for bridge */ }; +#define RESOURCE_TRANS_SAME 0x0 +/* Translate from IO port on slave into MMIO on master */ +#define RESOURCE_TRANS_IOPORT_TO_MMIO 0x1 +/* Translate from MMIO on slave into IO port on master */ +#define RESOURCE_TRANS_MMIO_TO_IOPORT 0x2 + /* * Common resource list management data structure and interfaces to support * ACPI, PNP and PCI host bridge etc. -- 1.7.10.4