LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 4.14 01/10] power: supply: ab8500: Fix external_power_changed race
@ 2023-05-31 13:45 Sasha Levin
  2023-05-31 13:45 ` [PATCH AUTOSEL 4.14 02/10] power: supply: bq27xxx: Use mod_delayed_work() instead of cancel() + schedule() Sasha Levin
                   ` (8 more replies)
  0 siblings, 9 replies; 14+ messages in thread
From: Sasha Levin @ 2023-05-31 13:45 UTC (permalink / raw
  To: linux-kernel, stable
  Cc: Hans de Goede, Linus Walleij, Sebastian Reichel, Sasha Levin, sre,
	linux-pm

From: Hans de Goede <hdegoede@redhat.com>

[ Upstream commit a5299ce4e96f3e8930e9c051b28d8093ada87b08 ]

ab8500_btemp_external_power_changed() dereferences di->btemp_psy,
which gets sets in ab8500_btemp_probe() like this:

        di->btemp_psy = devm_power_supply_register(dev, &ab8500_btemp_desc,
                                                   &psy_cfg);

As soon as devm_power_supply_register() has called device_add()
the external_power_changed callback can get called. So there is a window
where ab8500_btemp_external_power_changed() may get called while
di->btemp_psy has not been set yet leading to a NULL pointer dereference.

Fixing this is easy. The external_power_changed callback gets passed
the power_supply which will eventually get stored in di->btemp_psy,
so ab8500_btemp_external_power_changed() can simply directly use
the passed in psy argument which is always valid.

And the same applies to ab8500_fg_external_power_changed().

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/power/supply/ab8500_btemp.c | 6 ++----
 drivers/power/supply/ab8500_fg.c    | 6 ++----
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/power/supply/ab8500_btemp.c b/drivers/power/supply/ab8500_btemp.c
index 97423a04fc0f0..c58644a3345ce 100644
--- a/drivers/power/supply/ab8500_btemp.c
+++ b/drivers/power/supply/ab8500_btemp.c
@@ -976,10 +976,8 @@ static int ab8500_btemp_get_ext_psy_data(struct device *dev, void *data)
  */
 static void ab8500_btemp_external_power_changed(struct power_supply *psy)
 {
-	struct ab8500_btemp *di = power_supply_get_drvdata(psy);
-
-	class_for_each_device(power_supply_class, NULL,
-		di->btemp_psy, ab8500_btemp_get_ext_psy_data);
+	class_for_each_device(power_supply_class, NULL, psy,
+			      ab8500_btemp_get_ext_psy_data);
 }
 
 /* ab8500 btemp driver interrupts and their respective isr */
diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c
index b00844103a07a..f99e248f6aed3 100644
--- a/drivers/power/supply/ab8500_fg.c
+++ b/drivers/power/supply/ab8500_fg.c
@@ -2384,10 +2384,8 @@ static int ab8500_fg_init_hw_registers(struct ab8500_fg *di)
  */
 static void ab8500_fg_external_power_changed(struct power_supply *psy)
 {
-	struct ab8500_fg *di = power_supply_get_drvdata(psy);
-
-	class_for_each_device(power_supply_class, NULL,
-		di->fg_psy, ab8500_fg_get_ext_psy_data);
+	class_for_each_device(power_supply_class, NULL, psy,
+			      ab8500_fg_get_ext_psy_data);
 }
 
 /**
-- 
2.39.2


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

* [PATCH AUTOSEL 4.14 02/10] power: supply: bq27xxx: Use mod_delayed_work() instead of cancel() + schedule()
  2023-05-31 13:45 [PATCH AUTOSEL 4.14 01/10] power: supply: ab8500: Fix external_power_changed race Sasha Levin
@ 2023-05-31 13:45 ` Sasha Levin
  2023-06-16 19:28   ` Pavel Machek
  2023-05-31 13:45 ` [PATCH AUTOSEL 4.14 03/10] ARM: dts: vexpress: add missing cache properties Sasha Levin
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 14+ messages in thread
From: Sasha Levin @ 2023-05-31 13:45 UTC (permalink / raw
  To: linux-kernel, stable
  Cc: Hans de Goede, Sebastian Reichel, Sasha Levin, sre, linux-pm

From: Hans de Goede <hdegoede@redhat.com>

[ Upstream commit 59dddea9879713423c7b2ade43c423bb71e0d216 ]

Use mod_delayed_work() instead of separate cancel_delayed_work_sync() +
schedule_delayed_work() calls.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/power/supply/bq27xxx_battery.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
index 3e8466064bb2c..a4c21eeb780b8 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -832,10 +832,8 @@ static int poll_interval_param_set(const char *val, const struct kernel_param *k
 		return ret;
 
 	mutex_lock(&bq27xxx_list_lock);
-	list_for_each_entry(di, &bq27xxx_battery_devices, list) {
-		cancel_delayed_work_sync(&di->work);
-		schedule_delayed_work(&di->work, 0);
-	}
+	list_for_each_entry(di, &bq27xxx_battery_devices, list)
+		mod_delayed_work(system_wq, &di->work, 0);
 	mutex_unlock(&bq27xxx_list_lock);
 
 	return ret;
-- 
2.39.2


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

* [PATCH AUTOSEL 4.14 03/10] ARM: dts: vexpress: add missing cache properties
  2023-05-31 13:45 [PATCH AUTOSEL 4.14 01/10] power: supply: ab8500: Fix external_power_changed race Sasha Levin
  2023-05-31 13:45 ` [PATCH AUTOSEL 4.14 02/10] power: supply: bq27xxx: Use mod_delayed_work() instead of cancel() + schedule() Sasha Levin
@ 2023-05-31 13:45 ` Sasha Levin
  2023-05-31 13:46 ` [PATCH AUTOSEL 4.14 04/10] power: supply: Ratelimit no data debug output Sasha Levin
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Sasha Levin @ 2023-05-31 13:45 UTC (permalink / raw
  To: linux-kernel, stable
  Cc: Krzysztof Kozlowski, Sudeep Holla, Sasha Levin, liviu.dudau,
	lpieralisi, robh+dt, krzysztof.kozlowski+dt, conor+dt,
	linux-arm-kernel, devicetree

From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

[ Upstream commit 328acc5657c6197753238d7ce0a6924ead829347 ]

As all level 2 and level 3 caches are unified, add required
cache-unified property to fix warnings like:

  vexpress-v2p-ca5s.dtb: cache-controller@2c0f0000: 'cache-unified' is a required property

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20230423150837.118466-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/arm/boot/dts/vexpress-v2p-ca5s.dts | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/vexpress-v2p-ca5s.dts b/arch/arm/boot/dts/vexpress-v2p-ca5s.dts
index 32f1906ffecfe..994edbc615cb0 100644
--- a/arch/arm/boot/dts/vexpress-v2p-ca5s.dts
+++ b/arch/arm/boot/dts/vexpress-v2p-ca5s.dts
@@ -117,6 +117,7 @@ L2: cache-controller@2c0f0000 {
 		reg = <0x2c0f0000 0x1000>;
 		interrupts = <0 84 4>;
 		cache-level = <2>;
+		cache-unified;
 	};
 
 	pmu {
-- 
2.39.2


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

* [PATCH AUTOSEL 4.14 04/10] power: supply: Ratelimit no data debug output
  2023-05-31 13:45 [PATCH AUTOSEL 4.14 01/10] power: supply: ab8500: Fix external_power_changed race Sasha Levin
  2023-05-31 13:45 ` [PATCH AUTOSEL 4.14 02/10] power: supply: bq27xxx: Use mod_delayed_work() instead of cancel() + schedule() Sasha Levin
  2023-05-31 13:45 ` [PATCH AUTOSEL 4.14 03/10] ARM: dts: vexpress: add missing cache properties Sasha Levin
@ 2023-05-31 13:46 ` Sasha Levin
  2023-05-31 13:46 ` [PATCH AUTOSEL 4.14 05/10] regulator: Fix error checking for debugfs_create_dir Sasha Levin
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Sasha Levin @ 2023-05-31 13:46 UTC (permalink / raw
  To: linux-kernel, stable
  Cc: Marek Vasut, Hans de Goede, Sebastian Reichel, Sasha Levin, sre,
	linux-pm

From: Marek Vasut <marex@denx.de>

[ Upstream commit 155c45a25679f571c2ae57d10db843a9dfc63430 ]

Reduce the amount of output this dev_dbg() statement emits into logs,
otherwise if system software polls the sysfs entry for data and keeps
getting -ENODATA, it could end up filling the logs up.

This does in fact make systemd journald choke, since during boot the
sysfs power supply entries are polled and if journald starts at the
same time, the journal is just being repeatedly filled up, and the
system stops on trying to start journald without booting any further.

Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/power/supply/power_supply_sysfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
index 2ccaf4ff4be47..2cb8a31e9dac0 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -88,7 +88,8 @@ static ssize_t power_supply_show_property(struct device *dev,
 
 		if (ret < 0) {
 			if (ret == -ENODATA)
-				dev_dbg(dev, "driver has no data for `%s' property\n",
+				dev_dbg_ratelimited(dev,
+					"driver has no data for `%s' property\n",
 					attr->attr.name);
 			else if (ret != -ENODEV && ret != -EAGAIN)
 				dev_err_ratelimited(dev,
-- 
2.39.2


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

* [PATCH AUTOSEL 4.14 05/10] regulator: Fix error checking for debugfs_create_dir
  2023-05-31 13:45 [PATCH AUTOSEL 4.14 01/10] power: supply: ab8500: Fix external_power_changed race Sasha Levin
                   ` (2 preceding siblings ...)
  2023-05-31 13:46 ` [PATCH AUTOSEL 4.14 04/10] power: supply: Ratelimit no data debug output Sasha Levin
@ 2023-05-31 13:46 ` Sasha Levin
  2023-05-31 13:46 ` [PATCH AUTOSEL 4.14 06/10] power: supply: Fix logic checking if system is running from battery Sasha Levin
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Sasha Levin @ 2023-05-31 13:46 UTC (permalink / raw
  To: linux-kernel, stable; +Cc: Osama Muhammad, Sasha Levin, lgirdwood, broonie

From: Osama Muhammad <osmtendev@gmail.com>

[ Upstream commit 2bf1c45be3b8f3a3f898d0756c1282f09719debd ]

This patch fixes the error checking in core.c in debugfs_create_dir.
The correct way to check if an error occurred is 'IS_ERR' inline function.

Signed-off-by: Osama Muhammad <osmtendev@gmail.com
Suggested-by: Ivan Orlov <ivan.orlov0322@gmail.com
Link: https://lore.kernel.org/r/20230515172938.13338-1-osmtendev@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/regulator/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 871d657a161f0..7898a54a324c4 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -3955,7 +3955,7 @@ static void rdev_init_debugfs(struct regulator_dev *rdev)
 	}
 
 	rdev->debugfs = debugfs_create_dir(rname, debugfs_root);
-	if (!rdev->debugfs) {
+	if (IS_ERR(rdev->debugfs)) {
 		rdev_warn(rdev, "Failed to create debugfs directory\n");
 		return;
 	}
@@ -4513,7 +4513,7 @@ static int __init regulator_init(void)
 	ret = class_register(&regulator_class);
 
 	debugfs_root = debugfs_create_dir("regulator", NULL);
-	if (!debugfs_root)
+	if (IS_ERR(debugfs_root))
 		pr_warn("regulator: Failed to create debugfs directory\n");
 
 	debugfs_create_file("supply_map", 0444, debugfs_root, NULL,
-- 
2.39.2


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

* [PATCH AUTOSEL 4.14 06/10] power: supply: Fix logic checking if system is running from battery
  2023-05-31 13:45 [PATCH AUTOSEL 4.14 01/10] power: supply: ab8500: Fix external_power_changed race Sasha Levin
                   ` (3 preceding siblings ...)
  2023-05-31 13:46 ` [PATCH AUTOSEL 4.14 05/10] regulator: Fix error checking for debugfs_create_dir Sasha Levin
@ 2023-05-31 13:46 ` Sasha Levin
  2023-05-31 13:46 ` [PATCH AUTOSEL 4.14 07/10] MIPS: Restore Au1300 support Sasha Levin
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Sasha Levin @ 2023-05-31 13:46 UTC (permalink / raw
  To: linux-kernel, stable
  Cc: Mario Limonciello, Evan Quan, Lijo Lazar, Sebastian Reichel,
	Sasha Levin, sre, linux-pm

From: Mario Limonciello <mario.limonciello@amd.com>

[ Upstream commit 95339f40a8b652b5b1773def31e63fc53c26378a ]

The logic used for power_supply_is_system_supplied() counts all power
supplies and assumes that the system is running from AC if there is
either a non-battery power-supply reporting to be online or if no
power-supplies exist at all.

The second rule is for desktop systems, that don't have any
battery/charger devices. These systems will incorrectly report to be
powered from battery once a device scope power-supply is registered
(e.g. a HID device), since these power-supplies increase the counter.

Apart from HID devices, recent dGPUs provide UCSI power supplies on a
desktop systems. The dGPU by default doesn't have anything plugged in so
it's 'offline'. This makes power_supply_is_system_supplied() return 0
with a count of 1 meaning all drivers that use this get a wrong judgement.

To fix this case adjust the logic to also examine the scope of the power
supply. If the power supply is deemed a device power supply, then don't
count it.

Cc: Evan Quan <Evan.Quan@amd.com>
Suggested-by: Lijo Lazar <Lijo.Lazar@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/power/supply/power_supply_core.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
index 409ecff1a51a7..67766b500325f 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -349,6 +349,10 @@ static int __power_supply_is_system_supplied(struct device *dev, void *data)
 	struct power_supply *psy = dev_get_drvdata(dev);
 	unsigned int *count = data;
 
+	if (!psy->desc->get_property(psy, POWER_SUPPLY_PROP_SCOPE, &ret))
+		if (ret.intval == POWER_SUPPLY_SCOPE_DEVICE)
+			return 0;
+
 	(*count)++;
 	if (psy->desc->type != POWER_SUPPLY_TYPE_BATTERY)
 		if (!psy->desc->get_property(psy, POWER_SUPPLY_PROP_ONLINE,
@@ -367,8 +371,8 @@ int power_supply_is_system_supplied(void)
 				      __power_supply_is_system_supplied);
 
 	/*
-	 * If no power class device was found at all, most probably we are
-	 * running on a desktop system, so assume we are on mains power.
+	 * If no system scope power class device was found at all, most probably we
+	 * are running on a desktop system, so assume we are on mains power.
 	 */
 	if (count == 0)
 		return 1;
-- 
2.39.2


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

* [PATCH AUTOSEL 4.14 07/10] MIPS: Restore Au1300 support
  2023-05-31 13:45 [PATCH AUTOSEL 4.14 01/10] power: supply: ab8500: Fix external_power_changed race Sasha Levin
                   ` (4 preceding siblings ...)
  2023-05-31 13:46 ` [PATCH AUTOSEL 4.14 06/10] power: supply: Fix logic checking if system is running from battery Sasha Levin
@ 2023-05-31 13:46 ` Sasha Levin
  2023-05-31 13:46 ` [PATCH AUTOSEL 4.14 08/10] MIPS: Alchemy: fix dbdma2 Sasha Levin
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Sasha Levin @ 2023-05-31 13:46 UTC (permalink / raw
  To: linux-kernel, stable
  Cc: Manuel Lauss, Thomas Bogendoerfer, Sasha Levin, jiaxun.yang,
	linux-mips

From: Manuel Lauss <manuel.lauss@gmail.com>

[ Upstream commit f2041708dee30a3425f680265c337acd28293782 ]

The Au1300, at least the one I have to test, uses the NetLogic vendor
ID, but commit 95b8a5e0111a ("MIPS: Remove NETLOGIC support") also
dropped Au1300 detection.  Restore Au1300 detection.

Tested on DB1300 with Au1380 chip.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/mips/kernel/cpu-probe.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index cf3fd549e16d0..f9368071a6bd9 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -1686,6 +1686,10 @@ static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
 			break;
 		}
 		break;
+	case PRID_IMP_NETLOGIC_AU13XX:
+		c->cputype = CPU_ALCHEMY;
+		__cpu_name[cpu] = "Au1300";
+		break;
 	}
 }
 
