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 6/9] remoteproc: Support virtio config space.
Date: Wed, 20 Feb 2013 12:45:10 +0200 [thread overview]
Message-ID: <20130220104510.GD16388@WorkStation.localnet> (raw)
In-Reply-To: <1360496352-29482-7-git-send-email-sjur.brandeland@stericsson.com>
Hi Sjur,
On Sun, Feb 10, 2013 at 12:39:09PM +0100, sjur.brandeland@stericsson.com wrote:
> From: Sjur Brændeland <sjur.brandeland@stericsson.com>
>
> Support virtio configuration space and device status and
> feature negotiation with remote device. This virtio device
> can now access the resource table in shared memory.
>
> Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
> ---
> drivers/remoteproc/remoteproc_core.c | 3 --
> drivers/remoteproc/remoteproc_virtio.c | 38 +++++++++++++++++++++++++++++--
> include/linux/remoteproc.h | 2 -
> 3 files changed, 35 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
> index c12a385..1bf410d 100644
> --- a/drivers/remoteproc/remoteproc_core.c
> +++ b/drivers/remoteproc/remoteproc_core.c
> @@ -368,9 +368,6 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc,
> goto free_rvdev;
> }
>
> - /* remember the device features */
> - rvdev->dfeatures = rsc->dfeatures;
> -
> /* remember the resource entry */
> rvdev->rsc = rsc;
>
> diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c
> index 9e198e5..d98cdd8 100644
> --- a/drivers/remoteproc/remoteproc_virtio.c
> +++ b/drivers/remoteproc/remoteproc_virtio.c
> @@ -182,16 +182,21 @@ error:
> */
> static u8 rproc_virtio_get_status(struct virtio_device *vdev)
> {
> - return 0;
> + struct rproc_vdev *rvdev = vdev_to_rvdev(vdev);
> + return rvdev->rsc->status;
> }
>
> static void rproc_virtio_set_status(struct virtio_device *vdev, u8 status)
> {
> + struct rproc_vdev *rvdev = vdev_to_rvdev(vdev);
> + rvdev->rsc->status = status;
> dev_dbg(&vdev->dev, "status: %d\n", status);
> }
>
> static void rproc_virtio_reset(struct virtio_device *vdev)
> {
> + struct rproc_vdev *rvdev = vdev_to_rvdev(vdev);
> + rvdev->rsc->status = 0;
> dev_dbg(&vdev->dev, "reset !\n");
> }
>
> @@ -200,7 +205,7 @@ static u32 rproc_virtio_get_features(struct virtio_device *vdev)
> {
> struct rproc_vdev *rvdev = vdev_to_rvdev(vdev);
>
> - return rvdev->dfeatures;
> + return rvdev->rsc->dfeatures;
> }
>
> static void rproc_virtio_finalize_features(struct virtio_device *vdev)
> @@ -219,7 +224,31 @@ static void rproc_virtio_finalize_features(struct virtio_device *vdev)
> * fixed as part of a small resource table overhaul and then an
> * extension of the virtio resource entries.
> */
> - rvdev->gfeatures = vdev->features[0];
> + rvdev->rsc->gfeatures = vdev->features[0];
> +}
> +
> +void rproc_virtio_get(struct virtio_device *vdev, unsigned offset,
> + void *buf, unsigned len)
> +{
> + struct rproc_vdev *rvdev = vdev_to_rvdev(vdev);
> + void *cfg = &rvdev->rsc->vring[rvdev->rsc->num_of_vrings];
> + if (offset + len > rvdev->rsc->config_len)
Perhaps check for integer overflow here?
> + dev_err(&vdev->dev,
> + "rproc_virtio_get: access out of bounds\n");
> + else
> + memcpy(buf, cfg + offset, len);
> +}
> +
> +void rproc_virtio_set(struct virtio_device *vdev, unsigned offset,
> + const void *buf, unsigned len)
> +{
> + struct rproc_vdev *rvdev = vdev_to_rvdev(vdev);
> + void *cfg = &rvdev->rsc->vring[rvdev->rsc->num_of_vrings];
> + if (offset + len > rvdev->rsc->config_len)
Here as well.
> + dev_err(&vdev->dev,
> + "rproc_virtio_set: access out of bounds\n");
> + else
> + memcpy(cfg + offset, buf, len);
> }
>
> static struct virtio_config_ops rproc_virtio_config_ops = {
> @@ -230,6 +259,9 @@ static struct virtio_config_ops rproc_virtio_config_ops = {
> .reset = rproc_virtio_reset,
> .set_status = rproc_virtio_set_status,
> .get_status = rproc_virtio_get_status,
> + .get = rproc_virtio_get,
> + .set = rproc_virtio_set,
> +
> };
>
> /*
> diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
> index cdacd66..c0c363c 100644
> --- a/include/linux/remoteproc.h
> +++ b/include/linux/remoteproc.h
> @@ -471,8 +471,6 @@ struct rproc_vdev {
> struct rproc *rproc;
> struct virtio_device vdev;
> struct rproc_vring vring[RVDEV_NUM_VRINGS];
> - unsigned long dfeatures;
> - unsigned long gfeatures;
> struct fw_rsc_vdev *rsc;
> };
>
> --
> 1.7.5.4
>
Thanks,
Ido.
next prev parent 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 [this message]
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
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=20130220104510.GD16388@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.