2022-09-08 13:33:25

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v2 0/8] ACPI: unify _UID handling as integer

This series is about unification on how we handle ACPI _UID when
it's known to be an integer-in-the-string.

The idea of merging either all via ACPI tree, or taking ACPI stuff
for the v6.1 while the rest may be picked up later on by respective
maintainers separately (currently all depends on Wolfram, other
patches have got the tags from the maintainers).

Partially compile-tested (x86-64).

Changelog v2:
- rebased pxa2xx patch to be applied against current Linux kernel code
- fixed uninitialized variable adev in use (mlxbf)
- dropped unneeded temporary variable adev (qcom_l2_pmu)
- changed type for ret in patch 8 (Hans)
- swapped conditions to check ret == 0 first (Ard)
- added tags (Mark, Ard, Hans)

Andy Shevchenko (8):
ACPI: utils: Add acpi_dev_uid_to_integer() helper to get _UID as
integer
ACPI: LPSS: Refactor _UID handling to use acpi_dev_uid_to_integer()
ACPI: x86: Refactor _UID handling to use acpi_dev_uid_to_integer()
i2c: amd-mp2-plat: Refactor _UID handling to use
acpi_dev_uid_to_integer()
i2c: mlxbf: Refactor _UID handling to use acpi_dev_uid_to_integer()
perf: qcom_l2_pmu: Refactor _UID handling to use
acpi_dev_uid_to_integer()
spi: pxa2xx: Refactor _UID handling to use acpi_dev_uid_to_integer()
efi/dev-path-parser: Refactor _UID handling to use
acpi_dev_uid_to_integer()

drivers/acpi/acpi_lpss.c | 15 ++++++-----
drivers/acpi/utils.c | 24 ++++++++++++++++++
drivers/acpi/x86/utils.c | 14 ++++++++---
drivers/firmware/efi/dev-path-parser.c | 10 +++++---
drivers/i2c/busses/i2c-amd-mp2-plat.c | 27 +++++++-------------
drivers/i2c/busses/i2c-mlxbf.c | 20 +++++----------
drivers/perf/qcom_l2_pmu.c | 8 +++---
drivers/spi/spi-pxa2xx.c | 35 +++++++-------------------
include/acpi/acpi_bus.h | 1 +
include/linux/acpi.h | 5 ++++
10 files changed, 81 insertions(+), 78 deletions(-)

--
2.35.1


2022-09-08 13:33:46

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v2 1/8] ACPI: utils: Add acpi_dev_uid_to_integer() helper to get _UID as integer

Some users interpret _UID only as integer and for them it's easier to
have an integer representation of _UID. Add respective helper for that.

Signed-off-by: Andy Shevchenko <[email protected]>
Reviewed-by: Hans de Goede <[email protected]>
---
drivers/acpi/utils.c | 24 ++++++++++++++++++++++++
include/acpi/acpi_bus.h | 1 +
include/linux/acpi.h | 5 +++++
3 files changed, 30 insertions(+)

diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 4acd6f7d1395..2ea14648a661 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -793,6 +793,30 @@ bool acpi_dev_hid_uid_match(struct acpi_device *adev,
}
EXPORT_SYMBOL(acpi_dev_hid_uid_match);