@@ -1988,6 +1992,7 @@ void cpu_probe(void)
 		cpu_probe_mips(c, cpu);
 		break;
 	case PRID_COMP_ALCHEMY:
+	case PRID_COMP_NETLOGIC:
 		cpu_probe_alchemy(c, cpu);
 		break;
 	case PRID_COMP_SIBYTE:
-- 
2.39.2


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

* [PATCH AUTOSEL 4.14 08/10] MIPS: Alchemy: fix dbdma2
  2023-05-31 13:45 [PATCH AUTOSEL 4.14 01/10] power: supply: ab8500: Fix external_power_changed race Sasha Levin
                   ` (5 preceding siblings ...)
  2023-05-31 13:46 ` [PATCH AUTOSEL 4.14 07/10] MIPS: Restore Au1300 support Sasha Levin
@ 2023-05-31 13:46 ` Sasha Levin
  2023-06-16 19:29   ` Pavel Machek
  2023-05-31 13:46 ` [PATCH AUTOSEL 4.14 09/10] mips: Move initrd_start check after initrd address sanitisation Sasha Levin
  2023-05-31 13:46 ` [PATCH AUTOSEL 4.14 10/10] xen/blkfront: Only check REQ_FUA for writes Sasha Levin
  8 siblings, 1 reply; 14+ messages in thread
