kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/5] driver core: platform: Introduce platform_get_mem_or_io_resource()
@ 2020-10-27 17:58 Andy Shevchenko
  2020-10-27 17:58 ` [PATCH v1 2/5] vfio: platform: Switch to use platform_get_mem_or_io_resource() Andy Shevchenko
  2020-12-03 13:21 ` [PATCH v1 1/5] driver core: platform: Introduce platform_get_mem_or_io_resource() Cornelia Huck
  0 siblings, 2 replies; 11+ messages in thread
From: Andy Shevchenko @ 2020-10-27 17:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: Andy Shevchenko, Eric Auger, Alex Williamson, Cornelia Huck, kvm,
	linux-usb, Peng Hao, Arnd Bergmann

There are at least few existing users of the proposed API which
retrieves either MEM or IO resource from platform device.

Make it common to utilize in the existing and new users.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Eric Auger <eric.auger@redhat.com>
Cc: Alex Williamson <alex.williamson@redhat.com>
Cc: Cornelia Huck <cohuck@redhat.com>
Cc: kvm@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: Peng Hao <peng.hao2@zte.com.cn>
Cc: Arnd Bergmann <arnd@arndb.de>
---
 include/linux/platform_device.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 77a2aada106d..eb8d74744e29 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -52,6 +52,19 @@ extern struct device platform_bus;
 
 extern struct resource *platform_get_resource(struct platform_device *,
 					      unsigned int, unsigned int);
+static inline
+struct resource *platform_get_mem_or_io_resource(struct platform_device *pdev,
+						 unsigned int num)
+{
+	struct resource *res;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, num);
+	if (res)
+		return res;
+
+	return platform_get_resource(pdev, IORESOURCE_IO, num);
+}
+
 extern struct device *
 platform_find_device_by_driver(struct device *start,
 			       const struct device_driver *drv);
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v1 2/5] vfio: platform: Switch to use platform_get_mem_or_io_resource()
  2020-10-27 17:58 [PATCH v1 1/5] driver core: platform: Introduce platform_get_mem_or_io_resource() Andy Shevchenko
@ 2020-10-27 17:58 ` Andy Shevchenko
  2020-12-03 12:54   ` Auger Eric
                     ` (2 more replies)
  2020-12-03 13:21 ` [PATCH v1 1/5] driver core: platform: Introduce platform_get_mem_or_io_resource() Cornelia Huck
  1 sibling, 3 replies; 11+ messages in thread
From: Andy Shevchenko @ 2020-10-27 17:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: Andy Shevchenko, Eric Auger, Alex Williamson, Cornelia Huck, kvm

Switch to use new platform_get_mem_or_io_resource() instead of
home grown analogue.