+/**
+ * acpi_dev_uid_to_integer - treat ACPI device _UID as integer
+ * @adev: ACPI device to get _UID from
+ * @integer: output buffer for integer
+ *
+ * Considers _UID as integer and converts it to @integer.
+ *
+ * Returns 0 on success, or negative error code otherwise.
+ */
+int acpi_dev_uid_to_integer(struct acpi_device *adev, u64 *integer)
+{
+ const char *uid;
+
+ if (!adev)
+ return -ENODEV;
+
+ uid = acpi_device_uid(adev);
+ if (!uid)
+ return -ENODATA;
+
+ return kstrtou64(uid, 0, integer);
+}
+EXPORT_SYMBOL(acpi_dev_uid_to_integer);
+
/**
* acpi_dev_found - Detect presence of a given ACPI device in the namespace.
* @hid: Hardware ID of the device.
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 42f76f2c2d49..1804d7a70918 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -739,6 +739,7 @@ static inline bool acpi_device_can_poweroff(struct acpi_device *adev)
}

bool acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, const char *uid2);
+int acpi_dev_uid_to_integer(struct acpi_device *adev, u64 *integer);

void acpi_dev_clear_dependencies(struct acpi_device *supplier);
bool acpi_dev_ready_for_enumeration(const struct acpi_device *device);
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index ed4aa395cc49..619b2b1e4fb4 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -799,6 +799,11 @@ acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, const char *u
return false;
}

+static inline int acpi_dev_uid_to_integer(struct acpi_device *adev, u64 *integer)
+{
+ return -ENODEV;
+}
+
static inline struct acpi_device *
acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv)
{
--
2.35.1

2022-09-08 13:33:56

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v2 4/8] i2c: amd-mp2-plat: Refactor _UID handling to use acpi_dev_uid_to_integer()

ACPI utils provide acpi_dev_uid_to_integer() helper to extract _UID as
an integer. Use it instead of custom approach.

Signed-off-by: Andy Shevchenko <[email protected]>
Reviewed-by: Hans de Goede <[email protected]>
---
drivers/i2c/busses/i2c-amd-mp2-plat.c | 27 +++++++++------------------
1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/drivers/i2c/busses/i2c-amd-mp2-plat.c b/drivers/i2c/busses/i2c-amd-mp2-plat.c
index 84b7e6cbc67b..423fe0c8a471 100644
--- a/drivers/i2c/busses/i2c-amd-mp2-plat.c
+++ b/drivers/i2c/busses/i2c-amd-mp2-plat.c
@@ -244,14 +244,18 @@ static const struct i2c_adapter_quirks amd_i2c_dev_quirks = {

static int i2c_amd_probe(struct platform_device *pdev)
{
+ struct device *dev = &pdev->dev;
int ret;
struct amd_i2c_dev *i2c_dev;
- struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
struct amd_mp2_dev *mp2_dev;
- const char *uid;
+ u64 uid;

- if (!adev)
- return -ENODEV;
+ ret = acpi_dev_uid_to_integer(ACPI_COMPANION(dev), &uid);
+ if (ret)
+ return dev_err_probe(dev, ret, "missing UID/bus id!\n");
+ if (uid >= 2)
+ return dev_err_probe(dev, -EINVAL, "incorrect UID/bus id \"%llu\"!\n", uid);
+ dev_dbg(dev, "bus id is %llu\n", uid);

/* The ACPI namespace doesn't contain information about which MP2 PCI
* device an AMDI0011 ACPI device is related to, so assume that there's
@@ -266,6 +270,7 @@ static int i2c_amd_probe(struct platform_device *pdev)
if (!i2c_dev)
return -ENOMEM;

+ i2c_dev->common.bus_id = uid;
i2c_dev->common.mp2_dev = mp2_dev;
i2c_dev->pdev = pdev;
platform_set_drvdata(pdev, i2c_dev);
@@ -276,20 +281,6 @@ static int i2c_amd_probe(struct platform_device *pdev)
i2c_dev->common.resume = &i2c_amd_resume;
#endif

- uid = adev->pnp.unique_id;
- if (!uid) {
- dev_err(&pdev->dev, "missing UID/bus id!\n");
- return -EINVAL;
- } else if (strcmp(uid, "0") == 0) {
- i2c_dev->common.bus_id = 0;
- } else if (strcmp(uid, "1") == 0) {
- i2c_dev->common.bus_id = 1;
- } else {
- dev_err(&pdev->dev, "incorrect UID/bus id \"%s\"!\n", uid);
- return -EINVAL;
- }
- dev_dbg(&pdev->dev, "bus id is %u\n", i2c_dev->common.bus_id);
-
/* Register the adapter */
amd_mp2_pm_runtime_get(mp2_dev);

--
2.35.1

2022-09-08 13:34:03

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v2 6/8] perf: qcom_l2_pmu: Refactor _UID handling to use acpi_dev_uid_to_integer()

ACPI utils provide acpi_dev_uid_to_integer() helper to extract _UID as
an integer. Use it instead of custom approach.