From: Sasha Levin @ 2023-05-31 13:46 UTC (permalink / raw
  To: linux-kernel, stable
  Cc: Manuel Lauss, Thomas Bogendoerfer, Sasha Levin, linux-mips

From: Manuel Lauss <manuel.lauss@gmail.com>

[ Upstream commit 2d645604f69f3a772d58ead702f9a8e84ab2b342 ]

Various fixes for the Au1200/Au1550/Au1300 DBDMA2 code:

- skip cache invalidation if chip has working coherency circuitry.
- invalidate KSEG0-portion of the (physical) data address.
- force the dma channel doorbell write out to bus immediately with
  a sync.

Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/mips/alchemy/common/dbdma.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/arch/mips/alchemy/common/dbdma.c b/arch/mips/alchemy/common/dbdma.c
index fc482d900dddb..122f8c0d258ef 100644
--- a/arch/mips/alchemy/common/dbdma.c
+++ b/arch/mips/alchemy/common/dbdma.c
@@ -30,6 +30,7 @@
  *
  */
 
+#include <linux/dma-map-ops.h> /* for dma_default_coherent */
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
@@ -623,17 +624,18 @@ u32 au1xxx_dbdma_put_source(u32 chanid, dma_addr_t buf, int nbytes, u32 flags)
 		dp->dscr_cmd0 &= ~DSCR_CMD0_IE;
 
 	/*
-	 * There is an errata on the Au1200/Au1550 parts that could result
-	 * in "stale" data being DMA'ed. It has to do with the snoop logic on
-	 * the cache eviction buffer.  DMA_NONCOHERENT is on by default for
-	 * these parts. If it is fixed in the future, these dma_cache_inv will
-	 * just be nothing more than empty macros. See io.h.
+	 * There is an erratum on certain Au1200/Au1550 revisions that could
+	 * result in "stale" data being DMA'ed. It has to do with the snoop
+	 * logic on the cache eviction buffer.  dma_default_coherent is set
+	 * to false on these parts.
 	 */
-	dma_cache_wback_inv((unsigned long)buf, nbytes);
+	if (!dma_default_coherent)
+		dma_cache_wback_inv(KSEG0ADDR(buf), nbytes);
 	dp->dscr_cmd0 |= DSCR_CMD0_V;	/* Let it rip */
 	wmb(); /* drain writebuffer */
 	dma_cache_wback_inv((unsigned long)dp, sizeof(*dp));
 	ctp->chan_ptr->ddma_dbell = 0;
+	wmb(); /* force doorbell write out to dma engine */
 
 	/* Get next descriptor pointer. */
 	ctp->put_ptr = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr));
