From 46a009e48075008d9fd7f9c43dfe7774f76bf498 Mon Sep 17 00:00:00 2001 From: Lino Sanfilippo Date: Thu, 1 Feb 2024 12:36:45 +0100 Subject: [PATCH 1/5] tpm,tpm_tis: Avoid warning splat at shutdown ANBZ: #26352 commit b7ab4bbd0188f3985b821fa09456b11105a8dedf upstream mainline inclusion from mainline-v6.9-rc1 commit b7ab4bbd0188f3985b821fa09456b11105a8dedf category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I9G5IU CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b7ab4bbd0188f3985b821fa09456b11105a8dedf ---------------------------------------------------------------------- If interrupts are not activated the work struct 'free_irq_work' is not initialized. This results in a warning splat at module shutdown. Fix this by always initializing the work regardless of whether interrupts are activated or not. cc: stable@vger.kernel.org Fixes: 481c2d14627d ("tpm,tpm_tis: Disable interrupts after 1000 unhandled IRQs") Reported-by: Jarkko Sakkinen Closes: https://lore.kernel.org/all/CX32RFOMJUQ0.3R4YCL9MDCB96@kernel.org/ Signed-off-by: Lino Sanfilippo Signed-off-by: Jarkko Sakkinen Signed-off-by: lujunhua --- drivers/char/tpm/tpm_tis_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index b3452259d6e0..6dde52c4f1d6 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -779,7 +779,6 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask, int rc; u32 int_status; - rc = devm_request_threaded_irq(chip->dev.parent, irq, NULL, tis_int_handler, IRQF_ONESHOT | flags, dev_name(&chip->dev), chip); @@ -989,6 +988,7 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, priv->phy_ops = phy_ops; priv->locality_count = 0; mutex_init(&priv->locality_count_mutex); + INIT_WORK(&priv->free_irq_work, tpm_tis_free_irq_func); dev_set_drvdata(&chip->dev, priv); -- Gitee From 78062e66a6c4c4ccac77b84a095425ebfb2d192b Mon Sep 17 00:00:00 2001 From: Devyn Liu Date: Mon, 13 May 2024 15:59:01 +0800 Subject: [PATCH 2/5] gpiolib: acpi: Fix failed in acpi_gpiochip_find() by adding parent node match ANBZ: #26352 commit adbc49a5a8c6fcf7be154c2e30213bbf472940da upstream Previous patch modified the standard used by acpi_gpiochip_find() to match device nodes. Using the device node set in gc->gpiodev->d- ev instead of gc->parent. However, there is a situation in gpio-dwapb where the GPIO device driver will set gc->fwnode for each port corresponding to a child node under a GPIO device, so gc->gpiodev->dev will be assigned the value of each child node in gpiochip_add_data(). gpio-dwapb.c: 128,31 static int dwapb_gpio_add_port(struct dwapb_gpio *gpio, struct dwapb_port_property *pp, unsigned int offs); port->gc.fwnode = pp->fwnode; 693,39 static int dwapb_gpio_probe; err = dwapb_gpio_add_port(gpio, &pdata->properties[i], i); When other drivers request GPIO pin resources through the GPIO device node provided by ACPI (corresponding to the parent node), the change of the matching object to gc->gpiodev->dev in acpi_gpiochip_find() only allows finding the value of each port (child node), resulting in a failed request. Reapply the condition of using gc->parent for match in acpi_gpio- chip_find() in the code can compatible with the problem of gpio-dwapb, and will not affect the two cases mentioned in the patch: 1. There is no setting for gc->fwnode. 2. The case that depends on using gc->fwnode for match. Fixes: 5062e4c14b75 ("gpiolib: acpi: use the fwnode in acpi_gpiochip_find()") Fixes: 067dbc1ea5ce ("gpiolib: acpi: Don't use GPIO chip fwnode in acpi_gpiochip_find()") Signed-off-by: Devyn Liu Reviewed-by: Mika Westerberg Tested-by: Benjamin Tissoires Signed-off-by: Andy Shevchenko --- drivers/gpio/gpiolib-acpi.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 44ee319da1b3..266d33d41511 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -95,10 +95,23 @@ static bool acpi_gpio_deferred_req_irqs_done; static int acpi_gpiochip_find(struct gpio_chip *gc, void *data) { - if (!gc->parent) - return false; + /* First check the actual GPIO device */ + if (device_match_acpi_handle(&gc->gpiodev->dev, data)) + return true; - return ACPI_HANDLE(gc->parent) == data; + /* + * When the ACPI device is artificially split to the banks of GPIOs, + * where each of them is represented by a separate GPIO device, + * the firmware node of the physical device may not be shared among + * the banks as they may require different values for the same property, + * e.g., number of GPIOs in a certain bank. In such case the ACPI handle + * of a GPIO device is NULL and can not be used. Hence we have to check + * the parent device to be sure that there is no match before bailing + * out. + */ + if (gc->parent) + return device_match_acpi_handle(gc->parent, data); + return false; } /** -- Gitee From bfe6d47cdffa503d931b4694e204fdd51278addf Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 14 Oct 2021 16:47:54 +0300 Subject: [PATCH 3/5] driver core: Provide device_match_acpi_handle() helper ANBZ: #26352 commit a164ff53cbd34479aeac3366840669b10845ce53 upstream We have a couple of users of this helper, make it available for them. The prototype for the helper is specifically crafted in order to be easily used with bus_find_device() call. That's why its location is in the driver core rather than ACPI. Reviewed-by: Rafael J. Wysocki Signed-off-by: Andy Shevchenko Link: https://lore.kernel.org/r/20211014134756.39092-1-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/base/core.c | 6 ++++++ include/linux/device/bus.h | 1 + 2 files changed, 7 insertions(+) diff --git a/drivers/base/core.c b/drivers/base/core.c index 547d21faff3a..945cd04fc428 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -4388,6 +4388,12 @@ int device_match_acpi_dev(struct device *dev, const void *adev) } EXPORT_SYMBOL(device_match_acpi_dev); +int device_match_acpi_handle(struct device *dev, const void *handle) +{ + return ACPI_HANDLE(dev) == handle; +} +EXPORT_SYMBOL(device_match_acpi_handle); + int device_match_any(struct device *dev, const void *unused) { return 1; diff --git a/include/linux/device/bus.h b/include/linux/device/bus.h index 3e1212b6fb58..0fd1117d1848 100644 --- a/include/linux/device/bus.h +++ b/include/linux/device/bus.h @@ -147,6 +147,7 @@ int device_match_of_node(struct device *dev, const void *np); int device_match_fwnode(struct device *dev, const void *fwnode); int device_match_devt(struct device *dev, const void *pdevt); int device_match_acpi_dev(struct device *dev, const void *adev); +int device_match_acpi_handle(struct device *dev, const void *handle); int device_match_any(struct device *dev, const void *unused); /* iterator helpers for buses */ -- Gitee From 923fc34478f52609895aedc6f2402292654d0faf Mon Sep 17 00:00:00 2001 From: Devyn Liu Date: Tue, 30 Jul 2024 11:20:39 +0800 Subject: [PATCH 4/5] spi: hisi-kunpeng: Add validation for the minimum value of speed_hz ANBZ: #26352 commit c3c4f22b7c814a6ee485ce294065836f8ede30fa upstream The speed specified by the user is used to calculate the clk_div based on the max_speed_hz in hisi_calc_effective_speed. A very low speed value can lead to a clk_div larger than the variable range. Avoid this by setting the min_speed_hz so that such a small speed value is rejected. __spi_validate() in spi.c will return -EINVAL for the specified speed_hz lower than min_speed_hz. Signed-off-by: Devyn Liu Reviewed-by: Jay Fang Link: https://patch.msgid.link/20240730032040.3156393-2-liudingyuan@huawei.com Signed-off-by: Mark Brown --- drivers/spi/spi-hisi-kunpeng.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/spi/spi-hisi-kunpeng.c b/drivers/spi/spi-hisi-kunpeng.c index 54730e93fba4..3591b3b96e84 100644 --- a/drivers/spi/spi-hisi-kunpeng.c +++ b/drivers/spi/spi-hisi-kunpeng.c @@ -495,6 +495,7 @@ static int hisi_spi_probe(struct platform_device *pdev) master->transfer_one = hisi_spi_transfer_one; master->handle_err = hisi_spi_handle_err; master->dev.fwnode = dev->fwnode; + master->min_speed_hz = DIV_ROUND_UP(host->max_speed_hz, CLK_DIV_MAX); hisi_spi_hw_init(hs); -- Gitee From bf27f2c74ce2a7dc81edb6f470fc07a74915bf89 Mon Sep 17 00:00:00 2001 From: Devyn Liu Date: Tue, 30 Jul 2024 11:20:40 +0800 Subject: [PATCH 5/5] spi: hisi-kunpeng: Add verification for the max_frequency provided by the firmware ANBZ: #26352 commit 5127c42c77de18651aa9e8e0a3ced190103b449c upstream If the value of max_speed_hz is 0, it may cause a division by zero error in hisi_calc_effective_speed(). The value of max_speed_hz is provided by firmware. Firmware is generally considered as a trusted domain. However, as division by zero errors can cause system failure, for defense measure, the value of max_speed is validated here. So 0 is regarded as invalid and an error code is returned. Signed-off-by: Devyn Liu Reviewed-by: Jay Fang Link: https://patch.msgid.link/20240730032040.3156393-3-liudingyuan@huawei.com Signed-off-by: Mark Brown spi: hisi-kunpeng: Fixed the wrong debugfs node name in hisi_spi debugfs initialization ANBZ: #26352 spi: hisi-kunpeng: Fixed the wrong debugfs node name in hisi_spi debugfs initialization driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ICOAO3 CVE: NA -------------------------------- in hisi_spi_debugfs_init, spi controller pointer is calculated by container_of macro, and the member is hs->dev. But the host pointer cannot be calculated offset directly by this, because hs->dev points to the device in platform device(pdev->dev), and the host->dev points to the pdev->dev.parent. In this patch, this issues is fixed by getting the controller data from pdev->dev.driver_data directly, driver_data points to the spi controller data in the probe stage. Fixes: 20af5164c223 ("spi: hisi-kunpeng: switch to use modern name") Signed-off-by: lujunhua Signed-off-by: Devyn Liu spi: hisi-kunpeng: remove init_work function to fix compilation errors ANBZ: #26352 spi: hisi-kunpeng: remove init_work function to fix compilation errors --- "\\" | 34 +++++++++++++++++++++++++++++++++ drivers/char/tpm/tpm_tis_core.c | 1 - drivers/spi/spi-hisi-kunpeng.c | 7 +++++-- 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 "\\" diff --git "a/\\" "b/\\" new file mode 100644 index 000000000000..eab7889a1722 --- /dev/null +++ "b/\\" @@ -0,0 +1,34 @@ +hwmon: Fix the missing of 'average' word in hwmon_power_attr_templates + +ANBZ: #26346 + +commit 232427772fc123942d110c18269cfbdf40edae18 upstream + +The string "power%d_interval_max" and "power%d_interval_min" in the +hwmon_power_attr_templates[] are corresponding to the sysfs interface name +of hwmon_power_average_interval_max and hwmon_power_average_interval_min. +But the 'average' word is missing in two strings. Fortunately, there is +no driver to use it yet. + +Signed-off-by: Huisong Li +Link: https://lore.kernel.org/r/20250304074640.2770353-1-lihuisong@huawei.com +Signed-off-by: Guenter Roeck + +# Please enter the commit message for your changes. Lines starting +# with '#' will be ignored, and an empty message aborts the commit. +# +# Author: Huisong Li +# Date: Tue Mar 4 15:46:40 2025 +0800 +# +# interactive rebase in progress; onto f8bce50aa552 +# Last commands done (6 commands done): +# reword 81ff9f4824e9 hwmon: (acpi_power_meter) Fix fail to load module on platform without _PMD method +# reword 2bd77b23ae17 hwmon: Fix the missing of 'average' word in hwmon_power_attr_templates +# Next commands to do (8 remaining commands): +# reword b2fde4dbeef9 hwmon: (acpi_power_meter) Ensure IPMI space handler is ready on Dell systems +# reword b2320c49d82a ACPI: PCC: Add PCC shared memory region command and status bitfields +# You are currently editing a commit while rebasing branch 'devel-5.10-power-meter2' on 'f8bce50aa552'. +# +# Changes to be committed: +# modified: drivers/hwmon/hwmon.c +# diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index 6dde52c4f1d6..ee253f421b23 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -988,7 +988,6 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, priv->phy_ops = phy_ops; priv->locality_count = 0; mutex_init(&priv->locality_count_mutex); - INIT_WORK(&priv->free_irq_work, tpm_tis_free_irq_func); dev_set_drvdata(&chip->dev, priv); diff --git a/drivers/spi/spi-hisi-kunpeng.c b/drivers/spi/spi-hisi-kunpeng.c index 3591b3b96e84..8d75e57fc1d5 100644 --- a/drivers/spi/spi-hisi-kunpeng.c +++ b/drivers/spi/spi-hisi-kunpeng.c @@ -164,8 +164,8 @@ static int hisi_spi_debugfs_init(struct hisi_spi *hs) struct spi_controller *master; - master = container_of(hs->dev, struct spi_controller, dev); - snprintf(name, 32, "hisi_spi%d", master->bus_num); + master = hs->dev->driver_data; + snprintf(name, 32, "hisi_spi%d", host->bus_num); hs->debugfs = debugfs_create_dir(name, NULL); if (!hs->debugfs) return -ENOMEM; @@ -481,6 +481,9 @@ static int hisi_spi_probe(struct platform_device *pdev) return -EINVAL; } + if (host->max_speed_hz == 0) + return dev_err_probe(dev, -EINVAL, "spi-max-frequency can't be 0\n"); + ret = device_property_read_u16(dev, "num-cs", &master->num_chipselect); if (ret) -- Gitee