Signed-off-by: Andy Shevchenko <[email protected]>
Reviewed-by: Hans de Goede <[email protected]>
---
drivers/perf/qcom_l2_pmu.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/perf/qcom_l2_pmu.c b/drivers/perf/qcom_l2_pmu.c
index 30234c261b05..ad4a41e1287f 100644
--- a/drivers/perf/qcom_l2_pmu.c
+++ b/drivers/perf/qcom_l2_pmu.c
@@ -840,16 +840,16 @@ static int l2_cache_pmu_probe_cluster(struct device *dev, void *data)
{
struct platform_device *pdev = to_platform_device(dev->parent);
struct platform_device *sdev = to_platform_device(dev);
- struct acpi_device *adev = ACPI_COMPANION(dev);
struct l2cache_pmu *l2cache_pmu = data;
struct cluster_pmu *cluster;
- unsigned long fw_cluster_id;
+ u64 fw_cluster_id;
int err;
int irq;

- if (!adev || kstrtoul(adev->pnp.unique_id, 10, &fw_cluster_id) < 0) {
+ err = acpi_dev_uid_to_integer(ACPI_COMPANION(dev), &fw_cluster_id);
+ if (err) {
dev_err(&pdev->dev, "unable to read ACPI uid\n");
- return -ENODEV;
+ return err;
}

cluster = devm_kzalloc(&pdev->dev, sizeof(*cluster), GFP_KERNEL);
--
2.35.1

2022-09-08 13:34:04

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v2 3/8] ACPI: x86: Refactor _UID handling to use acpi_dev_uid_to_integer()

ACPI utils provide acpi_dev_uid_to_integer() helper to extract _UID as
an integer. Use it instead of custom approach.

Signed-off-by: Andy Shevchenko <[email protected]>
Reviewed-by: Hans de Goede <[email protected]>
---
drivers/acpi/x86/utils.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/x86/utils.c b/drivers/acpi/x86/utils.c
index 664070fc8349..2764b4778ce7 100644
--- a/drivers/acpi/x86/utils.c
+++ b/drivers/acpi/x86/utils.c
@@ -351,11 +351,17 @@ int acpi_quirk_skip_serdev_enumeration(struct device *controller_parent, bool *s
struct acpi_device *adev = ACPI_COMPANION(controller_parent);
const struct dmi_system_id *dmi_id;
long quirks = 0;
+ u64 uid;
+ int ret;

*skip = false;

- /* !dev_is_platform() to not match on PNP enumerated debug UARTs */
- if (!adev || !adev->pnp.unique_id || !dev_is_platform(controller_parent))
+ ret = acpi_dev_uid_to_integer(adev, &uid);
+ if (ret)
+ return 0;
+
+ /* to not match on PNP enumerated debug UARTs */
+ if (!dev_is_platform(controller_parent))
return 0;

dmi_id = dmi_first_match(acpi_quirk_skip_dmi_ids);
@@ -363,10 +369,10 @@ int acpi_quirk_skip_serdev_enumeration(struct device *controller_parent, bool *s
quirks = (unsigned long)dmi_id->driver_data;

if (quirks & ACPI_QUIRK_UART1_TTY_UART2_SKIP) {
- if (!strcmp(adev->pnp.unique_id, "1"))
+ if (uid == 1)
return -ENODEV; /* Create tty cdev instead of serdev */

- if (!strcmp(adev->pnp.unique_id, "2"))
+ if (uid == 2)
*skip = true;
}

--
2.35.1

2022-09-08 13:34:05

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v2 7/8] spi: pxa2xx: Refactor _UID handling to use acpi_dev_uid_to_integer()

ACPI utils provide acpi_dev_uid_to_integer() helper to extract _UID as
an integer. Use it instead of custom approach.

Signed-off-by: Andy Shevchenko <[email protected]>
Reviewed-by: Hans de Goede <[email protected]>
Acked-by: Mark Brown <[email protected]>
---
drivers/spi/spi-pxa2xx.c | 35 +++++++++--------------------------
1 file changed, 9 insertions(+), 26 deletions(-)

diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
index 986ffc4bf1ed..024730dae8eb 100644
--- a/drivers/spi/spi-pxa2xx.c
+++ b/drivers/spi/spi-pxa2xx.c
@@ -1441,31 +1441,6 @@ static const struct of_device_id pxa2xx_spi_of_match[] = {
};
MODULE_DEVICE_TABLE(of, pxa2xx_spi_of_match);

-#ifdef CONFIG_ACPI
-
-static int pxa2xx_spi_get_port_id(struct device *dev)
-{
- struct acpi_device *adev;
- unsigned int devid;
- int port_id = -1;
-
- adev = ACPI_COMPANION(dev);
- if (adev && adev->pnp.unique_id &&
- !kstrtouint(adev->pnp.unique_id, 0, &devid))
- port_id = devid;
- return port_id;
-}
-
-#else /* !CONFIG_ACPI */
-
-static int pxa2xx_spi_get_port_id(struct device *dev)
-{
- return -1;
-}
-
-#endif /* CONFIG_ACPI */
-
-
#ifdef CONFIG_PCI

static bool pxa2xx_spi_idma_filter(struct dma_chan *chan, void *param)
@@ -1479,6 +1454,7 @@ static struct pxa2xx_spi_controller *
pxa2xx_spi_init_pdata(struct platform_device *pdev)
{
struct pxa2xx_spi_controller *pdata;
+ struct device *dev = &pdev->dev;
struct ssp_device *ssp;
struct resource *res;
struct device *parent = pdev->dev.parent;
@@ -1486,6 +1462,8 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev)
const struct pci_device_id *pcidev_id = NULL;
enum pxa_ssp_type type;
const void *match;
+ int status;
+ u64 uid;

if (pcidev)
pcidev_id = pci_match_id(pxa2xx_spi_pci_compound_match, pcidev);
@@ -1529,7 +1507,12 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev)

ssp->type = type;
ssp->dev = &pdev->dev;
- ssp->port_id = pxa2xx_spi_get_port_id(&pdev->dev);
+
+ status = acpi_dev_uid_to_integer(ACPI_COMPANION(dev), &uid);
+ if (status)
+ ssp->port_id = -1;
+ else
+ ssp->port_id = uid;

pdata->is_slave = device_property_read_bool(&pdev->dev, "spi-slave");
pdata->num_chipselect = 1;
--
2.35.1

2022-09-08 13:34:12

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v2 5/8] i2c: mlxbf: Refactor _UID handling to use acpi_dev_uid_to_integer()

ACPI utils provide acpi_dev_uid_to_integer() helper to extract _UID as
an integer. Use it instead of custom approach.

