2022-08-16 10:58:27

by Heikki Krogerus

[permalink] [raw]
Subject: [PATCH 0/6] ACPI: New helper function acpi_dev_get_memory_resources() and a new ACPI ID

Hi,

The helper function returns all memory resources described for a
device regardless of the ACPI descriptor type (as long as it's
memory), but the first patch introduces new ACPI ID for the IOM
controller on Intel Meteor Lake and also separately modifies the
driver so that it can get the memory resource from Address Space
Resource Descriptor.

An alternative would have been to introduce that helper function first
so we would not need to modify the driver when the new ID is added,
but then the helper would also need to be applied to the stable kernel
releases, and that does not feel necessary or appropriate in this
case, at least not IMO.

So that's why I'm proposing here that we first add the ID, and only
after that introduce the helper, and only for mainline. That way the
patch introducing the ID is the only that goes to the stable releases.

If that's okay, and these don't have any other problems, I assume it's
OK if Rafael takes all of these, including the ID?

thanks,

Heikki Krogerus (5):
ACPI: resource: Filter out the non memory resources in is_memory()
ACPI: resource: Add helper function acpi_dev_get_memory_resources()
ACPI: APD: Use the helper acpi_dev_get_memory_resources()
ACPI: LPSS: Use the helper acpi_dev_get_memory_resources()
usb: typec: intel_pmc_mux: Use the helper
acpi_dev_get_memory_resources()

Utkarsh Patel (1):
usb: typec: intel_pmc_mux: Add new ACPI ID for Meteor Lake IOM device

drivers/acpi/acpi_apd.c | 9 +--------
drivers/acpi/acpi_lpss.c | 9 +--------
drivers/acpi/resource.c | 20 ++++++++++++++++++++
drivers/usb/typec/mux/intel_pmc_mux.c | 12 ++++--------
include/linux/acpi.h | 1 +
5 files changed, 27 insertions(+), 24 deletions(-)

--
2.35.1


2022-08-16 11:28:12

by Heikki Krogerus

[permalink] [raw]
Subject: [PATCH 3/6] ACPI: resource: Add helper function acpi_dev_get_memory_resources()

Wrapper function that finds all memory type resources by
using acpi_dev_get_resources(). It removes the need for the
drivers to check the resource data type separately.

Signed-off-by: Heikki Krogerus <[email protected]>
---
drivers/acpi/resource.c | 17 +++++++++++++++++
include/linux/acpi.h | 1 +
2 files changed, 18 insertions(+)

diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
index e644e90d18847..8032d50ca9441 100644
--- a/drivers/acpi/resource.c
+++ b/drivers/acpi/resource.c
@@ -721,6 +721,23 @@ int acpi_dev_get_dma_resources(struct acpi_device *adev, struct list_head *list)
}
EXPORT_SYMBOL_GPL(acpi_dev_get_dma_resources);

