mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kieran Bingham <kieran.bingham@ideasonboard.com>
To: Broadcom internal kernel review list
	<bcm-kernel-feedback-list@broadcom.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Umang Jain <umang.jain@ideasonboard.com>
Cc: linux-rpi-kernel@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
	Dan Carpenter <dan.carpenter@linaro.org>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	kernel-list@raspberrypi.com, Stefan Wahren <wahrenst@gmx.net>,
	Umang Jain <umang.jain@ideasonboard.com>
Subject: Re: [PATCH v3 4/6] staging: vchiq_core: Refactor notify_bulks()
Date: Sun, 13 Oct 2024 08:22:25 +0100	[thread overview]
Message-ID: <172880414537.1925926.9488617715642757683@ping.linuxembedded.co.uk> (raw)
In-Reply-To: <20241012185652.316172-5-umang.jain@ideasonboard.com>

Quoting Umang Jain (2024-10-12 19:56:50)
> Move the statistics and bulk completion events handling  to a separate
> function. This helps to improve readability for notify_bulks().
> 
> No functional changes intended in this patch.
> 
> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
> ---
>  .../interface/vchiq_arm/vchiq_core.c          | 77 +++++++++++--------
>  1 file changed, 46 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
> index e9cd012e2b5f..19dfcd98dcde 100644
> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
> @@ -1309,6 +1309,49 @@ get_bulk_reason(struct vchiq_bulk *bulk)
>         return VCHIQ_BULK_RECEIVE_DONE;
>  }
>  
> +static int service_notify_bulk(struct vchiq_service *service,
> +                              struct vchiq_bulk *bulk)
> +{
> +       int status = -EINVAL;
> +
> +       if (!service || !bulk)
> +               return status;

Both of these are guaranteed by the (only) caller so I'm not sure they're
needed ?

But maybe it would be used elsewhere later?

If these checks were kept, and the int status removed as mentioned below
this would just be ' return -EINVAL;' of course.

Or just drop them if it's easier and guaranteed.

> +
> +       if (bulk->actual != VCHIQ_BULK_ACTUAL_ABORTED) {
> +               if (bulk->dir == VCHIQ_BULK_TRANSMIT) {
> +                       VCHIQ_SERVICE_STATS_INC(service, bulk_tx_count);
> +                       VCHIQ_SERVICE_STATS_ADD(service, bulk_tx_bytes,
> +                                               bulk->actual);
> +               } else {
> +                       VCHIQ_SERVICE_STATS_INC(service, bulk_rx_count);
> +                       VCHIQ_SERVICE_STATS_ADD(service, bulk_rx_bytes,
> +                                               bulk->actual);
> +                               }

I think the indentation on this } has gone wrong here.

> +       } else {
> +               VCHIQ_SERVICE_STATS_INC(service, bulk_aborted_count);
> +       }
> +
> +       if (bulk->mode == VCHIQ_BULK_MODE_BLOCKING) {
> +               struct bulk_waiter *waiter;
> +
> +               spin_lock(&service->state->bulk_waiter_spinlock);
> +               waiter = bulk->userdata;
> +               if (waiter) {
> +                       waiter->actual = bulk->actual;
> +                       complete(&waiter->event);
> +               }
> +               spin_unlock(&service->state->bulk_waiter_spinlock);
> +
> +               status = 0;

This just looks odd here. If it weren't for this I'd have probably been
fine with the initialisation of status

> +       } else if (bulk->mode == VCHIQ_BULK_MODE_CALLBACK) {
> +               enum vchiq_reason reason = get_bulk_reason(bulk);
> +               status = make_service_callback(service, reason, NULL,
> +                                              bulk->userdata);

I think I would probably just drop the int status altogether and make this

		return make_service_callback(service, reason, NULL,
					     bulk->userdata);

> +       }
> +
> +       return status;

And return 0 here. Then we get rid of the awkward initialisation and
usages above.