Signed-off-by: Andy Shevchenko <[email protected]>
Reviewed-by: Hans de Goede <[email protected]>
---
drivers/i2c/busses/i2c-mlxbf.c | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mlxbf.c b/drivers/i2c/busses/i2c-mlxbf.c
index 8716032f030a..32235c62f3d2 100644
--- a/drivers/i2c/busses/i2c-mlxbf.c
+++ b/drivers/i2c/busses/i2c-mlxbf.c
@@ -2229,35 +2229,27 @@ MODULE_DEVICE_TABLE(acpi, mlxbf_i2c_acpi_ids);
static int mlxbf_i2c_acpi_probe(struct device *dev, struct mlxbf_i2c_priv *priv)
{
const struct acpi_device_id *aid;
- struct acpi_device *adev;
- unsigned long bus_id = 0;
- const char *uid;
+ u64 bus_id;
int ret;

if (acpi_disabled)
return -ENOENT;

- adev = ACPI_COMPANION(dev);
- if (!adev)
- return -ENXIO;
-
aid = acpi_match_device(mlxbf_i2c_acpi_ids, dev);
if (!aid)
return -ENODEV;

priv->chip = (struct mlxbf_i2c_chip_info *)aid->driver_data;

- uid = acpi_device_uid(adev);
- if (!uid || !(*uid)) {
+ ret = acpi_dev_uid_to_integer(ACPI_COMPANION(dev), &bus_id);
+ if (ret) {
dev_err(dev, "Cannot retrieve UID\n");
- return -ENODEV;
+ return ret;
}

- ret = kstrtoul(uid, 0, &bus_id);
- if (!ret)
- priv->bus = bus_id;
+ priv->bus = bus_id;

- return ret;
+ return 0;
}
#else
static int mlxbf_i2c_acpi_probe(struct device *dev, struct mlxbf_i2c_priv *priv)
--
2.35.1

2022-09-08 13:34:19

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v2 8/8] efi/dev-path-parser: Refactor _UID handling to use acpi_dev_uid_to_integer()

ACPI utils provide acpi_dev_uid_to_integer() helper to extract _UID as
an integer. Use it instead of custom approach.

Signed-off-by: Andy Shevchenko <[email protected]>
Reviewed-by: Ard Biesheuvel <[email protected]>
---
drivers/firmware/efi/dev-path-parser.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/firmware/efi/dev-path-parser.c b/drivers/firmware/efi/dev-path-parser.c
index eb9c65f97841..f80d87c199c3 100644
--- a/drivers/firmware/efi/dev-path-parser.c
+++ b/drivers/firmware/efi/dev-path-parser.c
@@ -15,9 +15,11 @@
static long __init parse_acpi_path(const struct efi_dev_path *node,
struct device *parent, struct device **child)
{
- char hid[ACPI_ID_LEN], uid[11]; /* UINT_MAX + null byte */
struct acpi_device *adev;
struct device *phys_dev;
+ char hid[ACPI_ID_LEN];
+ u64 uid;
+ int ret;

if (node->header.length != 12)
return -EINVAL;
@@ -27,12 +29,12 @@ static long __init parse_acpi_path(const struct efi_dev_path *node,
'A' + ((node->acpi.hid >> 5) & 0x1f) - 1,
'A' + ((node->acpi.hid >> 0) & 0x1f) - 1,
node->acpi.hid >> 16);
- sprintf(uid, "%u", node->acpi.uid);

for_each_acpi_dev_match(adev, hid, NULL, -1) {
- if (adev->pnp.unique_id && !strcmp(adev->pnp.unique_id, uid))
+ ret = acpi_dev_uid_to_integer(adev, &uid);
+ if (ret == 0 && node->acpi.uid == uid)
break;
- if (!adev->pnp.unique_id && node->acpi.uid == 0)
+ if (ret == -ENODATA && node->acpi.uid == 0)
break;
}
if (!adev)
--
2.35.1

2022-09-08 13:54:15

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v2 2/8] ACPI: LPSS: Refactor _UID handling to use acpi_dev_uid_to_integer()

ACPI utils provide acpi_dev_uid_to_integer() helper to extract _UID as
an integer. Use it instead of custom approach.

