public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: Laszlo Ersek <lersek@redhat.com>
Cc: edk2-devel-01 <edk2-devel@lists.01.org>,
	Jordan Justen <jordan.l.justen@intel.com>
Subject: Re: [PATCH v2 3/7] OvmfPkg: introduce PciCapPciIoLib
Date: Thu, 24 May 2018 16:54:02 +0200	[thread overview]
Message-ID: <CAKv+Gu-OpZ2G-bQDW=Ei=wXa9OgnoWUr093eWXajxbtpL_vJ1g@mail.gmail.com> (raw)
In-Reply-To: <1cef03f3-f3be-9fd6-2644-a16ec95f1949@redhat.com>

On 24 May 2018 at 16:50, Laszlo Ersek <lersek@redhat.com> wrote:
> On 05/24/18 10:13, Ard Biesheuvel wrote:
>> On 23 May 2018 at 22:21, Laszlo Ersek <lersek@redhat.com> wrote:
>>> Add a library class, and a UEFI_DRIVER lib instance, that are layered on
>>> top of PciCapLib, and allow clients to plug an EFI_PCI_IO_PROTOCOL backend
>>> into PciCapLib, for config space access.
>>>
>>> (Side note:
>>>
>>
>> Again, please retain the below.
>
> Will do.
>
>>> +STATIC
>>> +EFI_STATUS
>>> +ProtoDevTransferConfig (
>>> +  IN     EFI_PCI_IO_PROTOCOL        *PciIo,
>>> +  IN     EFI_PCI_IO_PROTOCOL_CONFIG TransferFunction,
>>> +  IN     UINT16                     ConfigOffset,
>>> +  IN OUT UINT8                      *Buffer,
>>> +  IN     UINT16                     Size
>>> +  )
>>> +{
>>> +  while (Size > 0) {
>>> +    EFI_PCI_IO_PROTOCOL_WIDTH Width;
>>> +    UINT16                    Count;
>>> +    EFI_STATUS                Status;
>>> +    UINT16                    Progress;
>>> +
>>> +    //
>>> +    // Pick the largest access size that is allowed by the remaining transfer
>>> +    // Size and by the alignment of ConfigOffset.
>>> +    //
>>> +    // When the largest access size is available, transfer as many bytes as
>>> +    // possible in one iteration of the loop. Otherwise, transfer only one
>>> +    // unit, to improve the alignment.
>>> +    //
>>> +    if (Size >= BIT2 && (ConfigOffset & (BIT2 - 1)) == 0) {
>>
>> Ugh. Just use '4' or sizeof(UINT32).
>>
>>> +      Width = EfiPciIoWidthUint32;
>>> +      Count = Size >> Width;
>>> +    } else if (Size >= BIT1 && (ConfigOffset & (BIT1 - 1)) == 0) {
>>> +      Width = EfiPciIoWidthUint16;
>>> +      Count = 1;
>>> +    } else {
>>> +      Width = EfiPciIoWidthUint8;
>>> +      Count = 1;
>>> +    }
>
> I used "BITx" and "(BITx - 1)" for consistency, and because they seemed
> to convey the idea well (namely, shifting down the alignment).
>
> I'm fine replacing "BIT2" with "4", but then I believe I should also
> replace "(BIT2 - 1)" with "3". Similarly, replace "BIT1" with "2", and
> "(BIT1 -1)" with 1.
>
> Do you prefer the current code or the decimal constants?
>

IMHO, BITx is for bitmasks, not for numerical constants.

So yes, if you think (as do I) that sizeof(UINTnn) is too wordy, just
use the plain numbers please.


  reply	other threads:[~2018-05-24 14:54 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-23 20:21 [PATCH v2 0/7] OvmfPkg, ArmVirtPkg: add and use PCI(E) Capabilities Library Laszlo Ersek
2018-05-23 20:21 ` [PATCH v2 1/7] OvmfPkg: introduce PciCapLib Laszlo Ersek
2018-05-24  7:53   ` Ard Biesheuvel
2018-05-24 14:39     ` Laszlo Ersek
2018-05-24 14:41       ` Ard Biesheuvel
2018-05-24 17:25         ` Laszlo Ersek
2018-05-23 20:21 ` [PATCH v2 2/7] OvmfPkg: introduce PciCapPciSegmentLib Laszlo Ersek
2018-05-24  8:08   ` Ard Biesheuvel
2018-05-24 14:43     ` Laszlo Ersek
2018-05-24 14:55       ` Ard Biesheuvel
2018-05-23 20:21 ` [PATCH v2 3/7] OvmfPkg: introduce PciCapPciIoLib Laszlo Ersek
2018-05-24  8:13   ` Ard Biesheuvel
2018-05-24 14:50     ` Laszlo Ersek
2018-05-24 14:54       ` Ard Biesheuvel [this message]
2018-05-24 14:54         ` Ard Biesheuvel
2018-05-24 17:22         ` Laszlo Ersek
2018-05-23 20:21 ` [PATCH v2 4/7] OvmfPkg: resolve PciCapLib, PciCapPciSegmentLib, PciCapPciIoLib Laszlo Ersek
2018-05-24  8:14   ` Ard Biesheuvel
2018-05-23 20:21 ` [PATCH v2 5/7] ArmVirtPkg: " Laszlo Ersek
2018-05-24  8:14   ` Ard Biesheuvel
2018-05-23 20:21 ` [PATCH v2 6/7] OvmfPkg/PciHotPlugInitDxe: convert to PciCapLib Laszlo Ersek
2018-05-24  8:15   ` Ard Biesheuvel
2018-05-23 20:21 ` [PATCH v2 7/7] OvmfPkg/Virtio10Dxe: " Laszlo Ersek
2018-05-24  8:16   ` Ard Biesheuvel
2018-05-24 14:55     ` Laszlo Ersek
2018-05-24 20:04 ` [PATCH v2 0/7] OvmfPkg, ArmVirtPkg: add and use PCI(E) Capabilities Library Laszlo Ersek

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='CAKv+Gu-OpZ2G-bQDW=Ei=wXa9OgnoWUr093eWXajxbtpL_vJ1g@mail.gmail.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