From: Harry Wentland <harry.wentland-5C7GfCeVMHo@public.gmane.org>
To: Dave Airlie <airlied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH 4/4] amdgpu/dc: remove bitmap implementation in gpio_service
Date: Tue, 3 Oct 2017 12:10:53 -0400 [thread overview]
Message-ID: <4635cb6a-06bd-9b0d-d2db-066b2c394c80@amd.com> (raw)
In-Reply-To: <20171003034945.27909-4-airlied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
On 2017-10-02 11:49 PM, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
>
> This handrolls a bit map implementation (linux/bitmap.h),
> but it also actually doesn't need it, the max value greppable
> in the code is 31 for a gpio count. So just use a uint32_t for now.
>
> This should probably migrate to using the linux/bitops.h operations,
> but for now just rip out the bitmap implementation and fail if we
>> 32 bits.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
Nice cleanup. This was such overengineered code.
This series is
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Looks like you sent the ilog2 patch twice. I'll ignore the separate one
as it seems to be the same as the one from this series.
Harry
> ---
> drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c | 85 +++-------------------
> drivers/gpu/drm/amd/display/dc/gpio/gpio_service.h | 8 +-
> 2 files changed, 11 insertions(+), 82 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c b/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c
> index d4e5ef6..95df7d4 100644
> --- a/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c
> +++ b/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c
> @@ -56,8 +56,7 @@ struct gpio_service *dal_gpio_service_create(
> struct dc_context *ctx)
> {
> struct gpio_service *service;
> -
> - uint32_t index_of_id;
> + int i;
>
> service = kzalloc(sizeof(struct gpio_service), GFP_KERNEL);
>
> @@ -78,62 +77,16 @@ struct gpio_service *dal_gpio_service_create(
> goto failure_1;
> }
>
> - /* allocate and initialize business storage */
> - {
> - const uint32_t bits_per_uint = sizeof(uint32_t) << 3;
> -
> - index_of_id = 0;
> - service->ctx = ctx;
> -
> - do {
> - uint32_t number_of_bits =
> - service->factory.number_of_pins[index_of_id];
> -
> - uint32_t number_of_uints =
> - (number_of_bits + bits_per_uint - 1) /
> - bits_per_uint;
> -
> - uint32_t *slot;
> -
> - if (number_of_bits) {
> - uint32_t index_of_uint = 0;
> + service->ctx = ctx;
>
> - slot = kzalloc(number_of_uints * sizeof(uint32_t),
> - GFP_KERNEL);
> -
> - if (!slot) {
> - BREAK_TO_DEBUGGER();
> - goto failure_2;
> - }
> -
> - do {
> - slot[index_of_uint] = 0;
> -
> - ++index_of_uint;
> - } while (index_of_uint < number_of_uints);
> - } else
> - slot = NULL;
> -
> - service->busyness[index_of_id] = slot;
> -
> - ++index_of_id;
> - } while (index_of_id < GPIO_ID_COUNT);
> + for (i = 0; i < GPIO_ID_COUNT; i++) {
> + if (service->factory.number_of_pins[i] > 32) {
> + BREAK_TO_DEBUGGER();
> + goto failure_1;
> + }
> }
> -
> return service;
>
> -failure_2:
> - while (index_of_id) {
> - uint32_t *slot;
> -
> - --index_of_id;
> -
> - slot = service->busyness[index_of_id];
> -
> - if (slot)
> - kfree(slot);
> - };
> -
> failure_1:
> kfree(service);
>
> @@ -164,20 +117,6 @@ void dal_gpio_service_destroy(
> return;
> }
>
> - /* free business storage */
> - {
> - uint32_t index_of_id = 0;
> -
> - do {
> - uint32_t *slot = (*ptr)->busyness[index_of_id];
> -
> - if (slot)
> - kfree(slot);
> -
> - ++index_of_id;
> - } while (index_of_id < GPIO_ID_COUNT);
> - }
> -
> kfree(*ptr);
>
> *ptr = NULL;
> @@ -195,9 +134,7 @@ static bool is_pin_busy(
> {
> const uint32_t bits_per_uint = sizeof(uint32_t) << 3;
>
> - const uint32_t *slot = service->busyness[id] + (en / bits_per_uint);
> -
> - return 0 != (*slot & (1 << (en % bits_per_uint)));
> + return 0 != (service->busyness[id] & (1 << (en % bits_per_uint)));
> }
>
> static void set_pin_busy(
> @@ -207,8 +144,7 @@ static void set_pin_busy(
> {
> const uint32_t bits_per_uint = sizeof(uint32_t) << 3;
>
> - service->busyness[id][en / bits_per_uint] |=
> - (1 << (en % bits_per_uint));
> + service->busyness[id] |= (1 << (en % bits_per_uint));
> }
>
> static void set_pin_free(
> @@ -218,8 +154,7 @@ static void set_pin_free(
> {
> const uint32_t bits_per_uint = sizeof(uint32_t) << 3;
>
> - service->busyness[id][en / bits_per_uint] &=
> - ~(1 << (en % bits_per_uint));
> + service->busyness[id] &= ~(1 << (en % bits_per_uint));
> }
>
> enum gpio_result dal_gpio_service_open(
> diff --git a/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.h b/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.h
> index c7f3081..96c52be 100644
> --- a/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.h
> +++ b/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.h
> @@ -33,13 +33,7 @@ struct gpio_service {
> struct dc_context *ctx;
> struct hw_translate translate;
> struct hw_factory factory;
> - /*
> - * @brief
> - * Business storage.
> - * For each member of 'enum gpio_id',
> - * store array of bits (packed into uint32_t slots),
> - * index individual bit by 'en' value */
> - uint32_t *busyness[GPIO_ID_COUNT];
> + uint32_t busyness[GPIO_ID_COUNT];
> };
>
> enum gpio_result dal_gpio_service_open(
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2017-10-03 16:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-03 3:49 [PATCH 1/4] amdgpu/dc: use kernel ilog2 for log_2 Dave Airlie
[not found] ` <20171003034945.27909-1-airlied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-10-03 3:49 ` [PATCH 2/4] amdgpu/dc: drop dce110_types.h Dave Airlie
2017-10-03 3:49 ` [PATCH 3/4] amdgpu/dc: drop hw_sequencer_types.h Dave Airlie
2017-10-03 3:49 ` [PATCH 4/4] amdgpu/dc: remove bitmap implementation in gpio_service Dave Airlie
[not found] ` <20171003034945.27909-4-airlied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-10-03 16:10 ` Harry Wentland [this message]
2017-10-03 19:29 ` Felix Kuehling
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=4635cb6a-06bd-9b0d-d2db-066b2c394c80@amd.com \
--to=harry.wentland-5c7gfcevmho@public.gmane.org \
--cc=airlied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
/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