Cc: Eric Auger <eric.auger@redhat.com>
Cc: Alex Williamson <alex.williamson@redhat.com>
Cc: Cornelia Huck <cohuck@redhat.com>
Cc: kvm@vger.kernel.org
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/vfio/platform/vfio_platform.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/vfio/platform/vfio_platform.c b/drivers/vfio/platform/vfio_platform.c
index 1e2769010089..84afafb6941b 100644
--- a/drivers/vfio/platform/vfio_platform.c
+++ b/drivers/vfio/platform/vfio_platform.c
@@ -25,19 +25,8 @@ static struct resource *get_platform_resource(struct vfio_platform_device *vdev,
 					      int num)
 {
 	struct platform_device *dev = (struct platform_device *) vdev->opaque;
-	int i;
 
-	for (i = 0; i < dev->num_resources; i++) {
-		struct resource *r = &dev->resource[i];
-
-		if (resource_type(r) & (IORESOURCE_MEM|IORESOURCE_IO)) {
-			if (!num)
-				return r;
-
-			num--;
-		}
-	}
-	return NULL;
+	return platform_get_mem_or_io_resource(dev, num);
 }
 
 static int get_platform_irq(struct vfio_platform_device *vdev, int i)
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 2/5] vfio: platform: Switch to use platform_get_mem_or_io_resource()
  2020-10-27 17:58 ` [PATCH v1 2/5] vfio: platform: Switch to use platform_get_mem_or_io_resource() Andy Shevchenko
@ 2020-12-03 12:54   ` Auger Eric
  2020-12-03 13:07     ` Andy Shevchenko
  2020-12-03 13:22   ` Cornelia Huck
  2020-12-03 18:05   ` Alex Williamson
  2 siblings, 1 reply; 11+ messages in thread
From: Auger Eric @ 2020-12-03 12:54 UTC (permalink / raw)
  To: Andy Shevchenko, Greg Kroah-Hartman, linux-kernel
  Cc: Alex Williamson, Cornelia Huck, kvm

Hi Andy,

On 10/27/20 6:58 PM, Andy Shevchenko wrote:
> Switch to use new platform_get_mem_or_io_resource() instead of
> home grown analogue.
> 
> Cc: Eric Auger <eric.auger@redhat.com>
> Cc: Alex Williamson <alex.williamson@redhat.com>
> Cc: Cornelia Huck <cohuck@redhat.com>
> Cc: kvm@vger.kernel.org
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Eric Auger <eric.auger@redhat.com>

Thanks

Eric
> ---
>  drivers/vfio/platform/vfio_platform.c | 13 +------------
>  1 file changed, 1 insertion(+), 12 deletions(-)
> 
> diff --git a/drivers/vfio/platform/vfio_platform.c b/drivers/vfio/platform/vfio_platform.c
> index 1e2769010089..84afafb6941b 100644
> --- a/drivers/vfio/platform/vfio_platform.c
> +++ b/drivers/vfio/platform/vfio_platform.c
> @@ -25,19 +25,8 @@ static struct resource *get_platform_resource(struct vfio_platform_device *vdev,
>  					      int num)
>  {
>  	struct platform_device *dev = (struct platform_device *) vdev->opaque;
> -	int i;
>  
> -	for (i = 0; i < dev->num_resources; i++) {
> -		struct resource *r = &dev->resource[i];
> -
> -		if (resource_type(r) & (IORESOURCE_MEM|IORESOURCE_IO)) {
> -			if (!num)
> -				return r;
> -
> -			num--;
> -		}
> -	}
> -	return NULL;
> +	return platform_get_mem_or_io_resource(dev, num);
>  }
>  
>  static int get_platform_irq(struct vfio_platform_device *vdev, int i)
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 2/5] vfio: platform: Switch to use platform_get_mem_or_io_resource()
  2020-12-03 12:54   ` Auger Eric
@ 2020-12-03 13:07     ` Andy Shevchenko
  2020-12-09 14:47       ` Greg Kroah-Hartman
  0 siblings, 1 reply; 11+ messages in thread
From: Andy Shevchenko @ 2020-12-03 13:07 UTC (permalink / raw)
  To: Auger Eric
  Cc: Greg Kroah-Hartman, linux-kernel, Alex Williamson, Cornelia Huck, kvm

On Thu, Dec 03, 2020 at 01:54:38PM +0100, Auger Eric wrote:
> Hi Andy,
> 
> On 10/27/20 6:58 PM, Andy Shevchenko wrote:
> > Switch to use new platform_get_mem_or_io_resource() instead of
> > home grown analogue.
> > 
> > Cc: Eric Auger <eric.auger@redhat.com>
> > Cc: Alex Williamson <alex.williamson@redhat.com>
> > Cc: Cornelia Huck <cohuck@redhat.com>
> > Cc: kvm@vger.kernel.org
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Acked-by: Eric Auger <eric.auger@redhat.com>

Thanks!

Greg, do I need to do anything else with this series?

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 1/5] driver core: platform: Introduce platform_get_mem_or_io_resource()
  2020-10-27 17:58 [PATCH v1 1/5] driver core: platform: Introduce platform_get_mem_or_io_resource() Andy Shevchenko
  2020-10-27 17:58 ` [PATCH v1 2/5] vfio: platform: Switch to use platform_get_mem_or_io_resource() Andy Shevchenko
@ 2020-12-03 13:21 ` Cornelia Huck
  1 sibling, 0 replies; 11+ messages in thread