@@ -685,17 +687,18 @@ u32 au1xxx_dbdma_put_dest(u32 chanid, dma_addr_t buf, int nbytes, u32 flags)
 			  dp->dscr_source1, dp->dscr_dest0, dp->dscr_dest1);
 #endif
 	/*
-	 * There is an errata on the Au1200/Au1550 parts that could result in
-	 * "stale" data being DMA'ed. It has to do with the snoop logic on the
-	 * cache eviction buffer.  DMA_NONCOHERENT is on by default for these
-	 * parts. If it is fixed in the future, these dma_cache_inv will just
-	 * be nothing more than empty macros. See io.h.
+	 * There is an erratum on certain Au1200/Au1550 revisions that could
+	 * result in "stale" data being DMA'ed. It has to do with the snoop
+	 * logic on the cache eviction buffer.  dma_default_coherent is set
+	 * to false on these parts.
 	 */
-	dma_cache_inv((unsigned long)buf, nbytes);
+	if (!dma_default_coherent)
+		dma_cache_inv(KSEG0ADDR(buf), nbytes);
 	dp->dscr_cmd0 |= DSCR_CMD0_V;	/* Let it rip */
 	wmb(); /* drain writebuffer */
 	dma_cache_wback_inv((unsigned long)dp, sizeof(*dp));
 	ctp->chan_ptr->ddma_dbell = 0;