+/**
+ * acpi_dev_get_memory_resources - Get current memory resources of a device.
+ * @adev: ACPI device node to get the resources for.
+ * @list: Head of the resultant list of resources (must be empty).
+ *
+ * This is a helper function that locates all memory type resources of @adev
+ * with acpi_dev_get_resources().
+ *
+ * The number of resources in the output list is returned on success, an error
+ * code reflecting the error condition is returned otherwise.
+ */
+int acpi_dev_get_memory_resources(struct acpi_device *adev, struct list_head *list)
+{
+ return acpi_dev_get_resources(adev, list, is_memory, NULL);
+}
+EXPORT_SYMBOL_GPL(acpi_dev_get_memory_resources);
+
/**
* acpi_dev_filter_resource_type - Filter ACPI resource according to resource
* types
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 6f64b2f3dc547..ed4aa395cc49b 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -506,6 +506,7 @@ int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list,
void *preproc_data);
int acpi_dev_get_dma_resources(struct acpi_device *adev,
struct list_head *list);
+int acpi_dev_get_memory_resources(struct acpi_device *adev, struct list_head *list);
int acpi_dev_filter_resource_type(struct acpi_resource *ares,
unsigned long types);

--
2.35.1

2022-08-16 11:43:24

by Heikki Krogerus

[permalink] [raw]
Subject: [PATCH 6/6] usb: typec: intel_pmc_mux: Use the helper acpi_dev_get_memory_resources()

It removes the need to check the resource data type
separately.

Signed-off-by: Heikki Krogerus <[email protected]>
---
drivers/usb/typec/mux/intel_pmc_mux.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c
index a8e273fe204ab..e1f4df7238bf4 100644
--- a/drivers/usb/typec/mux/intel_pmc_mux.c
+++ b/drivers/usb/typec/mux/intel_pmc_mux.c
@@ -569,15 +569,6 @@ static int pmc_usb_register_port(struct pmc_usb *pmc, int index,
return ret;
}

-static int is_memory(struct acpi_resource *res, void *data)
-{
- struct resource_win win = {};
- struct resource *r = &win.res;
-
- return !(acpi_dev_resource_memory(res, r) ||
- acpi_dev_resource_address_space(res, &win));
-}
-
/* IOM ACPI IDs and IOM_PORT_STATUS_OFFSET */
static const struct acpi_device_id iom_acpi_ids[] = {
/* TigerLake */
@@ -611,7 +602,7 @@ static int pmc_usb_probe_iom(struct pmc_usb *pmc)
return -ENODEV;

INIT_LIST_HEAD(&resource_list);
- ret = acpi_dev_get_resources(adev, &resource_list, is_memory, NULL);
+ ret = acpi_dev_get_memory_resources(adev, &resource_list);
if (ret < 0)
return ret;

--
2.35.1

2022-08-16 11:43:50

by Heikki Krogerus

[permalink] [raw]
Subject: [PATCH 4/6] ACPI: APD: Use the helper acpi_dev_get_memory_resources()

It removes the need to check the resource data type
separately.

Signed-off-by: Heikki Krogerus <[email protected]>
---
drivers/acpi/acpi_apd.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/acpi/acpi_apd.c b/drivers/acpi/acpi_apd.c
index ad245bbd965ec..3bbe2276cac76 100644
--- a/drivers/acpi/acpi_apd.c
+++ b/drivers/acpi/acpi_apd.c
@@ -60,12 +60,6 @@ static int acpi_apd_setup(struct apd_private_data *pdata)
}

#ifdef CONFIG_X86_AMD_PLATFORM_DEVICE
-static int misc_check_res(struct acpi_resource *ares, void *data)
-{
- struct resource res;
-
- return !acpi_dev_resource_memory(ares, &res);
-}