From: Cornelia Huck @ 2020-12-03 13:21 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Greg Kroah-Hartman, linux-kernel, Eric Auger, Alex Williamson,
	kvm, linux-usb, Peng Hao, Arnd Bergmann

On Tue, 27 Oct 2020 19:58:02 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> There are at least few existing users of the proposed API which
> retrieves either MEM or IO resource from platform device.
> 
> Make it common to utilize in the existing and new users.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Eric Auger <eric.auger@redhat.com>
> Cc: Alex Williamson <alex.williamson@redhat.com>
> Cc: Cornelia Huck <cohuck@redhat.com>
> Cc: kvm@vger.kernel.org
> Cc: linux-usb@vger.kernel.org
> Cc: Peng Hao <peng.hao2@zte.com.cn>
> Cc: Arnd Bergmann <arnd@arndb.de>
> ---
>  include/linux/platform_device.h | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
> index 77a2aada106d..eb8d74744e29 100644
> --- a/include/linux/platform_device.h
> +++ b/include/linux/platform_device.h
> @@ -52,6 +52,19 @@ extern struct device platform_bus;
>  
>  extern struct resource *platform_get_resource(struct platform_device *,
>  					      unsigned int, unsigned int);
> +static inline
> +struct resource *platform_get_mem_or_io_resource(struct platform_device *pdev,

Minor nit: If I would want to break up the long line, I'd use

static inline struct resource *
platform_get_mem_or_io_resource(...)

> +						 unsigned int num)
> +{
> +	struct resource *res;
> +
> +	res = platform_get_resource(pdev, IORESOURCE_MEM, num);
> +	if (res)
> +		return res;
> +
> +	return platform_get_resource(pdev, IORESOURCE_IO, num);
> +}
> +
>  extern struct device *
>  platform_find_device_by_driver(struct device *start,
>  			       const struct device_driver *drv);

Reviewed-by: Cornelia Huck <cohuck@redhat.com>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 2/5] vfio: platform: Switch to use platform_get_mem_or_io_resource()
  2020-10-27 17:58 ` [PATCH v1 2/5] vfio: platform: Switch to use platform_get_mem_or_io_resource() Andy Shevchenko
  2020-12-03 12:54   ` Auger Eric
@ 2020-12-03 13:22   ` Cornelia Huck
  2020-12-03 18:05   ` Alex Williamson
  2 siblings, 0 replies; 11+ messages in thread
From: Cornelia Huck @ 2020-12-03 13:22 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Greg Kroah-Hartman, linux-kernel, Eric Auger, Alex Williamson, kvm

On Tue, 27 Oct 2020 19:58:03 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> Switch to use new platform_get_mem_or_io_resource() instead of
> home grown analogue.
> 
> Cc: Eric Auger <eric.auger@redhat.com>
> Cc: Alex Williamson <alex.williamson@redhat.com>
> Cc: Cornelia Huck <cohuck@redhat.com>
> Cc: kvm@vger.kernel.org
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/vfio/platform/vfio_platform.c | 13 +------------
>  1 file changed, 1 insertion(+), 12 deletions(-)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 2/5] vfio: platform: Switch to use platform_get_mem_or_io_resource()
  2020-10-27 17:58 ` [PATCH v1 2/5] vfio: platform: Switch to use platform_get_mem_or_io_resource() Andy Shevchenko
  2020-12-03 12:54   ` Auger Eric
  2020-12-03 13:22   ` Cornelia Huck
@ 2020-12-03 18:05   ` Alex Williamson
  2 siblings, 0 replies; 11+ messages in thread
From: Alex Williamson @ 2020-12-03 18:05 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Greg Kroah-Hartman, linux-kernel, Eric Auger, Cornelia Huck, kvm

