diff mbox series

[v13,07/42] virtio_ring: split: stop __vring_new_virtqueue as export symbol

Message ID 20220726072225.19884-8-xuanzhuo@linux.alibaba.com (mailing list archive)
State New, archived
Headers show
Series virtio pci support VIRTIO_F_RING_RESET | expand

Commit Message

Xuan Zhuo July 26, 2022, 7:21 a.m. UTC
There is currently only one place to reference __vring_new_virtqueue()
directly from the outside of virtio core. And here vring_new_virtqueue()
can be used instead.

Subsequent patches will modify __vring_new_virtqueue, so stop it as an
export symbol for now.

Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
---
 drivers/virtio/virtio_ring.c | 25 ++++++++++++++++---------
 include/linux/virtio_ring.h  | 10 ----------
 tools/virtio/virtio_test.c   |  4 ++--
 3 files changed, 18 insertions(+), 21 deletions(-)

Comments

Jason Wang July 27, 2022, 2:58 a.m. UTC | #1
在 2022/7/26 15:21, Xuan Zhuo 写道:
> There is currently only one place to reference __vring_new_virtqueue()
> directly from the outside of virtio core. And here vring_new_virtqueue()
> can be used instead.
>
> Subsequent patches will modify __vring_new_virtqueue, so stop it as an
> export symbol for now.
>
> Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
> ---
>   drivers/virtio/virtio_ring.c | 25 ++++++++++++++++---------
>   include/linux/virtio_ring.h  | 10 ----------
>   tools/virtio/virtio_test.c   |  4 ++--
>   3 files changed, 18 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> index 0ad35eca0d39..4e54ed7ee7fb 100644
> --- a/drivers/virtio/virtio_ring.c
> +++ b/drivers/virtio/virtio_ring.c
> @@ -204,6 +204,14 @@ struct vring_virtqueue {
>   #endif
>   };
>   
> +static struct virtqueue *__vring_new_virtqueue(unsigned int index,
> +					       struct vring vring,
> +					       struct virtio_device *vdev,
> +					       bool weak_barriers,
> +					       bool context,
> +					       bool (*notify)(struct virtqueue *),
> +					       void (*callback)(struct virtqueue *),
> +					       const char *name);
>   
>   /*
>    * Helpers.
> @@ -2197,14 +2205,14 @@ irqreturn_t vring_interrupt(int irq, void *_vq)
>   EXPORT_SYMBOL_GPL(vring_interrupt);
>   
>   /* Only available for split ring */
> -struct virtqueue *__vring_new_virtqueue(unsigned int index,
> -					struct vring vring,
> -					struct virtio_device *vdev,
> -					bool weak_barriers,
> -					bool context,
> -					bool (*notify)(struct virtqueue *),
> -					void (*callback)(struct virtqueue *),
> -					const char *name)
> +static struct virtqueue *__vring_new_virtqueue(unsigned int index,
> +					       struct vring vring,
> +					       struct virtio_device *vdev,
> +					       bool weak_barriers,
> +					       bool context,
> +					       bool (*notify)(struct virtqueue *),
> +					       void (*callback)(struct virtqueue *),
> +					       const char *name)
>   {
>   	struct vring_virtqueue *vq;
>   
> @@ -2272,7 +2280,6 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index,
>   	kfree(vq);
>   	return NULL;
>   }
> -EXPORT_SYMBOL_GPL(__vring_new_virtqueue);
>   
>   struct virtqueue *vring_create_virtqueue(
>   	unsigned int index,
> diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h
> index b485b13fa50b..8b8af1a38991 100644
> --- a/include/linux/virtio_ring.h
> +++ b/include/linux/virtio_ring.h
> @@ -76,16 +76,6 @@ struct virtqueue *vring_create_virtqueue(unsigned int index,
>   					 void (*callback)(struct virtqueue *vq),
>   					 const char *name);
>   
> -/* Creates a virtqueue with a custom layout. */
> -struct virtqueue *__vring_new_virtqueue(unsigned int index,
> -					struct vring vring,
> -					struct virtio_device *vdev,
> -					bool weak_barriers,
> -					bool ctx,
> -					bool (*notify)(struct virtqueue *),
> -					void (*callback)(struct virtqueue *),
> -					const char *name);
> -
>   /*
>    * Creates a virtqueue with a standard layout but a caller-allocated
>    * ring.
> diff --git a/tools/virtio/virtio_test.c b/tools/virtio/virtio_test.c
> index 23f142af544a..86a410ddcedd 100644
> --- a/tools/virtio/virtio_test.c
> +++ b/tools/virtio/virtio_test.c
> @@ -102,8 +102,8 @@ static void vq_reset(struct vq_info *info, int num, struct virtio_device *vdev)
>   
>   	memset(info->ring, 0, vring_size(num, 4096));
>   	vring_init(&info->vring, num, info->ring, 4096);


Let's remove the duplicated vring_init() here.

With this removed:

Acked-by: Jason Wang <jasowang@redhat.com>


> -	info->vq = __vring_new_virtqueue(info->idx, info->vring, vdev, true,
> -					 false, vq_notify, vq_callback, "test");
> +	info->vq = vring_new_virtqueue(info->idx, num, 4096, vdev, true, false,
> +				       info->ring, vq_notify, vq_callback, "test");
>   	assert(info->vq);
>   	info->vq->priv = info;
>   }
Xuan Zhuo July 27, 2022, 7:35 a.m. UTC | #2
On Wed, 27 Jul 2022 10:58:05 +0800, Jason Wang <jasowang@redhat.com> wrote:
>
> 在 2022/7/26 15:21, Xuan Zhuo 写道:
> > There is currently only one place to reference __vring_new_virtqueue()
> > directly from the outside of virtio core. And here vring_new_virtqueue()
> > can be used instead.
> >
> > Subsequent patches will modify __vring_new_virtqueue, so stop it as an
> > export symbol for now.
> >
> > Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
> > ---
> >   drivers/virtio/virtio_ring.c | 25 ++++++++++++++++---------
> >   include/linux/virtio_ring.h  | 10 ----------
> >   tools/virtio/virtio_test.c   |  4 ++--
> >   3 files changed, 18 insertions(+), 21 deletions(-)
> >
> > diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> > index 0ad35eca0d39..4e54ed7ee7fb 100644
> > --- a/drivers/virtio/virtio_ring.c
> > +++ b/drivers/virtio/virtio_ring.c
> > @@ -204,6 +204,14 @@ struct vring_virtqueue {
> >   #endif
> >   };
> >
> > +static struct virtqueue *__vring_new_virtqueue(unsigned int index,
> > +					       struct vring vring,
> > +					       struct virtio_device *vdev,
> > +					       bool weak_barriers,
> > +					       bool context,
> > +					       bool (*notify)(struct virtqueue *),
> > +					       void (*callback)(struct virtqueue *),
> > +					       const char *name);
> >
> >   /*
> >    * Helpers.
> > @@ -2197,14 +2205,14 @@ irqreturn_t vring_interrupt(int irq, void *_vq)
> >   EXPORT_SYMBOL_GPL(vring_interrupt);
> >
> >   /* Only available for split ring */
> > -struct virtqueue *__vring_new_virtqueue(unsigned int index,
> > -					struct vring vring,
> > -					struct virtio_device *vdev,
> > -					bool weak_barriers,
> > -					bool context,
> > -					bool (*notify)(struct virtqueue *),
> > -					void (*callback)(struct virtqueue *),
> > -					const char *name)
> > +static struct virtqueue *__vring_new_virtqueue(unsigned int index,
> > +					       struct vring vring,
> > +					       struct virtio_device *vdev,
> > +					       bool weak_barriers,
> > +					       bool context,
> > +					       bool (*notify)(struct virtqueue *),
> > +					       void (*callback)(struct virtqueue *),
> > +					       const char *name)
> >   {
> >   	struct vring_virtqueue *vq;
> >
> > @@ -2272,7 +2280,6 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index,
> >   	kfree(vq);
> >   	return NULL;
> >   }
> > -EXPORT_SYMBOL_GPL(__vring_new_virtqueue);
> >
> >   struct virtqueue *vring_create_virtqueue(
> >   	unsigned int index,
> > diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h
> > index b485b13fa50b..8b8af1a38991 100644
> > --- a/include/linux/virtio_ring.h
> > +++ b/include/linux/virtio_ring.h
> > @@ -76,16 +76,6 @@ struct virtqueue *vring_create_virtqueue(unsigned int index,
> >   					 void (*callback)(struct virtqueue *vq),
> >   					 const char *name);
> >
> > -/* Creates a virtqueue with a custom layout. */
> > -struct virtqueue *__vring_new_virtqueue(unsigned int index,
> > -					struct vring vring,
> > -					struct virtio_device *vdev,
> > -					bool weak_barriers,
> > -					bool ctx,
> > -					bool (*notify)(struct virtqueue *),
> > -					void (*callback)(struct virtqueue *),
> > -					const char *name);
> > -
> >   /*
> >    * Creates a virtqueue with a standard layout but a caller-allocated
> >    * ring.
> > diff --git a/tools/virtio/virtio_test.c b/tools/virtio/virtio_test.c
> > index 23f142af544a..86a410ddcedd 100644
> > --- a/tools/virtio/virtio_test.c
> > +++ b/tools/virtio/virtio_test.c
> > @@ -102,8 +102,8 @@ static void vq_reset(struct vq_info *info, int num, struct virtio_device *vdev)
> >
> >   	memset(info->ring, 0, vring_size(num, 4096));
> >   	vring_init(&info->vring, num, info->ring, 4096);
>
>
> Let's remove the duplicated vring_init() here.
>
> With this removed:

The reason I didn't delete this vring_init() is because info->vring is used
elsewhere. So it can't be deleted directly.

Thanks.

>
> Acked-by: Jason Wang <jasowang@redhat.com>
>
>
> > -	info->vq = __vring_new_virtqueue(info->idx, info->vring, vdev, true,
> > -					 false, vq_notify, vq_callback, "test");
> > +	info->vq = vring_new_virtqueue(info->idx, num, 4096, vdev, true, false,
> > +				       info->ring, vq_notify, vq_callback, "test");
> >   	assert(info->vq);
> >   	info->vq->priv = info;
> >   }
>
Jason Wang July 28, 2022, 2:36 a.m. UTC | #3
On Wed, Jul 27, 2022 at 3:36 PM Xuan Zhuo <xuanzhuo@linux.alibaba.com> wrote:
>
> On Wed, 27 Jul 2022 10:58:05 +0800, Jason Wang <jasowang@redhat.com> wrote:
> >
> > 在 2022/7/26 15:21, Xuan Zhuo 写道:
> > > There is currently only one place to reference __vring_new_virtqueue()
> > > directly from the outside of virtio core. And here vring_new_virtqueue()
> > > can be used instead.
> > >
> > > Subsequent patches will modify __vring_new_virtqueue, so stop it as an
> > > export symbol for now.
> > >
> > > Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
> > > ---
> > >   drivers/virtio/virtio_ring.c | 25 ++++++++++++++++---------
> > >   include/linux/virtio_ring.h  | 10 ----------
> > >   tools/virtio/virtio_test.c   |  4 ++--
> > >   3 files changed, 18 insertions(+), 21 deletions(-)
> > >
> > > diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> > > index 0ad35eca0d39..4e54ed7ee7fb 100644
> > > --- a/drivers/virtio/virtio_ring.c
> > > +++ b/drivers/virtio/virtio_ring.c
> > > @@ -204,6 +204,14 @@ struct vring_virtqueue {
> > >   #endif
> > >   };
> > >
> > > +static struct virtqueue *__vring_new_virtqueue(unsigned int index,
> > > +                                          struct vring vring,
> > > +                                          struct virtio_device *vdev,
> > > +                                          bool weak_barriers,
> > > +                                          bool context,
> > > +                                          bool (*notify)(struct virtqueue *),
> > > +                                          void (*callback)(struct virtqueue *),
> > > +                                          const char *name);
> > >
> > >   /*
> > >    * Helpers.
> > > @@ -2197,14 +2205,14 @@ irqreturn_t vring_interrupt(int irq, void *_vq)
> > >   EXPORT_SYMBOL_GPL(vring_interrupt);
> > >
> > >   /* Only available for split ring */
> > > -struct virtqueue *__vring_new_virtqueue(unsigned int index,
> > > -                                   struct vring vring,
> > > -                                   struct virtio_device *vdev,
> > > -                                   bool weak_barriers,
> > > -                                   bool context,
> > > -                                   bool (*notify)(struct virtqueue *),
> > > -                                   void (*callback)(struct virtqueue *),
> > > -                                   const char *name)
> > > +static struct virtqueue *__vring_new_virtqueue(unsigned int index,
> > > +                                          struct vring vring,
> > > +                                          struct virtio_device *vdev,
> > > +                                          bool weak_barriers,
> > > +                                          bool context,
> > > +                                          bool (*notify)(struct virtqueue *),
> > > +                                          void (*callback)(struct virtqueue *),
> > > +                                          const char *name)
> > >   {
> > >     struct vring_virtqueue *vq;
> > >
> > > @@ -2272,7 +2280,6 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index,
> > >     kfree(vq);
> > >     return NULL;
> > >   }
> > > -EXPORT_SYMBOL_GPL(__vring_new_virtqueue);
> > >
> > >   struct virtqueue *vring_create_virtqueue(
> > >     unsigned int index,
> > > diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h
> > > index b485b13fa50b..8b8af1a38991 100644
> > > --- a/include/linux/virtio_ring.h
> > > +++ b/include/linux/virtio_ring.h
> > > @@ -76,16 +76,6 @@ struct virtqueue *vring_create_virtqueue(unsigned int index,
> > >                                      void (*callback)(struct virtqueue *vq),
> > >                                      const char *name);
> > >
> > > -/* Creates a virtqueue with a custom layout. */
> > > -struct virtqueue *__vring_new_virtqueue(unsigned int index,
> > > -                                   struct vring vring,
> > > -                                   struct virtio_device *vdev,
> > > -                                   bool weak_barriers,
> > > -                                   bool ctx,
> > > -                                   bool (*notify)(struct virtqueue *),
> > > -                                   void (*callback)(struct virtqueue *),
> > > -                                   const char *name);
> > > -
> > >   /*
> > >    * Creates a virtqueue with a standard layout but a caller-allocated
> > >    * ring.
> > > diff --git a/tools/virtio/virtio_test.c b/tools/virtio/virtio_test.c
> > > index 23f142af544a..86a410ddcedd 100644
> > > --- a/tools/virtio/virtio_test.c
> > > +++ b/tools/virtio/virtio_test.c
> > > @@ -102,8 +102,8 @@ static void vq_reset(struct vq_info *info, int num, struct virtio_device *vdev)
> > >
> > >     memset(info->ring, 0, vring_size(num, 4096));
> > >     vring_init(&info->vring, num, info->ring, 4096);
> >
> >
> > Let's remove the duplicated vring_init() here.
> >
> > With this removed:
>
> The reason I didn't delete this vring_init() is because info->vring is used
> elsewhere. So it can't be deleted directly.

Ok, so we can leave it for future refactoring.

Acked-by: Jason Wang <jasowang@redhat.com>

Thanks

>
> Thanks.
>
> >
> > Acked-by: Jason Wang <jasowang@redhat.com>
> >
> >
> > > -   info->vq = __vring_new_virtqueue(info->idx, info->vring, vdev, true,
> > > -                                    false, vq_notify, vq_callback, "test");
> > > +   info->vq = vring_new_virtqueue(info->idx, num, 4096, vdev, true, false,
> > > +                                  info->ring, vq_notify, vq_callback, "test");
> > >     assert(info->vq);
> > >     info->vq->priv = info;
> > >   }
> >
>
diff mbox series

Patch

diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 0ad35eca0d39..4e54ed7ee7fb 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -204,6 +204,14 @@  struct vring_virtqueue {
 #endif
 };
 
+static struct virtqueue *__vring_new_virtqueue(unsigned int index,
+					       struct vring vring,
+					       struct virtio_device *vdev,
+					       bool weak_barriers,
+					       bool context,
+					       bool (*notify)(struct virtqueue *),
+					       void (*callback)(struct virtqueue *),
+					       const char *name);
 
 /*
  * Helpers.
@@ -2197,14 +2205,14 @@  irqreturn_t vring_interrupt(int irq, void *_vq)
 EXPORT_SYMBOL_GPL(vring_interrupt);
 
 /* Only available for split ring */
-struct virtqueue *__vring_new_virtqueue(unsigned int index,
-					struct vring vring,
-					struct virtio_device *vdev,
-					bool weak_barriers,
-					bool context,
-					bool (*notify)(struct virtqueue *),
-					void (*callback)(struct virtqueue *),
-					const char *name)
+static struct virtqueue *__vring_new_virtqueue(unsigned int index,
+					       struct vring vring,
+					       struct virtio_device *vdev,
+					       bool weak_barriers,
+					       bool context,
+					       bool (*notify)(struct virtqueue *),
+					       void (*callback)(struct virtqueue *),
+					       const char *name)
 {
 	struct vring_virtqueue *vq;
 
@@ -2272,7 +2280,6 @@  struct virtqueue *__vring_new_virtqueue(unsigned int index,
 	kfree(vq);
 	return NULL;
 }
-EXPORT_SYMBOL_GPL(__vring_new_virtqueue);
 
 struct virtqueue *vring_create_virtqueue(
 	unsigned int index,
diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h
index b485b13fa50b..8b8af1a38991 100644
--- a/include/linux/virtio_ring.h
+++ b/include/linux/virtio_ring.h
@@ -76,16 +76,6 @@  struct virtqueue *vring_create_virtqueue(unsigned int index,
 					 void (*callback)(struct virtqueue *vq),
 					 const char *name);
 
-/* Creates a virtqueue with a custom layout. */
-struct virtqueue *__vring_new_virtqueue(unsigned int index,
-					struct vring vring,
-					struct virtio_device *vdev,
-					bool weak_barriers,
-					bool ctx,
-					bool (*notify)(struct virtqueue *),
-					void (*callback)(struct virtqueue *),
-					const char *name);
-
 /*
  * Creates a virtqueue with a standard layout but a caller-allocated
  * ring.
diff --git a/tools/virtio/virtio_test.c b/tools/virtio/virtio_test.c
index 23f142af544a..86a410ddcedd 100644
--- a/tools/virtio/virtio_test.c
+++ b/tools/virtio/virtio_test.c
@@ -102,8 +102,8 @@  static void vq_reset(struct vq_info *info, int num, struct virtio_device *vdev)
 
 	memset(info->ring, 0, vring_size(num, 4096));
 	vring_init(&info->vring, num, info->ring, 4096);
-	info->vq = __vring_new_virtqueue(info->idx, info->vring, vdev, true,
-					 false, vq_notify, vq_callback, "test");
+	info->vq = vring_new_virtqueue(info->idx, num, 4096, vdev, true, false,
+				       info->ring, vq_notify, vq_callback, "test");
 	assert(info->vq);
 	info->vq->priv = info;
 }