linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Zheng, Lv" <lv.zheng@intel.com>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: "Wysocki, Rafael J" <rafael.j.wysocki@intel.com>,
	"Brown, Len" <len.brown@intel.com>, Lv Zheng <zetalog@gmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>
Subject: RE: [PATCH v3 2/7] ACPICA: Linux: Add stub implementation of ACPICA 64-bit mathematics.
Date: Mon, 21 Jul 2014 01:26:10 +0000	[thread overview]
Message-ID: <1AE640813FDE7649BE1B193DEA596E8802643932@SHSMSX101.ccr.corp.intel.com> (raw)
In-Reply-To: <3777197.HSR7Q9huIS@vostro.rjw.lan>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 4624 bytes --]

Hi, Rafael

> From: Rafael J. Wysocki [mailto:rjw@rjwysocki.net]
> Sent: Sunday, July 20, 2014 7:46 AM
> To: Zheng, Lv
> 
> On Wednesday, July 16, 2014 04:58:00 PM Lv Zheng wrote:
> > This patch adds default 64-bit mathematics in aclinux.h using do_div(). As
> > do_div() can be used for all Linux architectures, this can also be used as
> > stub macros for ACPICA 64-bit mathematics.
> >
> > But this is not a performance friendly way, as ACPICA's architecture
> > specific division OSL only requires a dividing 64-bit number with a 32-bit
> > number implementation, while Linux __div64_32() is not available for all
> > build environments. So currently, if an architecture really wants to
> > support ACPICA, it must implement its own division OSL.
> 
> What does this mean for i386, in particular?

All ACPICA environment macros have defaults in actypes.h or acenv.h, these macros are the only ones do not have defaults.
Because their defaults should be provided by OSPMs.
This patch just adds their default implementation for __KERNEL__ surrounded code for Linux kernel.
It only provides build protection and demonstrations of the functionality, no one actually uses it now.

Let me figure out the possible users below:

These macros are required by drivers/acpi/utmath.c when ACPI_USE_NATIVE_DIVIDE is not defined.
It is used by ACPICA, so currently this is only meaningful to CONFIG_ACPI builds.
So kernel will not use these macros unless CONFIG_ACPI is defined and ACPI_USE_DIVIDE is not defined.

For 64-bit kernels: 
In include/acpi/actypes.h, for ACPI_MACHINE_WIDTH=64, ACPI_USE_NATIVE_DIVIDE will be defined, thus these macros are not used.
In include/acpi/platform/aclinux.h, for __KERNEL__ surrounded code, ACPI_MACHINE_WIDTH is defined to be BITS_PER_LONG.
So all 64-bit kernels do not use these macros.

For 32-bit kernels:
As mentioned above, these macros will be used when BITS_PER_LONG is 32.
Thus currently the i328 kernels are the only users for these macros.
But they won't use this default implementation provided by this patch because:
In arch/x86/include/asm/acenv.h, there are already overrides implemented.
So these default macros are not used by 32-bit x86 (i386) kernels.

These macros will only be used by future non x86 32-bit architectures that try to support ACPI in Linux kernel.
During the period they do not have arch specific implementations of such macros, we can avoid build errors for them.
And since they can see ACPICA functioning without implementing any arch specific environment tunings, we  can also avoid function errors for them.
As this implementation is not performance friendly, those architectures still need to implement real support in the end.

As a conclusion, IMO:
1. This default implementation just fill an ACPICA default environment gap.
1. There are no users and will be no users of this default implementation in the kernel.
3. Though this default implementation is not performance friendly, it functions correctly, so it can be a demo for future 32-bit architectures that try to support ACPI.
4. We can use this default implementation to avoid build troubles.

Thanks and best regards
-Lv