+	wmb(); /* force doorbell write out to dma engine */
 
 	/* Get next descriptor pointer. */
 	ctp->put_ptr = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr));
-- 
2.39.2


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

* [PATCH AUTOSEL 4.14 09/10] mips: Move initrd_start check after initrd address sanitisation.
  2023-05-31 13:45 [PATCH AUTOSEL 4.14 01/10] power: supply: ab8500: Fix external_power_changed race Sasha Levin
                   ` (6 preceding siblings ...)
  2023-05-31 13:46 ` [PATCH AUTOSEL 4.14 08/10] MIPS: Alchemy: fix dbdma2 Sasha Levin
@ 2023-05-31 13:46 ` Sasha Levin
  2023-05-31 13:46 ` [PATCH AUTOSEL 4.14 10/10] xen/blkfront: Only check REQ_FUA for writes Sasha Levin
  8 siblings, 0 replies; 14+ messages in thread
From: Sasha Levin @ 2023-05-31 13:46 UTC (permalink / raw
  To: linux-kernel, stable
  Cc: Liviu Dudau, Thomas Bogendoerfer, Sasha Levin, nathan, yury.norov,
	Jason, linux-mips

From: Liviu Dudau <liviu@dudau.co.uk>

[ Upstream commit 4897a898a216058dec55e5e5902534e6e224fcdf ]

PAGE_OFFSET is technically a virtual address so when checking the value of
initrd_start against it we should make sure that it has been sanitised from
the values passed by the bootloader. Without this change, even with a bootloader
that passes correct addresses for an initrd, we are failing to load it on MT7621
boards, for example.

Signed-off-by: Liviu Dudau <liviu@dudau.co.uk>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/mips/kernel/setup.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index abd7ee9e90ab0..d205d3875e2c2 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -257,10 +257,6 @@ static unsigned long __init init_initrd(void)
 		pr_err("initrd start must be page aligned\n");
 		goto disable;
 	}
