Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752724AbcCASOh (ORCPT ); Tue, 1 Mar 2016 13:14:37 -0500 Received: from mail-ob0-f180.google.com ([209.85.214.180]:32954 "EHLO mail-ob0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752680AbcCASOd (ORCPT ); Tue, 1 Mar 2016 13:14:33 -0500 MIME-Version: 1.0 In-Reply-To: <1456853819.15454.45.camel@hpe.com> References: <1456178130-26468-1-git-send-email-toshi.kani@hpe.com> <1456178130-26468-2-git-send-email-toshi.kani@hpe.com> <94F2FBAB4432B54E8AACC7DFDE6C92E37E44D64B@ORSMSX110.amr.corp.intel.com> <1456850284.15454.23.camel@hpe.com> <94F2FBAB4432B54E8AACC7DFDE6C92E37E44D6E1@ORSMSX110.amr.corp.intel.com> <1456853819.15454.45.camel@hpe.com> Date: Tue, 1 Mar 2016 10:14:32 -0800 Message-ID: Subject: Re: [PATCH v2 1/3] ACPI/NFIT: Update Control Region Structure to comply ACPI 6.1 From: Dan Williams To: Toshi Kani Cc: "Moore, Robert" , "rjw@rjwysocki.net" , "Zheng, Lv" , "elliott@hpe.com" , "linux-nvdimm@lists.01.org" , "linux-acpi@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "devel@acpica.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1532 Lines: 33 On Tue, Mar 1, 2016 at 9:36 AM, Toshi Kani wrote: > On Tue, 2016-03-01 at 16:03 +0000, Moore, Robert wrote: >> We have a bunch of macros in include/acmacros.h -- like this: >> >> ACPI_MOVE_16_TO_16(d, s) > > There is a problem in using the ACPICA byte-swap macros. ACPI is little- > endian arch, so the macros are set to perform byte-swappings when the CPU > arch is big-endian. This case, however, is the other way around. The > fields in question are defined & stored as arrays of bytes. If you treat > them as multi-bytes numeric values, then you need to byte-swap them when > the CPU arch is little-endian because arrays of bytes have the same > addressing as big-endian. > > Another issue is that it is not clear who needs to perform the byte- > swapping among ACPICA and drivers. If ACPICA, drivers must agree that > these fields are always treated as multi-bytes numeric values despite of > the spec. If drivers, we need to make sure that only a single driver > performs this byte-swapping one time as ACPI tables are global structures. > > I think it is much clearer to define the structure according to the ACPI > spec. I think the "ACPI tables are little-endian" assumption is pervasive throughout the implementation. Toshi, it seems all we need is conversions like: - sprintf(buf, "%#x\n", dcr->vendor_id); + sprintf(buf, "%#x\n", le16_to_cpu(dcr->vendor_id)); ...for the values exported to userspace through sysfs, but otherwise leave the base table definitions as is. Will this suffice?