> 
> > This is required by the ACPICA header stub support. ACPICA header stubs are
> > useful to protect CONFIG_ACPI=n Linux kernel builds where ACPICA headers
> > are included. Lv Zheng.
> >
> > Signed-off-by: Lv Zheng <lv.zheng@intel.com>
> > ---
> >  include/acpi/platform/aclinuxex.h |   22 ++++++++++++++++++++++
> >  1 file changed, 22 insertions(+)
> >
> > diff --git a/include/acpi/platform/aclinuxex.h b/include/acpi/platform/aclinuxex.h
> > index 191e741..568d4b8 100644
> > --- a/include/acpi/platform/aclinuxex.h
> > +++ b/include/acpi/platform/aclinuxex.h
> > @@ -46,6 +46,28 @@
> >
> >  #ifdef __KERNEL__
> >
> > +#ifndef ACPI_USE_NATIVE_DIVIDE
> > +
> > +#ifndef ACPI_DIV_64_BY_32
> > +#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \
> > +	do { \
> > +		u64 (__n) = ((u64) n_hi) << 32 | (n_lo); \
> > +		(r32) = do_div ((__n), (d32)); \
> > +		(q32) = (u32) (__n); \
> > +	} while (0)
> > +#endif
> > +
> > +#ifndef ACPI_SHIFT_RIGHT_64
> > +#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \
> > +	do { \
> > +		(n_lo) >>= 1; \
> > +		(n_lo) |= (((n_hi) & 1) << 31); \
> > +		(n_hi) >>= 1; \
> > +	} while (0)
> > +#endif
> > +
> > +#endif
> > +
> >  /*
> >   * Overrides for in-kernel ACPICA
> >   */
> >
> 
> --
> I speak only for myself.
> Rafael J. Wysocki, Intel Open Source Technology Center.
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

  reply	other threads:[~2014-07-21  1:26 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-18  9:05 [RFC PATCH 00/15] ACPICA: Add CONFIG_ACPI=n build support for ACPICA header files Lv Zheng
2013-12-18  9:05 ` [RFC PATCH 01/15] ACPICA: OSL: Add configurability mechanism for global variables Lv Zheng
2013-12-18  9:06 ` [RFC PATCH 02/15] ACPICA: Linux: Add configurability for external globals Lv Zheng
2013-12-18  9:06 ` [RFC PATCH 03/15] ACPICA: Linux: Add configurability for OSL APIs Lv Zheng
2013-12-18  9:06 ` [RFC PATCH 04/15] ACPICA: OSL: Cleanup external macros and add stubs for macros Lv Zheng
2013-12-18  9:06 ` [RFC PATCH 05/15] ACPICA: OSL: Add configurability to error message functions Lv Zheng
2013-12-18  9:06 ` [RFC PATCH 06/15] ACPICA: OSL: Add configurability to debug output functions Lv Zheng
2013-12-18  9:06 ` [RFC PATCH 07/15] ACPICA: OSL: Add configurability mechanism for external APIs Lv Zheng
2013-12-18  9:06 ` [RFC PATCH 08/15] ACPICA: OSL: Updates ACPI_EXTERNAL_RETURN_x usages " Lv Zheng
2013-12-18  9:06 ` [RFC PATCH 09/15] ACPICA: Linux: Add stub support for Linux specific variables and functions Lv Zheng
2013-12-18  9:06 ` [RFC PATCH 10/15] ACPICA: Linux: Add architecture specific ACPICA headers in Linux Lv Zheng
2013-12-18  9:06 ` [RFC PATCH 11/15] ACPICA: Linux: Add stub implementation of ACPICA 64-bit mathematics Lv Zheng
2013-12-18  9:07 ` [RFC PATCH 12/15] ACPICA: Linux: Add configuration item to indicate the architecture specific support Lv Zheng
2013-12-18  9:07 ` [RFC PATCH 13/15] ACPICA: Linux: Remove <asm/acpi.h> inclusion from ACPICA headers Lv Zheng
2013-12-18  9:07 ` [RFC PATCH 14/15] ACPI/SFI: Fix wrong <acpi/acpi.h> inclusion in SFI/ACPI wrapper - table definitions Lv Zheng
2013-12-18  9:07 ` [RFC DBG PATCH] ACPICA: Add CONFIG_ACPI=n build test support Lv Zheng
2013-12-18 11:41   ` [RFC PATCH 15/15] ACPI/thinkpad: Fix wrong <acpi/acpi.h> inclusion in Thinkpad ACPI users Henrique de Moraes Holschuh
2013-12-18 13:06     ` [alsa-devel] " Takashi Iwai
2013-12-20  0:28       ` Zheng, Lv
2013-12-20  6:52         ` Takashi Iwai
2013-12-20  8:30 ` [UPDATE RFC " Lv Zheng
2013-12-20  9:15   ` Takashi Iwai
2014-07-07  4:16 ` [PATCH v2 0/7] ACPICA: Enable ACPICA prototypes for CONFIG_ACPI=n builds Lv Zheng
2014-07-07  4:17   ` [PATCH v2 1/7] ACPICA: Linux: Add stub support for Linux specific variables and functions Lv Zheng
2014-07-07  4:17   ` [PATCH v2 2/7] ACPICA: Linux: Add stub implementation of ACPICA 64-bit mathematics Lv Zheng
2014-07-07  4:17   ` [PATCH v2 3/7] ACPICA: Linux: Add configuration item to indicate the architecture specific support Lv Zheng
2014-07-07  4:17   ` [PATCH v2 4/7] ACPICA: Linux: Allow ACPICA inclusion for CONFIG_ACPI=n builds Lv Zheng
2014-07-07  4:17   ` [PATCH v2 5/7] ACPI/SFI: Fix wrong <acpi/acpi.h> inclusion in SFI/ACPI wrapper - table definitions Lv Zheng
2014-07-07 21:25     ` Rafael J. Wysocki
2014-07-08  0:08       ` Zheng, Lv
2014-07-07  4:17   ` [PATCH v2 6/7] ACPI: Cleanup useless ACPI inclusion Lv Zheng
2014-07-07 21:24     ` Rafael J. Wysocki
2014-07-08  0:05       ` Zheng, Lv
2014-07-07  4:17   ` [PATCH v2 7/7] ACPI: Add support to force header inclusion rules for <acpi/acpi.h> Lv Zheng
2014-07-16  8:57 ` [PATCH v3 0/7] ACPICA: Enable ACPICA prototypes for CONFIG_ACPI=n builds Lv Zheng
2014-07-16  8:57   ` [PATCH v3 1/7] ACPICA: Linux: Add stub support for Linux specific variables and functions Lv Zheng
2014-07-16  8:58   ` [PATCH v3 2/7] ACPICA: Linux: Add stub implementation of ACPICA 64-bit mathematics Lv Zheng
2014-07-19 23:46     ` Rafael J. Wysocki
2014-07-21  1:26       ` Zheng, Lv [this message]
2014-07-22 23:42         ` Rafael J. Wysocki
2014-07-16  8:58   ` [PATCH v3 3/7] ACPICA: Linux: Add support to exclude <asm/acenv.h> inclusion Lv Zheng
2014-07-16  8:58   ` [PATCH v3 4/7] ACPICA: Linux: Allow ACPICA inclusion for CONFIG_ACPI=n builds Lv Zheng
2014-07-16  8:58   ` [PATCH v3 5/7] ACPI/SFI: Fix wrong <acpi/acpi.h> inclusion in SFI/ACPI wrapper - table definitions Lv Zheng
2014-07-16  8:58   ` [PATCH v3 6/7] ACPI: Add support to force header inclusion rules for <acpi/acpi.h> Lv Zheng
2014-07-23  3:53     ` Hanjun Guo
2014-07-16  8:59   ` [PATCH v3 7/7] ACPI: Cleanup useless ACPI inclusion Lv Zheng
2014-07-16 12:07     ` Mark Brown
2014-07-16 21:46       ` Rafael J. Wysocki
2014-07-16 21:34         ` Mark Brown
2014-07-17  1:29           ` Zheng, Lv

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1AE640813FDE7649BE1B193DEA596E8802643932@SHSMSX101.ccr.corp.intel.com \
    --to=lv.zheng@intel.com \
    --cc=len.brown@intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rjw@rjwysocki.net \
    --cc=zetalog@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).