Signed-off-by: Andy Shevchenko <[email protected]>
Reviewed-by: Hans de Goede <[email protected]>
---
drivers/acpi/acpi_lpss.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index 7a73528aa9c2..f08ffa75f4a7 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -167,10 +167,10 @@ static struct pwm_lookup byt_pwm_lookup[] = {

static void byt_pwm_setup(struct lpss_private_data *pdata)
{
- struct acpi_device *adev = pdata->adev;
+ u64 uid;

/* Only call pwm_add_table for the first PWM controller */
- if (!adev->pnp.unique_id || strcmp(adev->pnp.unique_id, "1"))
+ if (acpi_dev_uid_to_integer(pdata->adev, &uid) || uid != 1)
return;

pwm_add_table(byt_pwm_lookup, ARRAY_SIZE(byt_pwm_lookup));
@@ -180,14 +180,13 @@ static void byt_pwm_setup(struct lpss_private_data *pdata)

static void byt_i2c_setup(struct lpss_private_data *pdata)
{
- const char *uid_str = acpi_device_uid(pdata->adev);
acpi_handle handle = pdata->adev->handle;
unsigned long long shared_host = 0;
acpi_status status;
- long uid = 0;
+ u64 uid;

- /* Expected to always be true, but better safe then sorry */
- if (uid_str && !kstrtol(uid_str, 10, &uid) && uid) {
+ /* Expected to always be successfull, but better safe then sorry */
+ if (!acpi_dev_uid_to_integer(pdata->adev, &uid) && uid) {
/* Detect I2C bus shared with PUNIT and ignore its d3 status */
status = acpi_evaluate_integer(handle, "_SEM", NULL, &shared_host);
if (ACPI_SUCCESS(status) && shared_host)
@@ -211,10 +210,10 @@ static struct pwm_lookup bsw_pwm_lookup[] = {

static void bsw_pwm_setup(struct lpss_private_data *pdata)
{
- struct acpi_device *adev = pdata->adev;
+ u64 uid;

/* Only call pwm_add_table for the first PWM controller */
- if (!adev->pnp.unique_id || strcmp(adev->pnp.unique_id, "1"))
+ if (acpi_dev_uid_to_integer(pdata->adev, &uid) || uid != 1)
return;

pwm_add_table(bsw_pwm_lookup, ARRAY_SIZE(bsw_pwm_lookup));
--
2.35.1

2022-09-08 14:18:40

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v2 0/8] ACPI: unify _UID handling as integer

On Thu, Sep 08, 2022 at 04:29:02PM +0300, Andy Shevchenko wrote:
> This series is about unification on how we handle ACPI _UID when
> it's known to be an integer-in-the-string.
>
> The idea of merging either all via ACPI tree, or taking ACPI stuff
> for the v6.1 while the rest may be picked up later on by respective
> maintainers separately

>(currently all depends on Wolfram, other
> patches have got the tags from the maintainers).

I stand corrected, the perf patch is not tagged yet.

> Partially compile-tested (x86-64).

Forgot to mention that there is a new user of this API is pending:
https://lore.kernel.org/linux-gpio/[email protected]/

--
With Best Regards,
Andy Shevchenko


2022-09-08 14:20:26

by Hans de Goede

[permalink] [raw]
Subject: Re: [PATCH v2 8/8] efi/dev-path-parser: Refactor _UID handling to use acpi_dev_uid_to_integer()

Hi,

On 9/8/22 15:29, Andy Shevchenko wrote:
> ACPI utils provide acpi_dev_uid_to_integer() helper to extract _UID as
> an integer. Use it instead of custom approach.
>
> Signed-off-by: Andy Shevchenko <[email protected]>
> Reviewed-by: Ard Biesheuvel <[email protected]>

Thanks, patch looks good to me:

Reviewed-by: Hans de Goede <[email protected]>

Regards,

Hans


> ---
> drivers/firmware/efi/dev-path-parser.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/firmware/efi/dev-path-parser.c b/drivers/firmware/efi/dev-path-parser.c
> index eb9c65f97841..f80d87c199c3 100644
> --- a/drivers/firmware/efi/dev-path-parser.c
> +++ b/drivers/firmware/efi/dev-path-parser.c
> @@ -15,9 +15,11 @@
> static long __init parse_acpi_path(const struct efi_dev_path *node,
> struct device *parent, struct device **child)
> {
> - char hid[ACPI_ID_LEN], uid[11]; /* UINT_MAX + null byte */
> struct acpi_device *adev;
> struct device *phys_dev;
> + char hid[ACPI_ID_LEN];
> + u64 uid;
> + int ret;
>
> if (node->header.length != 12)
> return -EINVAL;
> @@ -27,12 +29,12 @@ static long __init parse_acpi_path(const struct efi_dev_path *node,
> 'A' + ((node->acpi.hid >> 5) & 0x1f) - 1,
> 'A' + ((node->acpi.hid >> 0) & 0x1f) - 1,
> node->acpi.hid >> 16);
> - sprintf(uid, "%u", node->acpi.uid);
>
> for_each_acpi_dev_match(adev, hid, NULL, -1) {
> - if (adev->pnp.unique_id && !strcmp(adev->pnp.unique_id, uid))
> + ret = acpi_dev_uid_to_integer(adev, &uid);
> + if (ret == 0 && node->acpi.uid == uid)
> break;
> - if (!adev->pnp.unique_id && node->acpi.uid == 0)
> + if (ret == -ENODATA && node->acpi.uid == 0)
> break;
> }
> if (!adev)

2022-09-09 04:44:06

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v2 6/8] perf: qcom_l2_pmu: Refactor _UID handling to use acpi_dev_uid_to_integer()

Hi Andy,

I love your patch! Perhaps something to improve:

[auto build test WARNING on rafael-pm/linux-next]
[also build test WARNING on wsa/i2c/for-next broonie-spi/for-next efi/next linus/master v6.0-rc4 next-20220908]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/ACPI-unify-_UID-handling-as-integer/20220908-213543
base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
config: arm64-allyesconfig (https://download.01.org/0day-ci/archive/20220909/[email protected]/config)
compiler: aarch64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/9441434beecbf7fcd74ca58adbb06cc53c874179
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Andy-Shevchenko/ACPI-unify-_UID-handling-as-integer/20220908-213543
git checkout 9441434beecbf7fcd74ca58adbb06cc53c874179
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/perf/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

In file included from include/linux/device.h:15,
from include/linux/acpi.h:15,
from drivers/perf/qcom_l2_pmu.c:4:
drivers/perf/qcom_l2_pmu.c: In function 'l2_cache_pmu_probe_cluster':
>> drivers/perf/qcom_l2_pmu.c:882:17: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'u64' {aka 'long long unsigned int'} [-Wformat=]
882 | "Registered L2 cache PMU cluster %ld\n", fw_cluster_id);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:110:30: note: in definition of macro 'dev_printk_index_wrap'
110 | _p_func(dev, fmt, ##__VA_ARGS__); \
| ^~~
include/linux/dev_printk.h:150:58: note: in expansion of macro 'dev_fmt'
150 | dev_printk_index_wrap(_dev_info, KERN_INFO, dev, dev_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~
drivers/perf/qcom_l2_pmu.c:881:9: note: in expansion of macro 'dev_info'
881 | dev_info(&pdev->dev,
| ^~~~~~~~
drivers/perf/qcom_l2_pmu.c:882:52: note: format string is defined here
882 | "Registered L2 cache PMU cluster %ld\n", fw_cluster_id);
| ~~^
| |
| long int
| %lld


vim +882 drivers/perf/qcom_l2_pmu.c

21bdbb7102edea Neil Leeder 2017-02-07 838
21bdbb7102edea Neil Leeder 2017-02-07 839 static int l2_cache_pmu_probe_cluster(struct device *dev, void *data)
21bdbb7102edea Neil Leeder 2017-02-07 840 {
21bdbb7102edea Neil Leeder 2017-02-07 841 struct platform_device *pdev = to_platform_device(dev->parent);
21bdbb7102edea Neil Leeder 2017-02-07 842 struct platform_device *sdev = to_platform_device(dev);
21bdbb7102edea Neil Leeder 2017-02-07 843 struct l2cache_pmu *l2cache_pmu = data;
21bdbb7102edea Neil Leeder 2017-02-07 844 struct cluster_pmu *cluster;
9441434beecbf7 Andy Shevchenko 2022-09-08 845 u64 fw_cluster_id;
21bdbb7102edea Neil Leeder 2017-02-07 846 int err;
21bdbb7102edea Neil Leeder 2017-02-07 847 int irq;
21bdbb7102edea Neil Leeder 2017-02-07 848
9441434beecbf7 Andy Shevchenko 2022-09-08 849 err = acpi_dev_uid_to_integer(ACPI_COMPANION(dev), &fw_cluster_id);
9441434beecbf7 Andy Shevchenko 2022-09-08 850 if (err) {
21bdbb7102edea Neil Leeder 2017-02-07 851 dev_err(&pdev->dev, "unable to read ACPI uid\n");
9441434beecbf7 Andy Shevchenko 2022-09-08 852 return err;
21bdbb7102edea Neil Leeder 2017-02-07 853 }
21bdbb7102edea Neil Leeder 2017-02-07 854
21bdbb7102edea Neil Leeder 2017-02-07 855 cluster = devm_kzalloc(&pdev->dev, sizeof(*cluster), GFP_KERNEL);
21bdbb7102edea Neil Leeder 2017-02-07 856 if (!cluster)
21bdbb7102edea Neil Leeder 2017-02-07 857 return -ENOMEM;
21bdbb7102edea Neil Leeder 2017-02-07 858
21bdbb7102edea Neil Leeder 2017-02-07 859 INIT_LIST_HEAD(&cluster->next);
21bdbb7102edea Neil Leeder 2017-02-07 860 list_add(&cluster->next, &l2cache_pmu->clusters);
21bdbb7102edea Neil Leeder 2017-02-07 861 cluster->cluster_id = fw_cluster_id;
21bdbb7102edea Neil Leeder 2017-02-07 862
21bdbb7102edea Neil Leeder 2017-02-07 863 irq = platform_get_irq(sdev, 0);
228f855fb57ae2 Stephen Boyd 2019-07-30 864 if (irq < 0)
21bdbb7102edea Neil Leeder 2017-02-07 865 return irq;
21bdbb7102edea Neil Leeder 2017-02-07 866 cluster->irq = irq;
21bdbb7102edea Neil Leeder 2017-02-07 867
21bdbb7102edea Neil Leeder 2017-02-07 868 cluster->l2cache_pmu = l2cache_pmu;
21bdbb7102edea Neil Leeder 2017-02-07 869 cluster->on_cpu = -1;
21bdbb7102edea Neil Leeder 2017-02-07 870
21bdbb7102edea Neil Leeder 2017-02-07 871 err = devm_request_irq(&pdev->dev, irq, l2_cache_handle_irq,
0d0f144a8f5f98 Tian Tao 2021-06-02 872 IRQF_NOBALANCING | IRQF_NO_THREAD |
0d0f144a8f5f98 Tian Tao 2021-06-02 873 IRQF_NO_AUTOEN,
21bdbb7102edea Neil Leeder 2017-02-07 874 "l2-cache-pmu", cluster);
21bdbb7102edea Neil Leeder 2017-02-07 875 if (err) {
21bdbb7102edea Neil Leeder 2017-02-07 876 dev_err(&pdev->dev,
21bdbb7102edea Neil Leeder 2017-02-07 877 "Unable to request IRQ%d for L2 PMU counters\n", irq);
21bdbb7102edea Neil Leeder 2017-02-07 878 return err;
21bdbb7102edea Neil Leeder 2017-02-07 879 }
21bdbb7102edea Neil Leeder 2017-02-07 880
21bdbb7102edea Neil Leeder 2017-02-07 881 dev_info(&pdev->dev,
21bdbb7102edea Neil Leeder 2017-02-07 @882 "Registered L2 cache PMU cluster %ld\n", fw_cluster_id);
21bdbb7102edea Neil Leeder 2017-02-07 883
21bdbb7102edea Neil Leeder 2017-02-07 884 spin_lock_init(&cluster->pmu_lock);
21bdbb7102edea Neil Leeder 2017-02-07 885
21bdbb7102edea Neil Leeder 2017-02-07 886 l2cache_pmu->num_pmus++;
21bdbb7102edea Neil Leeder 2017-02-07 887
21bdbb7102edea Neil Leeder 2017-02-07 888 return 0;
21bdbb7102edea Neil Leeder 2017-02-07 889 }
21bdbb7102edea Neil Leeder 2017-02-07 890

--
0-DAY CI Kernel Test Service
https://01.org/lkp

2022-09-09 08:54:34

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v2 6/8] perf: qcom_l2_pmu: Refactor _UID handling to use acpi_dev_uid_to_integer()

On Fri, Sep 09, 2022 at 12:40:36PM +0800, kernel test robot wrote:
> Hi Andy,
>
> I love your patch! Perhaps something to improve:

Indeed.

> All warnings (new ones prefixed by >>):
>
> In file included from include/linux/device.h:15,
> from include/linux/acpi.h:15,
> from drivers/perf/qcom_l2_pmu.c:4:
> drivers/perf/qcom_l2_pmu.c: In function 'l2_cache_pmu_probe_cluster':
> >> drivers/perf/qcom_l2_pmu.c:882:17: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'u64' {aka 'long long unsigned int'} [-Wformat=]

Fixed locally.

--
With Best Regards,
Andy Shevchenko


2022-09-10 16:43:43

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH v2 0/8] ACPI: unify _UID handling as integer

On Thu, Sep 8, 2022 at 3:38 PM Andy Shevchenko
<[email protected]> wrote:
>
> On Thu, Sep 08, 2022 at 04:29:02PM +0300, Andy Shevchenko wrote:
> > This series is about unification on how we handle ACPI _UID when
> > it's known to be an integer-in-the-string.
> >
> > The idea of merging either all via ACPI tree, or taking ACPI stuff
> > for the v6.1 while the rest may be picked up later on by respective
> > maintainers separately
>
> >(currently all depends on Wolfram, other
> > patches have got the tags from the maintainers).
>
> I stand corrected, the perf patch is not tagged yet.
>
> > Partially compile-tested (x86-64).

Tentatively applied as 6.1 material.

If there are updates, we'll make changes as they go.

Thanks!

2022-09-12 10:51:30

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v2 0/8] ACPI: unify _UID handling as integer

On Sat, Sep 10, 2022 at 06:32:10PM +0200, Rafael J. Wysocki wrote:
> On Thu, Sep 8, 2022 at 3:38 PM Andy Shevchenko
> <[email protected]> wrote:

...

> Tentatively applied as 6.1 material.

Thanks!

> If there are updates, we'll make changes as they go.

There is one at least to fix a warning in the perf patch. Should I resend
a fixed patch, just a fix, or entire series with a fixed patch?


--
With Best Regards,
Andy Shevchenko


2022-09-12 21:10:35

by Wolfram Sang

[permalink] [raw]
Subject: Re: [PATCH v2 4/8] i2c: amd-mp2-plat: Refactor _UID handling to use acpi_dev_uid_to_integer()

On Thu, Sep 08, 2022 at 04:29:06PM +0300, Andy Shevchenko wrote:
> ACPI utils provide acpi_dev_uid_to_integer() helper to extract _UID as
> an integer. Use it instead of custom approach.
>
> Signed-off-by: Andy Shevchenko <[email protected]>
> Reviewed-by: Hans de Goede <[email protected]>

Acked-by: Wolfram Sang <[email protected]>


Attachments:
(No filename) (361.00 B)
signature.asc (849.00 B)
Download all attachments

2022-09-12 21:30:11

by Wolfram Sang

[permalink] [raw]
Subject: Re: [PATCH v2 5/8] i2c: mlxbf: Refactor _UID handling to use acpi_dev_uid_to_integer()

On Thu, Sep 08, 2022 at 04:29:07PM +0300, Andy Shevchenko wrote:
> ACPI utils provide acpi_dev_uid_to_integer() helper to extract _UID as
> an integer. Use it instead of custom approach.
>
> Signed-off-by: Andy Shevchenko <[email protected]>
> Reviewed-by: Hans de Goede <[email protected]>

Acked-by: Wolfram Sang <[email protected]>


Attachments:
(No filename) (361.00 B)
signature.asc (849.00 B)
Download all attachments

2022-09-13 01:17:37

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v2 7/8] spi: pxa2xx: Refactor _UID handling to use acpi_dev_uid_to_integer()

Hi Andy,

I love your patch! Perhaps something to improve:

[auto build test WARNING on rafael-pm/linux-next]
[also build test WARNING on wsa/i2c/for-next broonie-spi/for-next efi/next linus/master v6.0-rc5 next-20220912]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/ACPI-unify-_UID-handling-as-integer/20220908-213543
base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
config: x86_64-buildonly-randconfig-r006-20220912 (https://download.01.org/0day-ci/archive/20220913/[email protected]/config)
compiler: gcc-11 (Debian 11.3.0-5) 11.3.0
reproduce (this is a W=1 build):
# https://github.com/intel-lab-lkp/linux/commit/ea7999676bc9f75bb4165358cda640b340fe34d0
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Andy-Shevchenko/ACPI-unify-_UID-handling-as-integer/20220908-213543
git checkout ea7999676bc9f75bb4165358cda640b340fe34d0
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/spi/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

drivers/spi/spi-pxa2xx.c: In function 'pxa2xx_spi_init_pdata':
>> drivers/spi/spi-pxa2xx.c:1457:24: warning: unused variable 'dev' [-Wunused-variable]
1457 | struct device *dev = &pdev->dev;
| ^~~


vim +/dev +1457 drivers/spi/spi-pxa2xx.c

1452
1453 static struct pxa2xx_spi_controller *
1454 pxa2xx_spi_init_pdata(struct platform_device *pdev)
1455 {
1456 struct pxa2xx_spi_controller *pdata;
> 1457 struct device *dev = &pdev->dev;
1458 struct ssp_device *ssp;
1459 struct resource *res;
1460 struct device *parent = pdev->dev.parent;
1461 struct pci_dev *pcidev = dev_is_pci(parent) ? to_pci_dev(parent) : NULL;
1462 const struct pci_device_id *pcidev_id = NULL;
1463 enum pxa_ssp_type type;
1464 const void *match;
1465 int status;
1466 u64 uid;
1467
1468 if (pcidev)
1469 pcidev_id = pci_match_id(pxa2xx_spi_pci_compound_match, pcidev);
1470
1471 match = device_get_match_data(&pdev->dev);
1472 if (match)
1473 type = (enum pxa_ssp_type)match;
1474 else if (pcidev_id)
1475 type = (enum pxa_ssp_type)pcidev_id->driver_data;
1476 else
1477 return ERR_PTR(-EINVAL);
1478
1479 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
1480 if (!pdata)
1481 return ERR_PTR(-ENOMEM);
1482
1483 ssp = &pdata->ssp;
1484
1485 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1486 ssp->mmio_base = devm_ioremap_resource(&pdev->dev, res);
1487 if (IS_ERR(ssp->mmio_base))
1488 return ERR_CAST(ssp->mmio_base);
1489
1490 ssp->phys_base = res->start;
1491

--
0-DAY CI Kernel Test Service
https://01.org/lkp

2022-09-13 18:12:31

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v2 0/8] ACPI: unify _UID handling as integer

On Mon, Sep 12, 2022 at 01:39:00PM +0300, Andy Shevchenko wrote:
> On Sat, Sep 10, 2022 at 06:32:10PM +0200, Rafael J. Wysocki wrote:
> > On Thu, Sep 8, 2022 at 3:38 PM Andy Shevchenko
> > <[email protected]> wrote:

...

> > Tentatively applied as 6.1 material.
>
> Thanks!
>
> > If there are updates, we'll make changes as they go.
>
> There is one at least to fix a warning in the perf patch. Should I resend
> a fixed patch, just a fix, or entire series with a fixed patch?

Since LKP found one small issue with SPI patch when CONFIG_ACPI=n, I decided
to send a v3. Please, replace this by a new version in your tree, thanks!

--
With Best Regards,
Andy Shevchenko