From: Marcel Apfelbaum <marcel@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>, qemu-devel@nongnu.org
Cc: ehabkost@redhat.com, mst@redhat.com, cohuck@redhat.com,
yuval.shaia@oracle.com, borntraeger@de.ibm.com,
pbonzini@redhat.com, imammedo@redhat.com
Subject: Re: [Qemu-devel] [PATCH V6 1/5] pci/shpc: Move function to generic header file
Date: Sun, 7 Jan 2018 16:35:13 +0200 [thread overview]
Message-ID: <ef3e67ed-9d52-df23-72c5-0c4f7c48f64f@redhat.com> (raw)
In-Reply-To: <d0cfcb3f-7589-2233-ff76-bd7bb0ea4bfb@amsat.org>
On 07/01/2018 15:47, Philippe Mathieu-Daudé wrote:
> Hi Marcel,
>
Hi Philippe,
> On 01/07/2018 09:32 AM, Marcel Apfelbaum wrote:
>> From: Yuval Shaia <yuval.shaia@oracle.com>
>>
>> This function should be declared in generic header file so we can
>> utilize it.
>>
>> Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com>
>> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
>> ---
>> hw/pci/shpc.c | 13 ++-----------
>> include/qemu/host-utils.h | 10 ++++++++++
>> 2 files changed, 12 insertions(+), 11 deletions(-)
>>
>> diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c
>> index 69fc14b218..a8462d48bb 100644
>> --- a/hw/pci/shpc.c
>> +++ b/hw/pci/shpc.c
>> @@ -1,6 +1,7 @@
>> #include "qemu/osdep.h"
>> #include "qapi/error.h"
>> #include "qemu-common.h"
>> +#include "qemu/host-utils.h"
>> #include "qemu/range.h"
>> #include "qemu/error-report.h"
>> #include "hw/pci/shpc.h"
>> @@ -122,16 +123,6 @@
>> #define SHPC_PCI_TO_IDX(pci_slot) ((pci_slot) - 1)
>> #define SHPC_IDX_TO_PHYSICAL(slot) ((slot) + 1)
>>
>> -static int roundup_pow_of_two(int x)
>> -{
>> - x |= (x >> 1);
>> - x |= (x >> 2);
>> - x |= (x >> 4);
>> - x |= (x >> 8);
>> - x |= (x >> 16);
>> - return x + 1;
>> -}
>> -
>> static uint16_t shpc_get_status(SHPCDevice *shpc, int slot, uint16_t msk)
>> {
>> uint8_t *status = shpc->config + SHPC_SLOT_STATUS(slot);
>> @@ -656,7 +647,7 @@ int shpc_init(PCIDevice *d, PCIBus *sec_bus, MemoryRegion *bar,
>>
>> int shpc_bar_size(PCIDevice *d)
>> {
>> - return roundup_pow_of_two(SHPC_SLOT_REG(SHPC_MAX_SLOTS));
>> + return pow2roundup32(SHPC_SLOT_REG(SHPC_MAX_SLOTS));
>> }
>>
>> void shpc_cleanup(PCIDevice *d, MemoryRegion *bar)
>> diff --git a/include/qemu/host-utils.h b/include/qemu/host-utils.h
>> index 5ac621cf1f..9fadb3f1ba 100644
>> --- a/include/qemu/host-utils.h
>> +++ b/include/qemu/host-utils.h
>> @@ -400,6 +400,16 @@ static inline uint64_t pow2ceil(uint64_t value)
>> return 0x8000000000000000ull >> (n - 1);
>> }
>>
>> +static inline int pow2roundup32(int x)
>
> Can you change the type?
>
> static inline uint32_t pow2roundup32(uint32_t value)
>
Sure.
> Then:
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Appreciated,
Marcel
>> +{
>> + x |= (x >> 1);
>> + x |= (x >> 2);
>> + x |= (x >> 4);
>> + x |= (x >> 8);
>> + x |= (x >> 16);
>> + return x + 1;
>> +}
>> +
>> /**
>> * urshift - 128-bit Unsigned Right Shift.
>> * @plow: in/out - lower 64-bit integer.
>>
next prev parent reply other threads:[~2018-01-07 14:35 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-07 12:32 [Qemu-devel] [PATCH V6 0/5] hw/pvrdma: PVRDMA device implementation Marcel Apfelbaum
2018-01-07 12:32 ` [Qemu-devel] [PATCH V6 1/5] pci/shpc: Move function to generic header file Marcel Apfelbaum
2018-01-07 13:47 ` Philippe Mathieu-Daudé
2018-01-07 14:35 ` Marcel Apfelbaum [this message]
2018-01-07 12:32 ` [Qemu-devel] [PATCH V6 2/5] mem: add share parameter to memory-backend-ram Marcel Apfelbaum
2018-01-08 16:05 ` [Qemu-devel] Getting rid of phys_mem_set_alloc (was: Re: [PATCH V6 2/5] mem: add share parameter to memory-backend-ram) Cornelia Huck
2018-01-08 18:53 ` [Qemu-devel] Getting rid of phys_mem_set_alloc Marcel Apfelbaum
2018-01-07 12:32 ` [Qemu-devel] [PATCH V6 3/5] docs: add pvrdma device documentation Marcel Apfelbaum
2018-01-09 9:17 ` Cornelia Huck
2018-01-09 10:09 ` Marcel Apfelbaum
2018-01-07 12:32 ` [Qemu-devel] [PATCH V6 4/5] pvrdma: initial implementation Marcel Apfelbaum
2018-01-09 10:39 ` Cornelia Huck
2018-01-09 11:08 ` Yuval Shaia
2018-01-09 12:51 ` Cornelia Huck
2018-01-10 9:28 ` Marcel Apfelbaum
2018-01-10 9:37 ` Cornelia Huck
2018-01-10 9:06 ` Marcel Apfelbaum
2018-01-07 12:32 ` [Qemu-devel] [PATCH V6 5/5] MAINTAINERS: add entry for hw/rdma Marcel Apfelbaum
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=ef3e67ed-9d52-df23-72c5-0c4f7c48f64f@redhat.com \
--to=marcel@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=ehabkost@redhat.com \
--cc=f4bug@amsat.org \
--cc=imammedo@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=yuval.shaia@oracle.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).