static int fch_misc_setup(struct apd_private_data *pdata)
{
@@ -82,8 +76,7 @@ static int fch_misc_setup(struct apd_private_data *pdata)
return -ENOMEM;

INIT_LIST_HEAD(&resource_list);
- ret = acpi_dev_get_resources(adev, &resource_list, misc_check_res,
- NULL);
+ ret = acpi_dev_get_memory_resources(adev, &resource_list);
if (ret < 0)
return -ENOENT;

--
2.35.1

2022-08-16 11:49:47

by Heikki Krogerus

[permalink] [raw]
Subject: [PATCH 2/6] ACPI: resource: Filter out the non memory resources in is_memory()

This will generalise the function so it should become
useful in more places.

Signed-off-by: Heikki Krogerus <[email protected]>
---
drivers/acpi/resource.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
index 510cdec375c4d..e644e90d18847 100644
--- a/drivers/acpi/resource.c
+++ b/drivers/acpi/resource.c
@@ -690,6 +690,9 @@ static int is_memory(struct acpi_resource *ares, void *not_used)

memset(&win, 0, sizeof(win));

+ if (acpi_dev_filter_resource_type(ares, IORESOURCE_MEM))
+ return 1;
+
return !(acpi_dev_resource_memory(ares, res)
|| acpi_dev_resource_address_space(ares, &win)
|| acpi_dev_resource_ext_address_space(ares, &win));
--
2.35.1

2022-08-16 11:50:28

by Heikki Krogerus

[permalink] [raw]
Subject: [PATCH 5/6] ACPI: LPSS: Use the helper acpi_dev_get_memory_resources()

It removes the need to check the resource data type
separately.

Signed-off-by: Heikki Krogerus <[email protected]>
---
drivers/acpi/acpi_lpss.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index c4d4d21391d7b..4f6cba8fe8def 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -392,13 +392,6 @@ static const struct acpi_device_id acpi_lpss_device_ids[] = {

#ifdef CONFIG_X86_INTEL_LPSS

-static int is_memory(struct acpi_resource *res, void *not_used)
-{
- struct resource r;
-
- return !acpi_dev_resource_memory(res, &r);
-}
-
/* LPSS main clock device. */
static struct platform_device *lpss_clk_dev;

@@ -659,7 +652,7 @@ static int acpi_lpss_create_device(struct acpi_device *adev,
return -ENOMEM;

INIT_LIST_HEAD(&resource_list);
- ret = acpi_dev_get_resources(adev, &resource_list, is_memory, NULL);
+ ret = acpi_dev_get_memory_resources(adev, &resource_list);
if (ret < 0)
goto err_out;

--
2.35.1

2022-08-18 19:32:24

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 0/6] ACPI: New helper function acpi_dev_get_memory_resources() and a new ACPI ID

On Tue, Aug 16, 2022 at 01:16:23PM +0300, Heikki Krogerus wrote:
> Hi,
>
> The helper function returns all memory resources described for a
> device regardless of the ACPI descriptor type (as long as it's
> memory), but the first patch introduces new ACPI ID for the IOM
> controller on Intel Meteor Lake and also separately modifies the
> driver so that it can get the memory resource from Address Space
> Resource Descriptor.
>
> An alternative would have been to introduce that helper function first
> so we would not need to modify the driver when the new ID is added,
> but then the helper would also need to be applied to the stable kernel
> releases, and that does not feel necessary or appropriate in this
> case, at least not IMO.
>
> So that's why I'm proposing here that we first add the ID, and only
> after that introduce the helper, and only for mainline. That way the
> patch introducing the ID is the only that goes to the stable releases.
>
> If that's okay, and these don't have any other problems, I assume it's
> OK if Rafael takes all of these, including the ID?

I took the id now, for 6.0-final as it seems to be totally independant
of the other commits (otherwise you would not have tagged it for the
stable tree.)

The remainder should probably be resent and send through the acpi tree.

thanks,

greg k-h

2022-08-19 10:15:16

by Heikki Krogerus

[permalink] [raw]
Subject: Re: [PATCH 0/6] ACPI: New helper function acpi_dev_get_memory_resources() and a new ACPI ID

Hi,

On Thu, Aug 18, 2022 at 09:12:46PM +0200, Greg Kroah-Hartman wrote:
> On Tue, Aug 16, 2022 at 01:16:23PM +0300, Heikki Krogerus wrote:
> > Hi,
> >
> > The helper function returns all memory resources described for a
> > device regardless of the ACPI descriptor type (as long as it's
> > memory), but the first patch introduces new ACPI ID for the IOM
> > controller on Intel Meteor Lake and also separately modifies the
> > driver so that it can get the memory resource from Address Space
> > Resource Descriptor.
> >
> > An alternative would have been to introduce that helper function first
> > so we would not need to modify the driver when the new ID is added,
> > but then the helper would also need to be applied to the stable kernel
> > releases, and that does not feel necessary or appropriate in this
> > case, at least not IMO.
> >
> > So that's why I'm proposing here that we first add the ID, and only
> > after that introduce the helper, and only for mainline. That way the
> > patch introducing the ID is the only that goes to the stable releases.
> >
> > If that's okay, and these don't have any other problems, I assume it's
> > OK if Rafael takes all of these, including the ID?
>
> I took the id now, for 6.0-final as it seems to be totally independant
> of the other commits (otherwise you would not have tagged it for the
> stable tree.)
>
> The remainder should probably be resent and send through the acpi tree.

Okay. The last patch depends on that ID patch, so Rafael, you need to
handle that conflict with immutable branch I guess. Or should we just
skip that patch for now?

I think another way to handle this would be that Greg, you take the
whole series.

thanks,

--
heikki

2022-08-19 10:47:54

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 0/6] ACPI: New helper function acpi_dev_get_memory_resources() and a new ACPI ID

On Fri, Aug 19, 2022 at 01:02:30PM +0300, Heikki Krogerus wrote:
> Hi,
>
> On Thu, Aug 18, 2022 at 09:12:46PM +0200, Greg Kroah-Hartman wrote:
> > On Tue, Aug 16, 2022 at 01:16:23PM +0300, Heikki Krogerus wrote:
> > > Hi,
> > >
> > > The helper function returns all memory resources described for a
> > > device regardless of the ACPI descriptor type (as long as it's
> > > memory), but the first patch introduces new ACPI ID for the IOM
> > > controller on Intel Meteor Lake and also separately modifies the
> > > driver so that it can get the memory resource from Address Space
> > > Resource Descriptor.
> > >
> > > An alternative would have been to introduce that helper function first
> > > so we would not need to modify the driver when the new ID is added,
> > > but then the helper would also need to be applied to the stable kernel
> > > releases, and that does not feel necessary or appropriate in this
> > > case, at least not IMO.
> > >
> > > So that's why I'm proposing here that we first add the ID, and only
> > > after that introduce the helper, and only for mainline. That way the
> > > patch introducing the ID is the only that goes to the stable releases.
> > >
> > > If that's okay, and these don't have any other problems, I assume it's
> > > OK if Rafael takes all of these, including the ID?
> >
> > I took the id now, for 6.0-final as it seems to be totally independant
> > of the other commits (otherwise you would not have tagged it for the
> > stable tree.)
> >
> > The remainder should probably be resent and send through the acpi tree.
>
> Okay. The last patch depends on that ID patch, so Rafael, you need to
> handle that conflict with immutable branch I guess. Or should we just
> skip that patch for now?

You can wait for -rc3 or so which should have that commit in it.

thanks,

greg k-h

2022-08-20 11:33:33

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH 0/6] ACPI: New helper function acpi_dev_get_memory_resources() and a new ACPI ID