On Tue, 27 Oct 2020 19:58:03 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> Switch to use new platform_get_mem_or_io_resource() instead of
> home grown analogue.
> 
> Cc: Eric Auger <eric.auger@redhat.com>
> Cc: Alex Williamson <alex.williamson@redhat.com>
> Cc: Cornelia Huck <cohuck@redhat.com>
> Cc: kvm@vger.kernel.org
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/vfio/platform/vfio_platform.c | 13 +------------
>  1 file changed, 1 insertion(+), 12 deletions(-)

Acked-by: Alex Williamson <alex.williamson@redhat.com>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 2/5] vfio: platform: Switch to use platform_get_mem_or_io_resource()
  2020-12-03 13:07     ` Andy Shevchenko
@ 2020-12-09 14:47       ` Greg Kroah-Hartman
  2020-12-09 16:48         ` Andy Shevchenko
  0 siblings, 1 reply; 11+ messages in thread
From: Greg Kroah-Hartman @ 2020-12-09 14:47 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Auger Eric, linux-kernel, Alex Williamson, Cornelia Huck, kvm

On Thu, Dec 03, 2020 at 03:07:19PM +0200, Andy Shevchenko wrote:
> On Thu, Dec 03, 2020 at 01:54:38PM +0100, Auger Eric wrote:
> > Hi Andy,
> > 
> > On 10/27/20 6:58 PM, Andy Shevchenko wrote:
> > > Switch to use new platform_get_mem_or_io_resource() instead of
> > > home grown analogue.
> > > 
> > > Cc: Eric Auger <eric.auger@redhat.com>
> > > Cc: Alex Williamson <alex.williamson@redhat.com>
> > > Cc: Cornelia Huck <cohuck@redhat.com>
> > > Cc: kvm@vger.kernel.org
> > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > Acked-by: Eric Auger <eric.auger@redhat.com>
> 
> Thanks!
> 
> Greg, do I need to do anything else with this series?

Have them taken by the vfio maintainers?  I'm not that person :)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 2/5] vfio: platform: Switch to use platform_get_mem_or_io_resource()
  2020-12-09 14:47       ` Greg Kroah-Hartman
@ 2020-12-09 16:48         ` Andy Shevchenko
  2020-12-09 16:53           ` Greg Kroah-Hartman
  0 siblings, 1 reply; 11+ messages in thread
From: Andy Shevchenko @ 2020-12-09 16:48 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Auger Eric, linux-kernel, Alex Williamson, Cornelia Huck, kvm

On Wed, Dec 09, 2020 at 03:47:06PM +0100, Greg Kroah-Hartman wrote:
> On Thu, Dec 03, 2020 at 03:07:19PM +0200, Andy Shevchenko wrote:
> > On Thu, Dec 03, 2020 at 01:54:38PM +0100, Auger Eric wrote:
> > > On 10/27/20 6:58 PM, Andy Shevchenko wrote:
> > > > Switch to use new platform_get_mem_or_io_resource() instead of
> > > > home grown analogue.
> > > > 
> > > > Cc: Eric Auger <eric.auger@redhat.com>
> > > > Cc: Alex Williamson <alex.williamson@redhat.com>
> > > > Cc: Cornelia Huck <cohuck@redhat.com>
> > > > Cc: kvm@vger.kernel.org
> > > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > > Acked-by: Eric Auger <eric.auger@redhat.com>
> > 
> > Thanks!
> > 
> > Greg, do I need to do anything else with this series?
> 
> Have them taken by the vfio maintainers?  I'm not that person :)