-	if (initrd_start < PAGE_OFFSET) {
-		pr_err("initrd start < PAGE_OFFSET\n");
-		goto disable;
-	}
 
 	/*
 	 * Sanitize initrd addresses. For example firmware
@@ -273,6 +269,11 @@ static unsigned long __init init_initrd(void)
 	initrd_end = (unsigned long)__va(end);
 	initrd_start = (unsigned long)__va(__pa(initrd_start));
 
+	if (initrd_start < PAGE_OFFSET) {
+		pr_err("initrd start < PAGE_OFFSET\n");
+		goto disable;
+	}
+
 	ROOT_DEV = Root_RAM0;
 	return PFN_UP(end);
 disable:
-- 
2.39.2


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

* [PATCH AUTOSEL 4.14 10/10] xen/blkfront: Only check REQ_FUA for writes
  2023-05-31 13:45 [PATCH AUTOSEL 4.14 01/10] power: supply: ab8500: Fix external_power_changed race Sasha Levin
                   ` (7 preceding siblings ...)
  2023-05-31 13:46 ` [PATCH AUTOSEL 4.14 09/10] mips: Move initrd_start check after initrd address sanitisation Sasha Levin
@ 2023-05-31 13:46 ` Sasha Levin
  8 siblings, 0 replies; 14+ messages in thread
From: Sasha Levin @ 2023-05-31 13:46 UTC (permalink / raw
  To: linux-kernel, stable
  Cc: Ross Lagerwall, Juergen Gross, Sasha Levin, roger.pau,
	sstabellini, axboe, xen-devel, linux-block

From: Ross Lagerwall <ross.lagerwall@citrix.com>

[ Upstream commit b6ebaa8100090092aa602530d7e8316816d0c98d ]

The existing code silently converts read operations with the
REQ_FUA bit set into write-barrier operations. This results in data
loss as the backend scribbles zeroes over the data instead of returning
it.

While the REQ_FUA bit doesn't make sense on a read operation, at least
one well-known out-of-tree kernel module does set it and since it
results in data loss, let's be safe here and only look at REQ_FUA for
writes.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Acked-by: Juergen Gross <jgross@suse.com>
Link: https://lore.kernel.org/r/20230426164005.2213139-1-ross.lagerwall@citrix.com
Signed-off-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/block/xen-blkfront.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index cd58f582c50c1..b649f1a68b417 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -780,7 +780,8 @@ static int blkif_queue_rw_req(struct request *req, struct blkfront_ring_info *ri
 		ring_req->u.rw.handle = info->handle;
 		ring_req->operation = rq_data_dir(req) ?
 			BLKIF_OP_WRITE : BLKIF_OP_READ;
-		if (req_op(req) == REQ_OP_FLUSH || req->cmd_flags & REQ_FUA) {
+		if (req_op(req) == REQ_OP_FLUSH ||
+		    (req_op(req) == REQ_OP_WRITE && (req->cmd_flags & REQ_FUA))) {
 			/*
 			 * Ideally we can do an unordered flush-to-disk.
 			 * In case the backend onlysupports barriers, use that.
-- 
2.39.2


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

* Re: [PATCH AUTOSEL 4.14 02/10] power: supply: bq27xxx: Use mod_delayed_work() instead of cancel() + schedule()
  2023-05-31 13:45 ` [PATCH AUTOSEL 4.14 02/10] power: supply: bq27xxx: Use mod_delayed_work() instead of cancel() + schedule() Sasha Levin
@ 2023-06-16 19:28   ` Pavel Machek
  0 siblings, 0 replies; 14+ messages in thread
From: Pavel Machek @ 2023-06-16 19:28 UTC (permalink / raw
  To: Sasha Levin
  Cc: linux-kernel, stable, Hans de Goede, Sebastian Reichel, sre,
	linux-pm

[-- Attachment #1: Type: text/plain, Size: 1033 bytes --]

Hi!

> From: Hans de Goede <hdegoede@redhat.com>
> 
> [ Upstream commit 59dddea9879713423c7b2ade43c423bb71e0d216 ]
> 
> Use mod_delayed_work() instead of separate cancel_delayed_work_sync() +
> schedule_delayed_work() calls.

AFAICT this is just a cleanup, we should not need it for -stable.

Best regards,
								Pavel
								
> +++ b/drivers/power/supply/bq27xxx_battery.c
> @@ -832,10 +832,8 @@ static int poll_interval_param_set(const char *val, const struct kernel_param *k
>  		return ret;
>  
>  	mutex_lock(&bq27xxx_list_lock);
> -	list_for_each_entry(di, &bq27xxx_battery_devices, list) {
> -		cancel_delayed_work_sync(&di->work);
> -		schedule_delayed_work(&di->work, 0);
> -	}
> +	list_for_each_entry(di, &bq27xxx_battery_devices, list)
> +		mod_delayed_work(system_wq, &di->work, 0);
>  	mutex_unlock(&bq27xxx_list_lock);
>  
>  	return ret;

-- 
DENX Software Engineering GmbH,        Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* Re: [PATCH AUTOSEL 4.14 08/10] MIPS: Alchemy: fix dbdma2
  2023-05-31 13:46 ` [PATCH AUTOSEL 4.14 08/10] MIPS: Alchemy: fix dbdma2 Sasha Levin
@ 2023-06-16 19:29   ` Pavel Machek
       [not found]     ` <CAOLZvyHQL7T33O9fSdBZMtjrLKO2uN6Gr6g_p0oKVUtnMuXheQ@mail.gmail.com>
  0 siblings, 1 reply; 14+ messages in thread
From: Pavel Machek @ 2023-06-16 19:29 UTC (permalink / raw
  To: Sasha Levin
  Cc: linux-kernel, stable, Manuel Lauss, Thomas Bogendoerfer,
	linux-mips

[-- Attachment #1: Type: text/plain, Size: 749 bytes --]

Hi!

> From: Manuel Lauss <manuel.lauss@gmail.com>
> 
> [ Upstream commit 2d645604f69f3a772d58ead702f9a8e84ab2b342 ]
> 
> Various fixes for the Au1200/Au1550/Au1300 DBDMA2 code:
> 
> - skip cache invalidation if chip has working coherency circuitry.
> - invalidate KSEG0-portion of the (physical) data address.
> - force the dma channel doorbell write out to bus immediately with
>   a sync.
> 
> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> Signed-off-by: Sasha Levin <sashal@kernel.org>

I believe author's signoff is missing here.

Best regards,
							Pavel
-- 
DENX Software Engineering GmbH,        Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* Re: [PATCH AUTOSEL 4.14 08/10] MIPS: Alchemy: fix dbdma2
       [not found]     ` <CAOLZvyHQL7T33O9fSdBZMtjrLKO2uN6Gr6g_p0oKVUtnMuXheQ@mail.gmail.com>
@ 2023-06-18  8:56       ` Pavel Machek
  2023-06-20  6:31         ` Manuel Lauss
  0 siblings, 1 reply; 14+ messages in thread
From: Pavel Machek @ 2023-06-18  8:56 UTC (permalink / raw
  To: Manuel Lauss
  Cc: Pavel Machek, Sasha Levin, linux-kernel, stable,
	Thomas Bogendoerfer, linux-mips

[-- Attachment #1: Type: text/plain, Size: 1154 bytes --]

On Sun 2023-06-18 07:43:10, Manuel Lauss wrote:
> On Fri, Jun 16, 2023 at 9:33 PM Pavel Machek <pavel@denx.de> wrote:
> 
> > Hi!
> >
> > > From: Manuel Lauss <manuel.lauss@gmail.com>
> > >
> > > [ Upstream commit 2d645604f69f3a772d58ead702f9a8e84ab2b342 ]
> > >
> > > Various fixes for the Au1200/Au1550/Au1300 DBDMA2 code:
> > >
> > > - skip cache invalidation if chip has working coherency circuitry.
> > > - invalidate KSEG0-portion of the (physical) data address.
> > > - force the dma channel doorbell write out to bus immediately with
> > >   a sync.
> > >
> > > Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> > > Signed-off-by: Sasha Levin <sashal@kernel.org>
> >
> > I believe author's signoff is missing here.
> >
> 
> As the author, I say this patch should not be applied to 4.xx at all.  Same
> for my other 2 MIPS patches.

Thanks for info, where is the threshold, do we need them for 5.10?

Sasha, please drop.

Best regards,
									Pavel

-- 
DENX Software Engineering GmbH,        Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* Re: [PATCH AUTOSEL 4.14 08/10] MIPS: Alchemy: fix dbdma2
  2023-06-18  8:56       ` Pavel Machek
@ 2023-06-20  6:31         ` Manuel Lauss
  0 siblings, 0 replies; 14+ messages in thread
From: Manuel Lauss @ 2023-06-20  6:31 UTC (permalink / raw
  To: Pavel Machek
  Cc: Sasha Levin, linux-kernel, stable, Thomas Bogendoerfer,
	linux-mips

On Sun, Jun 18, 2023 at 10:56 AM Pavel Machek <pavel@denx.de> wrote:
>
> On Sun 2023-06-18 07:43:10, Manuel Lauss wrote:
> > On Fri, Jun 16, 2023 at 9:33 PM Pavel Machek <pavel@denx.de> wrote:
> >
> > > Hi!
> > >
> > > > From: Manuel Lauss <manuel.lauss@gmail.com>
> > > >
> > > > [ Upstream commit 2d645604f69f3a772d58ead702f9a8e84ab2b342 ]
> > > >
> > > > Various fixes for the Au1200/Au1550/Au1300 DBDMA2 code:
> > > >
> > > > - skip cache invalidation if chip has working coherency circuitry.
> > > > - invalidate KSEG0-portion of the (physical) data address.
> > > > - force the dma channel doorbell write out to bus immediately with
> > > >   a sync.
> > > >
> > > > Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> > > > Signed-off-by: Sasha Levin <sashal@kernel.org>
> > >
> > > I believe author's signoff is missing here.
> > >
> >
> > As the author, I say this patch should not be applied to 4.xx at all.  Same
> > for my other 2 MIPS patches.
>
> Thanks for info, where is the threshold, do we need them for 5.10?

Drop this one "MIPS: Alchemy: fix dbdma2" from all stable,
the other 2 can be applied to 5.10 if need be.  I seem to be the only active
user of this hardware and I only test mainline, so it's probably not a big issue
if you drop the all from stable.

    Manuel

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

end of thread, other threads:[~2023-06-20  6:32 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-31 13:45 [PATCH AUTOSEL 4.14 01/10] power: supply: ab8500: Fix external_power_changed race Sasha Levin
2023-05-31 13:45 ` [PATCH AUTOSEL 4.14 02/10] power: supply: bq27xxx: Use mod_delayed_work() instead of cancel() + schedule() Sasha Levin
2023-06-16 19:28   ` Pavel Machek
2023-05-31 13:45 ` [PATCH AUTOSEL 4.14 03/10] ARM: dts: vexpress: add missing cache properties Sasha Levin
2023-05-31 13:46 ` [PATCH AUTOSEL 4.14 04/10] power: supply: Ratelimit no data debug output Sasha Levin
2023-05-31 13:46 ` [PATCH AUTOSEL 4.14 05/10] regulator: Fix error checking for debugfs_create_dir Sasha Levin
2023-05-31 13:46 ` [PATCH AUTOSEL 4.14 06/10] power: supply: Fix logic checking if system is running from battery Sasha Levin
2023-05-31 13:46 ` [PATCH AUTOSEL 4.14 07/10] MIPS: Restore Au1300 support Sasha Levin
2023-05-31 13:46 ` [PATCH AUTOSEL 4.14 08/10] MIPS: Alchemy: fix dbdma2 Sasha Levin
2023-06-16 19:29   ` Pavel Machek
     [not found]     ` <CAOLZvyHQL7T33O9fSdBZMtjrLKO2uN6Gr6g_p0oKVUtnMuXheQ@mail.gmail.com>
2023-06-18  8:56       ` Pavel Machek
2023-06-20  6:31         ` Manuel Lauss
2023-05-31 13:46 ` [PATCH AUTOSEL 4.14 09/10] mips: Move initrd_start check after initrd address sanitisation Sasha Levin
2023-05-31 13:46 ` [PATCH AUTOSEL 4.14 10/10] xen/blkfront: Only check REQ_FUA for writes Sasha Levin

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 read-only IMAP folder(s) and NNTP newsgroup(s).