From patchwork Tue Nov 29 18:43:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 9452981 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 D08586071C for ; Tue, 29 Nov 2016 18:45:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1E08283D3 for ; Tue, 29 Nov 2016 18:45:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6CB6283ED; Tue, 29 Nov 2016 18:45:38 +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=-1.7 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_MED,SUSPICIOUS_RECIPS autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2B0FD283D3 for ; Tue, 29 Nov 2016 18:45:38 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBnO1-0002zi-3W; Tue, 29 Nov 2016 18:44:13 +0000 Received: from mail.kernel.org ([198.145.29.136]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBnNc-0002af-I2 for linux-arm-kernel@lists.infradead.org; Tue, 29 Nov 2016 18:43:50 +0000 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F33EB20149; Tue, 29 Nov 2016 18:43:28 +0000 (UTC) Received: from localhost (unknown [69.55.156.165]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 97A8320142; Tue, 29 Nov 2016 18:43:27 +0000 (UTC) Subject: [PATCH 1/2] ACPI: Combine acpi_dev_resource_address_space() and acpi_dev_resource_ext_address_space() From: Bjorn Helgaas To: linux-pci@vger.kernel.org Date: Tue, 29 Nov 2016 12:43:26 -0600 Message-ID: <20161129184326.7618.60729.stgit@bhelgaas-glaptop.roam.corp.google.com> In-Reply-To: <20161129182415.7618.99129.stgit@bhelgaas-glaptop.roam.corp.google.com> References: <20161129182415.7618.99129.stgit@bhelgaas-glaptop.roam.corp.google.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161129_104348_774695_EAC847F7 X-CRM114-Status: GOOD ( 15.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linaro-acpi@lists.linaro.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Previously acpi_dev_resource_address_space() and acpi_dev_resource_ext_address_space() were wrappers that called acpi_decode_space(). We need to distinguish between Word/DWord/QWord address descriptors and Extended address descriptors, which was impossible in acpi_decode_space(). Fold the acpi_dev_resource_address_space() and acpi_dev_resource_ext_address_space() functionality into acpi_decode_space() and call the result acpi_dev_resource_address_space(). No functional change intended. Signed-off-by: Bjorn Helgaas --- drivers/acpi/ioapic.c | 3 - drivers/acpi/resource.c | 114 ++++++++++++++++------------------------ drivers/pnp/pnpacpi/rsparser.c | 3 - include/linux/acpi.h | 2 - 4 files changed, 48 insertions(+), 74 deletions(-) diff --git a/drivers/acpi/ioapic.c b/drivers/acpi/ioapic.c index 6d7ce6e..6d91417 100644 --- a/drivers/acpi/ioapic.c +++ b/drivers/acpi/ioapic.c @@ -50,8 +50,7 @@ static acpi_status setup_res(struct acpi_resource *acpi_res, void *data) return AE_OK; if (!acpi_dev_resource_memory(acpi_res, res)) { - if (acpi_dev_resource_address_space(acpi_res, &win) || - acpi_dev_resource_ext_address_space(acpi_res, &win)) + if (acpi_dev_resource_address_space(acpi_res, &win)) *res = win.res; } if ((res->flags & IORESOURCE_PREFETCH) || diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c index 56241eb..2732d39e 100644 --- a/drivers/acpi/resource.c +++ b/drivers/acpi/resource.c @@ -197,16 +197,54 @@ bool acpi_dev_resource_io(struct acpi_resource *ares, struct resource *res) } EXPORT_SYMBOL_GPL(acpi_dev_resource_io); -static bool acpi_decode_space(struct resource_win *win, - struct acpi_resource_address *addr, - struct acpi_address64_attribute *attr) +/** + * acpi_dev_resource_address_space - Extract ACPI address space information. + * @ares: Input ACPI resource object. + * @win: Output generic resource object. + * + * Check if the given ACPI resource object represents an address space resource + * and if that's the case, use the information in it to populate the generic + * resource object pointed to by @win. + * + * Return: + * 1) false with win->res.flags setting to zero: not the expected resource type + * 2) false with IORESOURCE_DISABLED in win->res.flags: valid unassigned + * resource + * 3) true: valid assigned resource + XXX check these return values + */ +bool acpi_dev_resource_address_space(struct acpi_resource *ares, + struct resource_win *win) { - u8 iodec = attr->granularity == 0xfff ? ACPI_DECODE_10 : ACPI_DECODE_16; - bool wp = addr->info.mem.write_protect; - u64 len = attr->address_length; - u64 start, end, offset = 0; + struct acpi_resource_address *addr; + struct acpi_address64_attribute *attr; + struct acpi_resource_extended_address64 *ext_addr; + struct acpi_resource_address64 addr64; + acpi_status status; + u8 iodec; + bool wp; + u64 len, start, end, offset = 0; struct resource *res = &win->res; + win->res.flags = 0; + + if (ares->type == ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64) { + ext_addr = &ares->data.ext_address64; + addr = (struct acpi_resource_address *)ext_addr; + attr = &ext_addr->address; + } else { + status = acpi_resource_to_address64(ares, &addr64); + if (ACPI_FAILURE(status)) + return false; + + addr = (struct acpi_resource_address *)&addr64; + attr = &addr64.address; + } + + iodec = attr->granularity == 0xfff ? ACPI_DECODE_10 : ACPI_DECODE_16; + wp = addr->info.mem.write_protect; + len = attr->address_length; + /* * Filter out invalid descriptor according to ACPI Spec 5.0, section * 6.4.3.5 Address Space Resource Descriptors. @@ -264,68 +302,9 @@ static bool acpi_decode_space(struct resource_win *win, return !(res->flags & IORESOURCE_DISABLED); } - -/** - * acpi_dev_resource_address_space - Extract ACPI address space information. - * @ares: Input ACPI resource object. - * @win: Output generic resource object. - * - * Check if the given ACPI resource object represents an address space resource - * and if that's the case, use the information in it to populate the generic - * resource object pointed to by @win. - * - * Return: - * 1) false with win->res.flags setting to zero: not the expected resource type - * 2) false with IORESOURCE_DISABLED in win->res.flags: valid unassigned - * resource - * 3) true: valid assigned resource - */ -bool acpi_dev_resource_address_space(struct acpi_resource *ares, - struct resource_win *win) -{ - struct acpi_resource_address64 addr; - - win->res.flags = 0; - if (ACPI_FAILURE(acpi_resource_to_address64(ares, &addr))) - return false; - - return acpi_decode_space(win, (struct acpi_resource_address *)&addr, - &addr.address); -} EXPORT_SYMBOL_GPL(acpi_dev_resource_address_space); /** - * acpi_dev_resource_ext_address_space - Extract ACPI address space information. - * @ares: Input ACPI resource object. - * @win: Output generic resource object. - * - * Check if the given ACPI resource object represents an extended address space - * resource and if that's the case, use the information in it to populate the - * generic resource object pointed to by @win. - * - * Return: - * 1) false with win->res.flags setting to zero: not the expected resource type - * 2) false with IORESOURCE_DISABLED in win->res.flags: valid unassigned - * resource - * 3) true: valid assigned resource - */ -bool acpi_dev_resource_ext_address_space(struct acpi_resource *ares, - struct resource_win *win) -{ - struct acpi_resource_extended_address64 *ext_addr; - - win->res.flags = 0; - if (ares->type != ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64) - return false; - - ext_addr = &ares->data.ext_address64; - - return acpi_decode_space(win, (struct acpi_resource_address *)ext_addr, - &ext_addr->address); -} -EXPORT_SYMBOL_GPL(acpi_dev_resource_ext_address_space); - -/** * acpi_dev_irq_flags - Determine IRQ resource flags. * @triggering: Triggering type as provided by ACPI. * @polarity: Interrupt polarity as provided by ACPI. @@ -542,8 +521,7 @@ static acpi_status acpi_dev_process_resource(struct acpi_resource *ares, if (acpi_dev_resource_memory(ares, res) || acpi_dev_resource_io(ares, res) - || acpi_dev_resource_address_space(ares, &win) - || acpi_dev_resource_ext_address_space(ares, &win)) + || acpi_dev_resource_address_space(ares, &win)) return acpi_dev_new_resource_entry(&win, c); for (i = 0; acpi_dev_resource_interrupt(ares, i, res); i++) { diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index 4b717c6..bc61651 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c @@ -184,8 +184,7 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, struct resource *r = &win.res; int i, flags; - if (acpi_dev_resource_address_space(res, &win) - || acpi_dev_resource_ext_address_space(res, &win)) { + if (acpi_dev_resource_address_space(res, &win)) { pnp_add_resource(dev, &win.res); return AE_OK; } diff --git a/include/linux/acpi.h b/include/linux/acpi.h index ddbeda6..a06a877 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -399,8 +399,6 @@ bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res); bool acpi_dev_resource_io(struct acpi_resource *ares, struct resource *res); bool acpi_dev_resource_address_space(struct acpi_resource *ares, struct resource_win *win); -bool acpi_dev_resource_ext_address_space(struct acpi_resource *ares, - struct resource_win *win); unsigned long acpi_dev_irq_flags(u8 triggering, u8 polarity, u8 shareable); unsigned int acpi_dev_get_irq_type(int triggering, int polarity); bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index,