public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Gao, Liming" <liming.gao@intel.com>
To: "Kinney, Michael D" <michael.d.kinney@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: [Patch] MdePkg/PciSegmentLib: Optimize PCI_SEGMENT_LIB_ADDRESS()
Date: Thu, 27 Oct 2016 03:17:52 +0000	[thread overview]
Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14B49A46B@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <1477516692-8972-1-git-send-email-michael.d.kinney@intel.com>

Reviewed-by: Liming Gao <liming.gao@intel.com>

> -----Original Message-----
> From: Kinney, Michael D
> Sent: Thursday, October 27, 2016 5:18 AM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>
> Subject: [Patch] MdePkg/PciSegmentLib: Optimize
> PCI_SEGMENT_LIB_ADDRESS()
> 
> The PCI_SEGMENT_LIB_ADDRESS() macro puts the Segment number
> into bits 32..47 of the logical address that is returned.
> The portable method to put Segment in this bit range is to
> use LShitU64().  For 64-bit CPUs, this is optimized well
> by the compiler.  For 32-bit CPUs, a call to LSHiftU64()
> is included in the generated binaries.  However, if the
> Segment parameter is 0, then no shift is required.  Add
> a check for Segment set to 0 and provide an optimized
> macro implementation that does not call LShiftU64().
> 
> Cc: Liming Gao <liming.gao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Michael Kinney <michael.d.kinney@intel.com>
> ---
>  MdePkg/Include/Library/PciSegmentLib.h | 19 +++++++++++++------
>  1 file changed, 13 insertions(+), 6 deletions(-)
> 
> diff --git a/MdePkg/Include/Library/PciSegmentLib.h
> b/MdePkg/Include/Library/PciSegmentLib.h
> index 1135010..5175e07 100644
> --- a/MdePkg/Include/Library/PciSegmentLib.h
> +++ b/MdePkg/Include/Library/PciSegmentLib.h
> @@ -23,7 +23,7 @@
>    access method.  Modules will typically use the PCI Segment Library for its
> PCI configuration
>    accesses when PCI Segments other than Segment #0 must be accessed.
> 
> -Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
>  This program and the accompanying materials
>  are licensed and made available under the terms and conditions of the BSD
> License
>  which accompanies this distribution.  The full text of the license may be
> found at
> @@ -56,11 +56,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF
> ANY KIND, EITHER EXPRESS OR IMPLIED.
> 
>  **/
>  #define
> PCI_SEGMENT_LIB_ADDRESS(Segment,Bus,Device,Function,Register) \
> -  ( ((Register) & 0xfff)              | \
> -    (((Function) & 0x07) << 12)       | \
> -    (((Device) & 0x1f) << 15)         | \
> -    (((Bus) & 0xff) << 20)            | \
> -    (LShiftU64((Segment) & 0xffff, 32)) \
> +  ((Segment != 0) ? \
> +    ( ((Register) & 0xfff)                 | \
> +      (((Function) & 0x07) << 12)          | \
> +      (((Device) & 0x1f) << 15)            | \
> +      (((Bus) & 0xff) << 20)               | \
> +      (LShiftU64 ((Segment) & 0xffff, 32))   \
> +    ) :                                      \
> +    ( ((Register) & 0xfff)                 | \
> +      (((Function) & 0x07) << 12)          | \
> +      (((Device) & 0x1f) << 15)            | \
> +      (((Bus) & 0xff) << 20)                 \
> +    )                                        \
>    )
> 
>  /**
> --
> 2.6.3.windows.1



      reply	other threads:[~2016-10-27  3:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-26 21:18 [Patch] MdePkg/PciSegmentLib: Optimize PCI_SEGMENT_LIB_ADDRESS() Michael Kinney
2016-10-27  3:17 ` Gao, Liming [this message]

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-list 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=4A89E2EF3DFEDB4C8BFDE51014F606A14B49A46B@shsmsx102.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /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