> +}
> +
>  /* Called by the slot handler - don't hold the bulk mutex */
>  static int
>  notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue,
> @@ -1333,37 +1376,9 @@ notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue,
>                  * requests, and non-terminated services
>                  */
>                 if (bulk->data && service->instance) {
> -                       if (bulk->actual != VCHIQ_BULK_ACTUAL_ABORTED) {
> -                               if (bulk->dir == VCHIQ_BULK_TRANSMIT) {
> -                                       VCHIQ_SERVICE_STATS_INC(service, bulk_tx_count);
> -                                       VCHIQ_SERVICE_STATS_ADD(service, bulk_tx_bytes,
> -                                                               bulk->actual);
> -                               } else {
> -                                       VCHIQ_SERVICE_STATS_INC(service, bulk_rx_count);
> -                                       VCHIQ_SERVICE_STATS_ADD(service, bulk_rx_bytes,
> -                                                               bulk->actual);
> -                               }
> -                       } else {
> -                               VCHIQ_SERVICE_STATS_INC(service, bulk_aborted_count);
> -                       }
> -                       if (bulk->mode == VCHIQ_BULK_MODE_BLOCKING) {
> -                               struct bulk_waiter *waiter;
> -
> -                               spin_lock(&service->state->bulk_waiter_spinlock);
> -                               waiter = bulk->userdata;
> -                               if (waiter) {
> -                                       waiter->actual = bulk->actual;
> -                                       complete(&waiter->event);
> -                               }
> -                               spin_unlock(&service->state->bulk_waiter_spinlock);
> -                       } else if (bulk->mode == VCHIQ_BULK_MODE_CALLBACK) {
> -                               enum vchiq_reason reason =
> -                                               get_bulk_reason(bulk);
> -                               status = make_service_callback(service, reason, NULL,
> -                                                              bulk->userdata);
> -                               if (status == -EAGAIN)
> -                                       break;
> -                       }
> +                       status = service_notify_bulk(service, bulk);
> +                       if (status == -EAGAIN)
> +                               break;

This now reads as 
                 if (bulk->data && service->instance) {
                         status = service_notify_bulk(service, bulk);
                         if (status == -EAGAIN)
                                 break;
		}

which is much nicer.

With the updates above handled, then I think we're more accurately at no
functional changes:

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>



>                 }
>  
>                 queue->remove++;
> -- 
> 2.45.2
>

  reply	other threads:[~2024-10-13  7:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-12 18:56 [PATCH v3 0/6] staging: vchiq: Lower indentation at various places Umang Jain
2024-10-12 18:56 ` [PATCH v3 1/6] staging: vchiq_core: Locally cache cache_line_size information Umang Jain
2024-10-12 18:56 ` [PATCH v3 2/6] staging: vchiq_core: Do not log debug in a separate scope Umang Jain
2024-10-12 18:56 ` [PATCH v3 3/6] staging: vchiq_core: Indent copy_message_data() on a single line Umang Jain
2024-10-12 18:56 ` [PATCH v3 4/6] staging: vchiq_core: Refactor notify_bulks() Umang Jain
2024-10-13  7:22   ` Kieran Bingham [this message]
2024-10-13  7:33     ` Umang Jain
2024-10-13 12:14       ` Dan Carpenter
2024-10-13 11:59   ` Dan Carpenter
2024-10-12 18:56 ` [PATCH v3 5/6] staging: vchiq_core: Lower indentation in parse_open() Umang Jain
2024-10-12 18:56 ` [PATCH v3 6/6] staging: vchiq_core: Lower indentation in vchiq_close_service_internal Umang Jain

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=172880414537.1925926.9488617715642757683@ping.linuxembedded.co.uk \
    --to=kieran.bingham@ideasonboard.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=dan.carpenter@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-list@raspberrypi.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=umang.jain@ideasonboard.com \
    --cc=wahrenst@gmx.net \
    /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

all inboxes | Powered by JetHome®