But it can't be done with a first patch that provides a new API.
The rest seems under your realm, if I didn't miss anything.
Btw, VFIO agreed on the change (as per given tags).

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 2/5] vfio: platform: Switch to use platform_get_mem_or_io_resource()
  2020-12-09 16:48         ` Andy Shevchenko
@ 2020-12-09 16:53           ` Greg Kroah-Hartman
  2020-12-09 18:22             ` Andy Shevchenko
  0 siblings, 1 reply; 11+ messages in thread
From: Greg Kroah-Hartman @ 2020-12-09 16:53 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Auger Eric, linux-kernel, Alex Williamson, Cornelia Huck, kvm

On Wed, Dec 09, 2020 at 06:48:16PM +0200, Andy Shevchenko wrote:
> On Wed, Dec 09, 2020 at 03:47:06PM +0100, Greg Kroah-Hartman wrote:
> > On Thu, Dec 03, 2020 at 03:07:19PM +0200, Andy Shevchenko wrote:
> > > On Thu, Dec 03, 2020 at 01:54:38PM +0100, Auger Eric wrote:
> > > > On 10/27/20 6:58 PM, Andy Shevchenko wrote:
> > > > > Switch to use new platform_get_mem_or_io_resource() instead of
> > > > > home grown analogue.
> > > > > 
> > > > > Cc: Eric Auger <eric.auger@redhat.com>
> > > > > Cc: Alex Williamson <alex.williamson@redhat.com>
> > > > > Cc: Cornelia Huck <cohuck@redhat.com>
> > > > > Cc: kvm@vger.kernel.org
> > > > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > > > Acked-by: Eric Auger <eric.auger@redhat.com>
> > > 
> > > Thanks!
> > > 
> > > Greg, do I need to do anything else with this series?
> > 
> > Have them taken by the vfio maintainers?  I'm not that person :)
> 
> But it can't be done with a first patch that provides a new API.
> The rest seems under your realm, if I didn't miss anything.
> Btw, VFIO agreed on the change (as per given tags).

Ok, can you resend all of these, with the vfio tags added, so I know to
take them all?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 2/5] vfio: platform: Switch to use platform_get_mem_or_io_resource()
  2020-12-09 16:53           ` Greg Kroah-Hartman
@ 2020-12-09 18:22             ` Andy Shevchenko
  0 siblings, 0 replies; 11+ messages in thread
From: Andy Shevchenko @ 2020-12-09 18:22 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Auger Eric, linux-kernel, Alex Williamson, Cornelia Huck, kvm

On Wed, Dec 09, 2020 at 05:53:45PM +0100, Greg Kroah-Hartman wrote:
> On Wed, Dec 09, 2020 at 06:48:16PM +0200, Andy Shevchenko wrote:
> > On Wed, Dec 09, 2020 at 03:47:06PM +0100, Greg Kroah-Hartman wrote:
> > > On Thu, Dec 03, 2020 at 03:07:19PM +0200, Andy Shevchenko wrote:
> > > > On Thu, Dec 03, 2020 at 01:54:38PM +0100, Auger Eric wrote:

...

> > > > Greg, do I need to do anything else with this series?

> > > Have them taken by the vfio maintainers?  I'm not that person :)

> > But it can't be done with a first patch that provides a new API.
> > The rest seems under your realm, if I didn't miss anything.
> > Btw, VFIO agreed on the change (as per given tags).

> Ok, can you resend all of these, with the vfio tags added, so I know to
> take them all?

Sure. Will do soon.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-12-09 18:23 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-27 17:58 [PATCH v1 1/5] driver core: platform: Introduce platform_get_mem_or_io_resource() Andy Shevchenko
2020-10-27 17:58 ` [PATCH v1 2/5] vfio: platform: Switch to use platform_get_mem_or_io_resource() Andy Shevchenko
2020-12-03 12:54   ` Auger Eric
2020-12-03 13:07     ` Andy Shevchenko
2020-12-09 14:47       ` Greg Kroah-Hartman
2020-12-09 16:48         ` Andy Shevchenko
2020-12-09 16:53           ` Greg Kroah-Hartman
2020-12-09 18:22             ` Andy Shevchenko
2020-12-03 13:22   ` Cornelia Huck
2020-12-03 18:05   ` Alex Williamson
2020-12-03 13:21 ` [PATCH v1 1/5] driver core: platform: Introduce platform_get_mem_or_io_resource() Cornelia Huck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).