From: Wei Liu <wei.liu@kernel.org>
To: Paul Durrant <pdurrant@amazon.com>
Cc: Wei Liu <wei.liu@kernel.org>, Paul Durrant <paul@xen.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
xen-devel@lists.xenproject.org,
"David S. Miller" <davem@davemloft.net>
Subject: Re: [Xen-devel] [PATCH net-next] xen-netback: support dynamic unbind/bind
Date: Mon, 23 Dec 2019 11:35:45 +0000 [thread overview]
Message-ID: <20191223113545.nwugg7lsorttunuu@debian> (raw)
In-Reply-To: <20191223095923.2458-1-pdurrant@amazon.com>
On Mon, Dec 23, 2019 at 09:59:23AM +0000, Paul Durrant wrote:
[...]
> diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
> index f15ba3de6195..0c8a02a1ead7 100644
> --- a/drivers/net/xen-netback/interface.c
> +++ b/drivers/net/xen-netback/interface.c
> @@ -585,6 +585,7 @@ int xenvif_connect_ctrl(struct xenvif *vif, grant_ref_t ring_ref,
> struct net_device *dev = vif->dev;
> void *addr;
> struct xen_netif_ctrl_sring *shared;
> + RING_IDX rsp_prod, req_prod;
> int err;
>
> err = xenbus_map_ring_valloc(xenvif_to_xenbus_device(vif),
> @@ -593,7 +594,14 @@ int xenvif_connect_ctrl(struct xenvif *vif, grant_ref_t ring_ref,
> goto err;
>
> shared = (struct xen_netif_ctrl_sring *)addr;
> - BACK_RING_INIT(&vif->ctrl, shared, XEN_PAGE_SIZE);
> + rsp_prod = READ_ONCE(shared->rsp_prod);
> + req_prod = READ_ONCE(shared->req_prod);
> +
> + BACK_RING_ATTACH(&vif->ctrl, shared, rsp_prod, XEN_PAGE_SIZE);
> +
> + err = -EIO;
> + if (req_prod - rsp_prod > RING_SIZE(&vif->ctrl))
> + goto err_unmap;
I think it makes more sense to attach the ring after this check has been
done, but I can see you want to structure code like this to reuse the
unmap error path.
So:
Reviewed-by: Wei Liu <wei.liu@kernel.org>
Nice work btw.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
WARNING: multiple messages have this Message-ID (diff)
From: Wei Liu <wei.liu@kernel.org>
To: Paul Durrant <pdurrant@amazon.com>
Cc: xen-devel@lists.xenproject.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, Wei Liu <wei.liu@kernel.org>,
Paul Durrant <paul@xen.org>,
"David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH net-next] xen-netback: support dynamic unbind/bind
Date: Mon, 23 Dec 2019 11:35:45 +0000 [thread overview]
Message-ID: <20191223113545.nwugg7lsorttunuu@debian> (raw)
In-Reply-To: <20191223095923.2458-1-pdurrant@amazon.com>
On Mon, Dec 23, 2019 at 09:59:23AM +0000, Paul Durrant wrote:
[...]
> diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
> index f15ba3de6195..0c8a02a1ead7 100644
> --- a/drivers/net/xen-netback/interface.c
> +++ b/drivers/net/xen-netback/interface.c
> @@ -585,6 +585,7 @@ int xenvif_connect_ctrl(struct xenvif *vif, grant_ref_t ring_ref,
> struct net_device *dev = vif->dev;
> void *addr;
> struct xen_netif_ctrl_sring *shared;
> + RING_IDX rsp_prod, req_prod;
> int err;
>
> err = xenbus_map_ring_valloc(xenvif_to_xenbus_device(vif),
> @@ -593,7 +594,14 @@ int xenvif_connect_ctrl(struct xenvif *vif, grant_ref_t ring_ref,
> goto err;
>
> shared = (struct xen_netif_ctrl_sring *)addr;
> - BACK_RING_INIT(&vif->ctrl, shared, XEN_PAGE_SIZE);
> + rsp_prod = READ_ONCE(shared->rsp_prod);
> + req_prod = READ_ONCE(shared->req_prod);
> +
> + BACK_RING_ATTACH(&vif->ctrl, shared, rsp_prod, XEN_PAGE_SIZE);
> +
> + err = -EIO;
> + if (req_prod - rsp_prod > RING_SIZE(&vif->ctrl))
> + goto err_unmap;
I think it makes more sense to attach the ring after this check has been
done, but I can see you want to structure code like this to reuse the
unmap error path.
So:
Reviewed-by: Wei Liu <wei.liu@kernel.org>
Nice work btw.
next prev parent reply other threads:[~2019-12-23 11:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-23 9:59 [Xen-devel] [PATCH net-next] xen-netback: support dynamic unbind/bind Paul Durrant
2019-12-23 9:59 ` Paul Durrant
2019-12-23 11:35 ` Wei Liu [this message]
2019-12-23 11:35 ` Wei Liu
2019-12-23 11:46 ` [Xen-devel] " Durrant, Paul
2019-12-23 11:46 ` Durrant, Paul
2019-12-26 23:16 ` [Xen-devel] " David Miller
2019-12-26 23:16 ` David Miller
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=20191223113545.nwugg7lsorttunuu@debian \
--to=wei.liu@kernel.org \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=paul@xen.org \
--cc=pdurrant@amazon.com \
--cc=xen-devel@lists.xenproject.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 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.