On Fri, Aug 19, 2022 at 12:33 PM Greg Kroah-Hartman
<[email protected]> wrote:
>
> On Fri, Aug 19, 2022 at 01:02:30PM +0300, Heikki Krogerus wrote:
> > Hi,
> >
> > On Thu, Aug 18, 2022 at 09:12:46PM +0200, Greg Kroah-Hartman wrote:
> > > On Tue, Aug 16, 2022 at 01:16:23PM +0300, Heikki Krogerus wrote:
> > > > Hi,
> > > >
> > > > The helper function returns all memory resources described for a
> > > > device regardless of the ACPI descriptor type (as long as it's
> > > > memory), but the first patch introduces new ACPI ID for the IOM
> > > > controller on Intel Meteor Lake and also separately modifies the
> > > > driver so that it can get the memory resource from Address Space
> > > > Resource Descriptor.
> > > >
> > > > An alternative would have been to introduce that helper function first
> > > > so we would not need to modify the driver when the new ID is added,
> > > > but then the helper would also need to be applied to the stable kernel
> > > > releases, and that does not feel necessary or appropriate in this
> > > > case, at least not IMO.
> > > >
> > > > So that's why I'm proposing here that we first add the ID, and only
> > > > after that introduce the helper, and only for mainline. That way the
> > > > patch introducing the ID is the only that goes to the stable releases.
> > > >
> > > > If that's okay, and these don't have any other problems, I assume it's
> > > > OK if Rafael takes all of these, including the ID?
> > >
> > > I took the id now, for 6.0-final as it seems to be totally independant
> > > of the other commits (otherwise you would not have tagged it for the
> > > stable tree.)
> > >
> > > The remainder should probably be resent and send through the acpi tree.
> >
> > Okay. The last patch depends on that ID patch, so Rafael, you need to
> > handle that conflict with immutable branch I guess. Or should we just
> > skip that patch for now?
>
> You can wait for -rc3 or so which should have that commit in it.

I'll apply the series on top of -rc3.

Cheers!