public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ido Yariv <ido@wizery.com>
To: sjur.brandeland@stericsson.com
Cc: Ohad Ben-Cohen <ohad@wizery.com>,
	linux-kernel@vger.kernel.org,
	Dmitry Tarnyagin <dmitry.tarnyagin@stericsson.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Erwan Yvin <erwan.yvin@stericsson.com>,
	sjur@brendeland.net
Subject: Re: [PATCH 8/9] remoteproc: Calculate max_notifyid by counting vrings
Date: Wed, 20 Feb 2013 12:45:39 +0200	[thread overview]
Message-ID: <20130220104539.GE16388@WorkStation.localnet> (raw)
In-Reply-To: <1360496352-29482-9-git-send-email-sjur.brandeland@stericsson.com>

Hi Sjur,

On Sun, Feb 10, 2013 at 12:39:11PM +0100, sjur.brandeland@stericsson.com wrote:
> From: Sjur Brændeland <sjur.brandeland@stericsson.com>
> 
> Simplify handling of max_notifyid by simply counting the
> number of vrings.
> 
> Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
> ---
>  drivers/remoteproc/remoteproc_core.c |   34 +++++++++++++++++++---------------
>  1 files changed, 19 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
> index ec9f81e..14f40eb 100644
> --- a/drivers/remoteproc/remoteproc_core.c
> +++ b/drivers/remoteproc/remoteproc_core.c
> @@ -226,9 +226,6 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i)
>  		return ret;
>  	}
>  
> -	/* Store largest notifyid */
> -	rproc->max_notifyid = max(rproc->max_notifyid, notifyid);
> -
>  	dev_dbg(dev, "vring%d: va %p dma %llx size %x idr %d\n", i, va,
>  				(unsigned long long)dma, size, notifyid);
>  
> @@ -278,25 +275,13 @@ rproc_parse_vring(struct rproc_vdev *rvdev, struct fw_rsc_vdev *rsc, int i)
>  	return 0;
>  }
>  
> -static int rproc_max_notifyid(int id, void *p, void *data)
> -{
> -	int *maxid = data;
> -	*maxid = max(*maxid, id);
> -	return 0;
> -}
> -
>  void rproc_free_vring(struct rproc_vring *rvring)
>  {
>  	int size = PAGE_ALIGN(vring_size(rvring->len, rvring->align));
>  	struct rproc *rproc = rvring->rvdev->rproc;
> -	int maxid = 0;
>  
>  	dma_free_coherent(rproc->dev.parent, size, rvring->va, rvring->dma);
>  	idr_remove(&rproc->notifyids, rvring->notifyid);
> -
> -	/* Find the largest remaining notifyid */
> -	idr_for_each(&rproc->notifyids, rproc_max_notifyid, &maxid);
> -	rproc->max_notifyid = maxid;
>  }
>  
>  /**
> @@ -679,6 +664,15 @@ free_carv:
>  	return ret;
>  }
>  
> +static int rproc_handle_notifyid(struct rproc *rproc, struct fw_rsc_vdev *rsc,
> +								int avail)
> +{
> +	/* Summerize the number of notification IDs */
> +	rproc->max_notifyid += rsc->num_of_vrings;
> +
> +	return 0;
> +}
> +
>  /*
>   * A lookup table for resource handlers. The indices are defined in
>   * enum fw_resource_type.
> @@ -694,6 +688,10 @@ static rproc_handle_resource_t rproc_handle_vdev_rsc[RSC_LAST] = {
>  	[RSC_VDEV] = (rproc_handle_resource_t)rproc_handle_vdev,
>  };
>  
> +static rproc_handle_resource_t rproc_handle_notifyid_rsc[RSC_LAST] = {
> +	[RSC_VDEV] = (rproc_handle_resource_t)rproc_handle_notifyid,
> +};
> +
>  /* handle firmware resource entries before booting the remote processor */
>  static int
>  rproc_handle_resource(struct rproc *rproc, struct resource_table *table,
> @@ -868,6 +866,12 @@ static void rproc_fw_config_virtio(const struct firmware *fw, void *context)
>  	if (!table)
>  		goto out;
>  
> +	rproc->max_notifyid = 0;
> +
> +	/* count the numbe of notify-ids */

Small typo there.

> +	ret = rproc_handle_resource(rproc, table, tablesz,
> +						rproc_handle_notifyid_rsc);
> +

AFAICT, this will yield a higher max_notifyid than before (by one), since the
notification ids are zero based.

>  	/* look for virtio devices and register them */
>  	ret = rproc_handle_resource(rproc, table, tablesz,
>  						rproc_handle_vdev_rsc);
> -- 
> 1.7.5.4
> 

Thanks,
Ido.

  reply	other threads:[~2013-02-20 10:45 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-10 11:39 [PATCH 0/9] remoteproc: Support bi-directional vdev config space sjur.brandeland
2013-02-10 11:39 ` [PATCH 1/9] remoteproc: Bugfix: Deallocate firmware image on shutdown sjur.brandeland
2013-03-19 12:37   ` Ohad Ben-Cohen
2013-03-19 12:40     ` Sjur BRENDELAND
2013-03-19 13:15       ` Ohad Ben-Cohen
2013-02-10 11:39 ` [PATCH 2/9] remoteproc: Refactor function rproc_elf_find_rsc_table sjur.brandeland
2013-02-20 10:44   ` Ido Yariv
2013-02-10 11:39 ` [PATCH 3/9] remoteproc: Parse ELF file to find resource table address sjur.brandeland
2013-02-20 10:44   ` Ido Yariv
2013-02-10 11:39 ` [PATCH 4/9] remoteproc: Parse STE-firmware and " sjur.brandeland
2013-02-10 11:39 ` [PATCH 5/9] remoteproc: Set vring addresses in resource table sjur.brandeland
2013-02-10 11:39 ` [PATCH 6/9] remoteproc: Support virtio config space sjur.brandeland
2013-02-20 10:45   ` Ido Yariv
2013-02-10 11:39 ` [PATCH 7/9] remoteproc: Code cleanup of resource parsing sjur.brandeland
2013-02-10 11:39 ` [PATCH 8/9] remoteproc: Calculate max_notifyid by counting vrings sjur.brandeland
2013-02-20 10:45   ` Ido Yariv [this message]
2013-02-10 11:39 ` [PATCH 9/9] remoteproc: Always perserve resource table data sjur.brandeland
2013-02-20 10:46   ` Ido Yariv
2013-02-21 15:56     ` Sjur Brændeland

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=20130220104539.GE16388@WorkStation.localnet \
    --to=ido@wizery.com \
    --cc=dmitry.tarnyagin@stericsson.com \
    --cc=erwan.yvin@stericsson.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ohad@wizery.com \
    --cc=sjur.brandeland@stericsson.com \
    --cc=sjur@brendeland.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