--- /dev/null
+From 6a28a25d358079b7d0d144689f850aecacf63cba Mon Sep 17 00:00:00 2001
+From: Victor Shyba <victor1984@riseup.net>
+Date: Mon, 23 Jan 2023 19:21:29 -0300
+Subject: ALSA: hda/realtek: Add Acer Predator PH315-54
+
+From: Victor Shyba <victor1984@riseup.net>
+
+commit 6a28a25d358079b7d0d144689f850aecacf63cba upstream.
+
+Same issue as SP513-54N: Headset microphone does not work without
+ALC255_FIXUP_ACER_MIC_NO_PRESENCE fixup.
+
+BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=211853
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Victor Shyba <victor1984@riseup.net>
+Link: https://lore.kernel.org/r/20230123222129.17589-1-victor1984@riseup.net
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ sound/pci/hda/patch_realtek.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/sound/pci/hda/patch_realtek.c
++++ b/sound/pci/hda/patch_realtek.c
+@@ -9202,6 +9202,7 @@ static const struct snd_pci_quirk alc269
+ SND_PCI_QUIRK(0x1025, 0x142b, "Acer Swift SF314-42", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
+ SND_PCI_QUIRK(0x1025, 0x1430, "Acer TravelMate B311R-31", ALC256_FIXUP_ACER_MIC_NO_PRESENCE),
+ SND_PCI_QUIRK(0x1025, 0x1466, "Acer Aspire A515-56", ALC255_FIXUP_ACER_HEADPHONE_AND_MIC),
++ SND_PCI_QUIRK(0x1025, 0x1534, "Acer Predator PH315-54", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
+ SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
+ SND_PCI_QUIRK(0x1028, 0x053c, "Dell Latitude E5430", ALC292_FIXUP_DELL_E7X),
+ SND_PCI_QUIRK(0x1028, 0x054b, "Dell XPS one 2710", ALC275_FIXUP_DELL_XPS),
--- /dev/null
+From 858c54152658ccd4e305c1e12d3cc6825bc90504 Mon Sep 17 00:00:00 2001
+From: Jeremy Szu <jeremy.szu@canonical.com>
+Date: Wed, 18 Jan 2023 19:54:45 +0800
+Subject: ALSA: hda/realtek: fix mute/micmute LEDs, speaker don't work for a HP platform
+
+From: Jeremy Szu <jeremy.szu@canonical.com>
+
+commit 858c54152658ccd4e305c1e12d3cc6825bc90504 upstream.
+
+There is a HP platform needs ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED quirk to
+make mic-mute/audio-mute/speaker working.
+
+Signed-off-by: Jeremy Szu <jeremy.szu@canonical.com>
+Cc: <stable@vger.kernel.org>
+Link: https://lore.kernel.org/r/20230118115446.14902-1-jeremy.szu@canonical.com
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ sound/pci/hda/patch_realtek.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/sound/pci/hda/patch_realtek.c
++++ b/sound/pci/hda/patch_realtek.c
+@@ -9433,6 +9433,7 @@ static const struct snd_pci_quirk alc269
+ SND_PCI_QUIRK(0x103c, 0x8ad2, "HP EliteBook 860 16 inch G9 Notebook PC", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED),
+ SND_PCI_QUIRK(0x103c, 0x8b5d, "HP", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF),
+ SND_PCI_QUIRK(0x103c, 0x8b5e, "HP", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF),
++ SND_PCI_QUIRK(0x103c, 0x8b92, "HP", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED),
+ SND_PCI_QUIRK(0x103c, 0x8bf0, "HP", ALC236_FIXUP_HP_GPIO_LED),
+ SND_PCI_QUIRK(0x1043, 0x103e, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC),
+ SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300),
--- /dev/null
+From 1febf88ef907b142fdde34f7c64ed3535d9339e4 Mon Sep 17 00:00:00 2001
+From: Fabio Estevam <festevam@denx.de>
+Date: Tue, 17 Jan 2023 08:25:10 -0300
+Subject: ARM: dts: imx7d-smegw01: Fix USB host over-current polarity
+
+From: Fabio Estevam <festevam@denx.de>
+
+commit 1febf88ef907b142fdde34f7c64ed3535d9339e4 upstream.
+
+Currently, when resetting the USB modem via AT commands, the modem is
+no longer re-connected.
+
+This problem is caused by the incorrect description of the USB_OTG2_OC
+pad. It should have pull-up enabled, hysteresis enabled and the
+property 'over-current-active-low' should be passed.
+
+With this change, the USB modem can be successfully re-connected
+after a reset.
+
+Cc: stable@vger.kernel.org
+Fixes: 9ac0ae97e349 ("ARM: dts: imx7d-smegw01: Add support for i.MX7D SMEGW01 board")
+Signed-off-by: Fabio Estevam <festevam@denx.de>
+Signed-off-by: Shawn Guo <shawnguo@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/arm/boot/dts/imx7d-smegw01.dts | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/arch/arm/boot/dts/imx7d-smegw01.dts b/arch/arm/boot/dts/imx7d-smegw01.dts
+index 546268b8d0b1..c0f00f5db11e 100644
+--- a/arch/arm/boot/dts/imx7d-smegw01.dts
++++ b/arch/arm/boot/dts/imx7d-smegw01.dts
+@@ -198,6 +198,7 @@
+ &usbotg2 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_usbotg2>;
++ over-current-active-low;
+ dr_mode = "host";
+ status = "okay";
+ };
+@@ -374,7 +375,7 @@
+
+ pinctrl_usbotg2: usbotg2grp {
+ fsl,pins = <
+- MX7D_PAD_UART3_RTS_B__USB_OTG2_OC 0x04
++ MX7D_PAD_UART3_RTS_B__USB_OTG2_OC 0x5c
+ >;
+ };
+
+--
+2.39.1
+
--- /dev/null
+From 100c94ffde489ee11e23400f2a07b236144b048f Mon Sep 17 00:00:00 2001
+From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
+Date: Tue, 24 Jan 2023 13:30:49 +0100
+Subject: ASoC: codecs: wsa883x: correct playback min/max rates
+
+From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
+
+commit 100c94ffde489ee11e23400f2a07b236144b048f upstream.
+
+Correct reversed values used in min/max rates, leading to incorrect
+playback constraints.
+
+Cc: <stable@vger.kernel.org>
+Fixes: 43b8c7dc85a1 ("ASoC: codecs: add wsa883x amplifier support")
+Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
+Link: https://lore.kernel.org/r/20230124123049.285395-1-krzysztof.kozlowski@linaro.org
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ sound/soc/codecs/wsa883x.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/sound/soc/codecs/wsa883x.c b/sound/soc/codecs/wsa883x.c
+index 966ba4909204..58fdb4e9fd97 100644
+--- a/sound/soc/codecs/wsa883x.c
++++ b/sound/soc/codecs/wsa883x.c
+@@ -1359,8 +1359,8 @@ static struct snd_soc_dai_driver wsa883x_dais[] = {
+ .stream_name = "SPKR Playback",
+ .rates = WSA883X_RATES | WSA883X_FRAC_RATES,
+ .formats = WSA883X_FORMATS,
+- .rate_max = 8000,
+- .rate_min = 352800,
++ .rate_min = 8000,
++ .rate_max = 352800,
+ .channels_min = 1,
+ .channels_max = 1,
+ },
+--
+2.39.1
+
--- /dev/null
+From cc755b4377b0520d594ae573497cf0824baea648 Mon Sep 17 00:00:00 2001
+From: Bard Liao <yung-chuan.liao@linux.intel.com>
+Date: Wed, 18 Jan 2023 12:12:55 +0200
+Subject: ASoC: SOF: keep prepare/unprepare widgets in sink path
+
+From: Bard Liao <yung-chuan.liao@linux.intel.com>
+
+commit cc755b4377b0520d594ae573497cf0824baea648 upstream.
+
+The existing code return when a widget doesn't need to
+prepare/unprepare. This will prevent widgets in the sink path from being
+prepared/unprepared.
+
+Cc: <stable@vger.kernel.org> # 6.1
+Link: https://github.com/thesofproject/linux/issues/4021
+Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
+Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
+Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
+Reviewed-by: Rander Wang <rander.wang@intel.com>
+Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
+Link: https://lore.kernel.org/r/20230118101255.29139-4-peter.ujfalusi@linux.intel.com
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ sound/soc/sof/sof-audio.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c
+index 8c114e6a23c6..ff716bfbcb67 100644
+--- a/sound/soc/sof/sof-audio.c
++++ b/sound/soc/sof/sof-audio.c
+@@ -271,9 +271,9 @@ sof_unprepare_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_dapm_widg
+ struct snd_sof_widget *swidget = widget->dobj.private;
+ struct snd_soc_dapm_path *p;
+
+- /* return if the widget is in use or if it is already unprepared */
++ /* skip if the widget is in use or if it is already unprepared */
+ if (!swidget || !swidget->prepared || swidget->use_count > 0)
+- return;
++ goto sink_unprepare;
+
+ if (widget_ops[widget->id].ipc_unprepare)
+ /* unprepare the source widget */
+@@ -281,6 +281,7 @@ sof_unprepare_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_dapm_widg
+
+ swidget->prepared = false;
+
++sink_unprepare:
+ /* unprepare all widgets in the sink paths */
+ snd_soc_dapm_widget_for_each_sink_path(widget, p) {
+ if (!p->walking && p->sink->dobj.private) {
+--
+2.39.1
+
--- /dev/null
+From 0ad84b11f2f8dd19d62d0b2ffd95ece897e6c3dc Mon Sep 17 00:00:00 2001
+From: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
+Date: Wed, 18 Jan 2023 12:12:54 +0200
+Subject: ASoC: SOF: sof-audio: skip prepare/unprepare if swidget is NULL
+
+From: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
+
+commit 0ad84b11f2f8dd19d62d0b2ffd95ece897e6c3dc upstream.
+
+Skip preparing/unpreparing widgets if the swidget pointer is NULL. This
+will be true in the case of virtual widgets in topology that were added
+for reusing the legacy HDA machine driver with SOF.
+
+Fixes: 9862dcf70245 ("ASoC: SOF: don't unprepare widget used other pipelines")
+Cc: <stable@vger.kernel.org> # 6.1
+Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
+Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
+Reviewed-by: Rander Wang <rander.wang@intel.com>
+Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
+Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
+Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
+Link: https://lore.kernel.org/r/20230118101255.29139-3-peter.ujfalusi@linux.intel.com
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ sound/soc/sof/sof-audio.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/sound/soc/sof/sof-audio.c
++++ b/sound/soc/sof/sof-audio.c
+@@ -272,7 +272,7 @@ sof_unprepare_widgets_in_path(struct snd
+ struct snd_soc_dapm_path *p;
+
+ /* return if the widget is in use or if it is already unprepared */
+- if (!swidget->prepared || swidget->use_count > 0)
++ if (!swidget || !swidget->prepared || swidget->use_count > 0)
+ return;
+
+ if (widget_ops[widget->id].ipc_unprepare)
+@@ -303,7 +303,7 @@ sof_prepare_widgets_in_path(struct snd_s
+ struct snd_soc_dapm_path *p;
+ int ret;
+
+- if (!widget_ops[widget->id].ipc_prepare || swidget->prepared)
++ if (!swidget || !widget_ops[widget->id].ipc_prepare || swidget->prepared)
+ goto sink_prepare;
+
+ /* prepare the source widget */
--- /dev/null
+From 7d2a67e02549c4b1feaac4d8b4151bf46424a047 Mon Sep 17 00:00:00 2001
+From: Bard Liao <yung-chuan.liao@linux.intel.com>
+Date: Wed, 18 Jan 2023 12:12:53 +0200
+Subject: ASoC: SOF: sof-audio: unprepare when swidget->use_count > 0
+
+From: Bard Liao <yung-chuan.liao@linux.intel.com>
+
+commit 7d2a67e02549c4b1feaac4d8b4151bf46424a047 upstream.
+
+We should unprepare the widget if its use_count = 1.
+
+Fixes: 9862dcf70245 ("ASoC: SOF: don't unprepare widget used other pipelines")
+Cc: <stable@vger.kernel.org> # 6.1
+Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
+Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
+Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
+Reviewed-by: Rander Wang <rander.wang@intel.com>
+Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
+Link: https://lore.kernel.org/r/20230118101255.29139-2-peter.ujfalusi@linux.intel.com
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ sound/soc/sof/sof-audio.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c
+index 7306a2649857..e52ef62ce7a3 100644
+--- a/sound/soc/sof/sof-audio.c
++++ b/sound/soc/sof/sof-audio.c
+@@ -272,7 +272,7 @@ sof_unprepare_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_dapm_widg
+ struct snd_soc_dapm_path *p;
+
+ /* return if the widget is in use or if it is already unprepared */
+- if (!swidget->prepared || swidget->use_count > 1)
++ if (!swidget->prepared || swidget->use_count > 0)
+ return;
+
+ if (widget_ops[widget->id].ipc_unprepare)
+--
+2.39.1
+
--- /dev/null
+From 823b2e42720f96f277940c37ea438b7c5ead51a4 Mon Sep 17 00:00:00 2001
+From: Oliver Hartkopp <socketcan@hartkopp.net>
+Date: Thu, 12 Jan 2023 20:23:47 +0100
+Subject: can: isotp: handle wait_event_interruptible() return values
+
+From: Oliver Hartkopp <socketcan@hartkopp.net>
+
+commit 823b2e42720f96f277940c37ea438b7c5ead51a4 upstream.
+
+When wait_event_interruptible() has been interrupted by a signal the
+tx.state value might not be ISOTP_IDLE. Force the state machines
+into idle state to inhibit the timer handlers to continue working.
+
+Fixes: 866337865f37 ("can: isotp: fix tx state handling for echo tx processing")
+Cc: stable@vger.kernel.org
+Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
+Link: https://lore.kernel.org/all/20230112192347.1944-1-socketcan@hartkopp.net
+Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/can/isotp.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+--- a/net/can/isotp.c
++++ b/net/can/isotp.c
+@@ -1152,6 +1152,10 @@ static int isotp_release(struct socket *
+ /* wait for complete transmission of current pdu */
+ wait_event_interruptible(so->wait, so->tx.state == ISOTP_IDLE);
+
++ /* force state machines to be idle also when a signal occurred */
++ so->tx.state = ISOTP_IDLE;
++ so->rx.state = ISOTP_IDLE;
++
+ spin_lock(&isotp_notifier_lock);
+ while (isotp_busy_notifier == so) {
+ spin_unlock(&isotp_notifier_lock);
--- /dev/null
+From 4f027cba8216f42a18b544842efab134f8b1f9f4 Mon Sep 17 00:00:00 2001
+From: Oliver Hartkopp <socketcan@hartkopp.net>
+Date: Wed, 4 Jan 2023 15:57:01 +0100
+Subject: can: isotp: split tx timer into transmission and timeout
+
+From: Oliver Hartkopp <socketcan@hartkopp.net>
+
+commit 4f027cba8216f42a18b544842efab134f8b1f9f4 upstream.
+
+The timer for the transmission of isotp PDUs formerly had two functions:
+1. send two consecutive frames with a given time gap
+2. monitor the timeouts for flow control frames and the echo frames
+
+This led to larger txstate checks and potentially to a problem discovered
+by syzbot which enabled the panic_on_warn feature while testing.
+
+The former 'txtimer' function is split into 'txfrtimer' and 'txtimer'
+to handle the two above functionalities with separate timer callbacks.
+
+The two simplified timers now run in one-shot mode and make the state
+transitions (especially with isotp_rcv_echo) better understandable.
+
+Fixes: 866337865f37 ("can: isotp: fix tx state handling for echo tx processing")
+Reported-by: syzbot+5aed6c3aaba661f5b917@syzkaller.appspotmail.com
+Cc: stable@vger.kernel.org # >= v6.0
+Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
+Link: https://lore.kernel.org/all/20230104145701.2422-1-socketcan@hartkopp.net
+Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/can/isotp.c | 65 ++++++++++++++++++++++++--------------------------------
+ 1 file changed, 29 insertions(+), 36 deletions(-)
+
+--- a/net/can/isotp.c
++++ b/net/can/isotp.c
+@@ -140,7 +140,7 @@ struct isotp_sock {
+ canid_t rxid;
+ ktime_t tx_gap;
+ ktime_t lastrxcf_tstamp;
+- struct hrtimer rxtimer, txtimer;
++ struct hrtimer rxtimer, txtimer, txfrtimer;
+ struct can_isotp_options opt;
+ struct can_isotp_fc_options rxfc, txfc;
+ struct can_isotp_ll_options ll;
+@@ -871,7 +871,7 @@ static void isotp_rcv_echo(struct sk_buf
+ }
+
+ /* start timer to send next consecutive frame with correct delay */
+- hrtimer_start(&so->txtimer, so->tx_gap, HRTIMER_MODE_REL_SOFT);
++ hrtimer_start(&so->txfrtimer, so->tx_gap, HRTIMER_MODE_REL_SOFT);
+ }
+
+ static enum hrtimer_restart isotp_tx_timer_handler(struct hrtimer *hrtimer)
+@@ -879,49 +879,39 @@ static enum hrtimer_restart isotp_tx_tim
+ struct isotp_sock *so = container_of(hrtimer, struct isotp_sock,
+ txtimer);
+ struct sock *sk = &so->sk;
+- enum hrtimer_restart restart = HRTIMER_NORESTART;
+
+- switch (so->tx.state) {
+- case ISOTP_SENDING:
++ /* don't handle timeouts in IDLE state */
++ if (so->tx.state == ISOTP_IDLE)
++ return HRTIMER_NORESTART;
+
+- /* cfecho should be consumed by isotp_rcv_echo() here */
+- if (!so->cfecho) {
+- /* start timeout for unlikely lost echo skb */
+- hrtimer_set_expires(&so->txtimer,
+- ktime_add(ktime_get(),
+- ktime_set(ISOTP_ECHO_TIMEOUT, 0)));
+- restart = HRTIMER_RESTART;
++ /* we did not get any flow control or echo frame in time */
+
+- /* push out the next consecutive frame */
+- isotp_send_cframe(so);
+- break;
+- }
+-
+- /* cfecho has not been cleared in isotp_rcv_echo() */
+- pr_notice_once("can-isotp: cfecho %08X timeout\n", so->cfecho);
+- fallthrough;
++ /* report 'communication error on send' */
++ sk->sk_err = ECOMM;
++ if (!sock_flag(sk, SOCK_DEAD))
++ sk_error_report(sk);
+
+- case ISOTP_WAIT_FC:
+- case ISOTP_WAIT_FIRST_FC:
++ /* reset tx state */
++ so->tx.state = ISOTP_IDLE;
++ wake_up_interruptible(&so->wait);
+
+- /* we did not get any flow control frame in time */
++ return HRTIMER_NORESTART;
++}
+
+- /* report 'communication error on send' */
+- sk->sk_err = ECOMM;
+- if (!sock_flag(sk, SOCK_DEAD))
+- sk_error_report(sk);
++static enum hrtimer_restart isotp_txfr_timer_handler(struct hrtimer *hrtimer)
++{
++ struct isotp_sock *so = container_of(hrtimer, struct isotp_sock,
++ txfrtimer);
+
+- /* reset tx state */
+- so->tx.state = ISOTP_IDLE;
+- wake_up_interruptible(&so->wait);
+- break;
++ /* start echo timeout handling and cover below protocol error */
++ hrtimer_start(&so->txtimer, ktime_set(ISOTP_ECHO_TIMEOUT, 0),
++ HRTIMER_MODE_REL_SOFT);
+
+- default:
+- WARN_ONCE(1, "can-isotp: tx timer state %08X cfecho %08X\n",
+- so->tx.state, so->cfecho);
+- }
++ /* cfecho should be consumed by isotp_rcv_echo() here */
++ if (so->tx.state == ISOTP_SENDING && !so->cfecho)
++ isotp_send_cframe(so);
+
+- return restart;
++ return HRTIMER_NORESTART;
+ }
+
+ static int isotp_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
+@@ -1194,6 +1184,7 @@ static int isotp_release(struct socket *
+ }
+ }
+
++ hrtimer_cancel(&so->txfrtimer);
+ hrtimer_cancel(&so->txtimer);
+ hrtimer_cancel(&so->rxtimer);
+
+@@ -1597,6 +1588,8 @@ static int isotp_init(struct sock *sk)
+ so->rxtimer.function = isotp_rx_timer_handler;
+ hrtimer_init(&so->txtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT);
+ so->txtimer.function = isotp_tx_timer_handler;
++ hrtimer_init(&so->txfrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT);
++ so->txfrtimer.function = isotp_txfr_timer_handler;
+
+ init_waitqueue_head(&so->wait);
+ spin_lock_init(&so->rx_lock);
--- /dev/null
+From e5ae8803847b80fe9d744a3174abe2b7bfed222a Mon Sep 17 00:00:00 2001
+From: Waiman Long <longman@redhat.com>
+Date: Tue, 31 Jan 2023 10:48:03 -0500
+Subject: cgroup/cpuset: Fix wrong check in update_parent_subparts_cpumask()
+
+From: Waiman Long <longman@redhat.com>
+
+commit e5ae8803847b80fe9d744a3174abe2b7bfed222a upstream.
+
+It was found that the check to see if a partition could use up all
+the cpus from the parent cpuset in update_parent_subparts_cpumask()
+was incorrect. As a result, it is possible to leave parent with no
+effective cpu left even if there are tasks in the parent cpuset. This
+can lead to system panic as reported in [1].
+
+Fix this probem by updating the check to fail the enabling the partition
+if parent's effective_cpus is a subset of the child's cpus_allowed.
+
+Also record the error code when an error happens in update_prstate()
+and add a test case where parent partition and child have the same cpu
+list and parent has task. Enabling partition in the child will fail in
+this case.
+
+[1] https://www.spinics.net/lists/cgroups/msg36254.html
+
+Fixes: f0af1bfc27b5 ("cgroup/cpuset: Relax constraints to partition & cpus changes")
+Cc: stable@vger.kernel.org # v6.1
+Reported-by: Srinivas Pandruvada <srinivas.pandruvada@intel.com>
+Signed-off-by: Waiman Long <longman@redhat.com>
+Signed-off-by: Tejun Heo <tj@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ kernel/cgroup/cpuset.c | 3 ++-
+ tools/testing/selftests/cgroup/test_cpuset_prs.sh | 1 +
+ 2 files changed, 3 insertions(+), 1 deletion(-)
+
+--- a/kernel/cgroup/cpuset.c
++++ b/kernel/cgroup/cpuset.c
+@@ -1342,7 +1342,7 @@ static int update_parent_subparts_cpumas
+ * A parent can be left with no CPU as long as there is no
+ * task directly associated with the parent partition.
+ */
+- if (!cpumask_intersects(cs->cpus_allowed, parent->effective_cpus) &&
++ if (cpumask_subset(parent->effective_cpus, cs->cpus_allowed) &&
+ partition_is_populated(parent, cs))
+ return PERR_NOCPUS;
+
+@@ -2320,6 +2320,7 @@ out:
+ new_prs = -new_prs;
+ spin_lock_irq(&callback_lock);
+ cs->partition_root_state = new_prs;
++ WRITE_ONCE(cs->prs_err, err);
+ spin_unlock_irq(&callback_lock);
+ /*
+ * Update child cpusets, if present.
+--- a/tools/testing/selftests/cgroup/test_cpuset_prs.sh
++++ b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
+@@ -254,6 +254,7 @@ TEST_MATRIX=(
+ # Taking away all CPUs from parent or itself if there are tasks
+ # will make the partition invalid.
+ " S+ C2-3:P1:S+ C3:P1 . . T C2-3 . . 0 A1:2-3,A2:2-3 A1:P1,A2:P-1"
++ " S+ C3:P1:S+ C3 . . T P1 . . 0 A1:3,A2:3 A1:P1,A2:P-1"
+ " S+ $SETUP_A123_PARTITIONS . T:C2-3 . . . 0 A1:2-3,A2:2-3,A3:3 A1:P1,A2:P-1,A3:P-1"
+ " S+ $SETUP_A123_PARTITIONS . T:C2-3:C1-3 . . . 0 A1:1,A2:2,A3:3 A1:P1,A2:P1,A3:P1"
+
--- /dev/null
+From 636ab417a7aec4ee993916e688eb5c5977570836 Mon Sep 17 00:00:00 2001
+From: Ard Biesheuvel <ardb@kernel.org>
+Date: Thu, 2 Feb 2023 18:30:06 +0100
+Subject: efi: Accept version 2 of memory attributes table
+
+From: Ard Biesheuvel <ardb@kernel.org>
+
+commit 636ab417a7aec4ee993916e688eb5c5977570836 upstream.
+
+UEFI v2.10 introduces version 2 of the memory attributes table, which
+turns the reserved field into a flags field, but is compatible with
+version 1 in all other respects. So let's not complain about version 2
+if we encounter it.
+
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/firmware/efi/memattr.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/firmware/efi/memattr.c
++++ b/drivers/firmware/efi/memattr.c
+@@ -33,7 +33,7 @@ int __init efi_memattr_init(void)
+ return -ENOMEM;
+ }
+
+- if (tbl->version > 1) {
++ if (tbl->version > 2) {
+ pr_warn("Unexpected EFI Memory Attributes table version %d\n",
+ tbl->version);
+ goto unmap;
--- /dev/null
+From 2b09d5d364986f724f17001ccfe4126b9b43a0be Mon Sep 17 00:00:00 2001
+From: Samuel Thibault <samuel.thibault@ens-lyon.org>
+Date: Sun, 29 Jan 2023 16:17:40 +0100
+Subject: fbcon: Check font dimension limits
+
+From: Samuel Thibault <samuel.thibault@ens-lyon.org>
+
+commit 2b09d5d364986f724f17001ccfe4126b9b43a0be upstream.
+
+blit_x and blit_y are u32, so fbcon currently cannot support fonts
+larger than 32x32.
+
+The 32x32 case also needs shifting an unsigned int, to properly set bit
+31, otherwise we get "UBSAN: shift-out-of-bounds in fbcon_set_font",
+as reported on:
+
+http://lore.kernel.org/all/IA1PR07MB98308653E259A6F2CE94A4AFABCE9@IA1PR07MB9830.namprd07.prod.outlook.com
+Kernel Branch: 6.2.0-rc5-next-20230124
+Kernel config: https://drive.google.com/file/d/1F-LszDAizEEH0ZX0HcSR06v5q8FPl2Uv/view?usp=sharing
+Reproducer: https://drive.google.com/file/d/1mP1jcLBY7vWCNM60OMf-ogw-urQRjNrm/view?usp=sharing
+
+Reported-by: Sanan Hasanov <sanan.hasanov@Knights.ucf.edu>
+Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
+Fixes: 2d2699d98492 ("fbcon: font setting should check limitation of driver")
+Cc: stable@vger.kernel.org
+Tested-by: Miko Larsson <mikoxyzzz@gmail.com>
+Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Helge Deller <deller@gmx.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/video/fbdev/core/fbcon.c | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+--- a/drivers/video/fbdev/core/fbcon.c
++++ b/drivers/video/fbdev/core/fbcon.c
+@@ -2495,9 +2495,12 @@ static int fbcon_set_font(struct vc_data
+ h > FBCON_SWAP(info->var.rotate, info->var.yres, info->var.xres))
+ return -EINVAL;
+
++ if (font->width > 32 || font->height > 32)
++ return -EINVAL;
++
+ /* Make sure drawing engine can handle the font */
+- if (!(info->pixmap.blit_x & (1 << (font->width - 1))) ||
+- !(info->pixmap.blit_y & (1 << (font->height - 1))))
++ if (!(info->pixmap.blit_x & BIT(font->width - 1)) ||
++ !(info->pixmap.blit_y & BIT(font->height - 1)))
+ return -EINVAL;
+
+ /* Make sure driver can handle the font length */
--- /dev/null
+From 99f1c46011cc0feb47d4f4f7bee70a0341442d14 Mon Sep 17 00:00:00 2001
+From: Michael Kelley <mikelley@microsoft.com>
+Date: Mon, 30 Jan 2023 19:33:06 -0800
+Subject: hv_netvsc: Fix missed pagebuf entries in netvsc_dma_map/unmap()
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Michael Kelley <mikelley@microsoft.com>
+
+commit 99f1c46011cc0feb47d4f4f7bee70a0341442d14 upstream.
+
+netvsc_dma_map() and netvsc_dma_unmap() currently check the cp_partial
+flag and adjust the page_count so that pagebuf entries for the RNDIS
+portion of the message are skipped when it has already been copied into
+a send buffer. But this adjustment has already been made by code in
+netvsc_send(). The duplicate adjustment causes some pagebuf entries to
+not be mapped. In a normal VM, this doesn't break anything because the
+mapping doesn’t change the PFN. But in a Confidential VM,
+dma_map_single() does bounce buffering and provides a different PFN.
+Failing to do the mapping causes the wrong PFN to be passed to Hyper-V,
+and various errors ensue.
+
+Fix this by removing the duplicate adjustment in netvsc_dma_map() and
+netvsc_dma_unmap().
+
+Fixes: 846da38de0e8 ("net: netvsc: Add Isolation VM support for netvsc driver")
+Cc: stable@vger.kernel.org
+Signed-off-by: Michael Kelley <mikelley@microsoft.com>
+Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
+Link: https://lore.kernel.org/r/1675135986-254490-1-git-send-email-mikelley@microsoft.com
+Signed-off-by: Paolo Abeni <pabeni@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/net/hyperv/netvsc.c | 9 ++-------
+ 1 file changed, 2 insertions(+), 7 deletions(-)
+
+--- a/drivers/net/hyperv/netvsc.c
++++ b/drivers/net/hyperv/netvsc.c
+@@ -987,9 +987,6 @@ static void netvsc_copy_to_send_buf(stru
+ void netvsc_dma_unmap(struct hv_device *hv_dev,
+ struct hv_netvsc_packet *packet)
+ {
+- u32 page_count = packet->cp_partial ?
+- packet->page_buf_cnt - packet->rmsg_pgcnt :
+- packet->page_buf_cnt;
+ int i;
+
+ if (!hv_is_isolation_supported())
+@@ -998,7 +995,7 @@ void netvsc_dma_unmap(struct hv_device *
+ if (!packet->dma_range)
+ return;
+
+- for (i = 0; i < page_count; i++)
++ for (i = 0; i < packet->page_buf_cnt; i++)
+ dma_unmap_single(&hv_dev->device, packet->dma_range[i].dma,
+ packet->dma_range[i].mapping_size,
+ DMA_TO_DEVICE);
+@@ -1028,9 +1025,7 @@ static int netvsc_dma_map(struct hv_devi
+ struct hv_netvsc_packet *packet,
+ struct hv_page_buffer *pb)
+ {
+- u32 page_count = packet->cp_partial ?
+- packet->page_buf_cnt - packet->rmsg_pgcnt :
+- packet->page_buf_cnt;
++ u32 page_count = packet->page_buf_cnt;
+ dma_addr_t dma;
+ int i;
+
--- /dev/null
+From cbd3a0153cd18a2cbef6bf3cf31bb406c3fc9f55 Mon Sep 17 00:00:00 2001
+From: Xiongfeng Wang <wangxiongfeng2@huawei.com>
+Date: Tue, 29 Nov 2022 10:03:16 +0800
+Subject: iio: adc: berlin2-adc: Add missing of_node_put() in error path
+
+From: Xiongfeng Wang <wangxiongfeng2@huawei.com>
+
+commit cbd3a0153cd18a2cbef6bf3cf31bb406c3fc9f55 upstream.
+
+of_get_parent() will return a device_node pointer with refcount
+incremented. We need to use of_node_put() on it when done. Add the
+missing of_node_put() in the error path of berlin2_adc_probe();
+
+Fixes: 70f1937911ca ("iio: adc: add support for Berlin")
+Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
+Link: https://lore.kernel.org/r/20221129020316.191731-1-wangxiongfeng2@huawei.com
+Cc: <Stable@vger.kernel.org>
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/iio/adc/berlin2-adc.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+--- a/drivers/iio/adc/berlin2-adc.c
++++ b/drivers/iio/adc/berlin2-adc.c
+@@ -298,8 +298,10 @@ static int berlin2_adc_probe(struct plat
+ int ret;
+
+ indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*priv));
+- if (!indio_dev)
++ if (!indio_dev) {
++ of_node_put(parent_np);
+ return -ENOMEM;
++ }
+
+ priv = iio_priv(indio_dev);
+
--- /dev/null
+From f804bd0dc28683a93a60f271aaefb2fc5b0853dd Mon Sep 17 00:00:00 2001
+From: Andreas Kemnade <andreas@kemnade.info>
+Date: Thu, 1 Dec 2022 19:16:35 +0100
+Subject: iio:adc:twl6030: Enable measurements of VUSB, VBAT and others
+
+From: Andreas Kemnade <andreas@kemnade.info>
+
+commit f804bd0dc28683a93a60f271aaefb2fc5b0853dd upstream.
+
+Some inputs need to be wired up to produce proper measurements,
+without this change only near zero values are reported.
+
+Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
+Fixes: 1696f36482e70 ("iio: twl6030-gpadc: TWL6030, TWL6032 GPADC driver")
+Link: https://lore.kernel.org/r/20221201181635.3522962-1-andreas@kemnade.info
+Cc: <Stable@vger.kernel.org>
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/iio/adc/twl6030-gpadc.c | 32 ++++++++++++++++++++++++++++++++
+ 1 file changed, 32 insertions(+)
+
+--- a/drivers/iio/adc/twl6030-gpadc.c
++++ b/drivers/iio/adc/twl6030-gpadc.c
+@@ -57,6 +57,18 @@
+ #define TWL6030_GPADCS BIT(1)
+ #define TWL6030_GPADCR BIT(0)
+
++#define USB_VBUS_CTRL_SET 0x04
++#define USB_ID_CTRL_SET 0x06
++
++#define TWL6030_MISC1 0xE4
++#define VBUS_MEAS 0x01
++#define ID_MEAS 0x01
++
++#define VAC_MEAS 0x04
++#define VBAT_MEAS 0x02
++#define BB_MEAS 0x01
++
++
+ /**
+ * struct twl6030_chnl_calib - channel calibration
+ * @gain: slope coefficient for ideal curve
+@@ -927,6 +939,26 @@ static int twl6030_gpadc_probe(struct pl
+ return ret;
+ }
+
++ ret = twl_i2c_write_u8(TWL_MODULE_USB, VBUS_MEAS, USB_VBUS_CTRL_SET);
++ if (ret < 0) {
++ dev_err(dev, "failed to wire up inputs\n");
++ return ret;
++ }
++
++ ret = twl_i2c_write_u8(TWL_MODULE_USB, ID_MEAS, USB_ID_CTRL_SET);
++ if (ret < 0) {
++ dev_err(dev, "failed to wire up inputs\n");
++ return ret;
++ }
++
++ ret = twl_i2c_write_u8(TWL6030_MODULE_ID0,
++ VBAT_MEAS | BB_MEAS | BB_MEAS,
++ TWL6030_MISC1);
++ if (ret < 0) {
++ dev_err(dev, "failed to wire up inputs\n");
++ return ret;
++ }
++
+ indio_dev->name = DRIVER_NAME;
+ indio_dev->info = &twl6030_gpadc_iio_info;
+ indio_dev->modes = INDIO_DIRECT_MODE;
--- /dev/null
+From 6794ed0cfcc6ce737240eccc48b3e8190df36703 Mon Sep 17 00:00:00 2001
+From: Marco Pagani <marpagan@redhat.com>
+Date: Fri, 25 Nov 2022 12:31:12 +0100
+Subject: iio: adc: xilinx-ams: fix devm_krealloc() return value check
+
+From: Marco Pagani <marpagan@redhat.com>
+
+commit 6794ed0cfcc6ce737240eccc48b3e8190df36703 upstream.
+
+The clang-analyzer reported a warning: "Value stored to 'ret'
+is never read".
+
+Fix the return value check if devm_krealloc() fails to resize
+ams_channels.
+
+Fixes: d5c70627a794 ("iio: adc: Add Xilinx AMS driver")
+Signed-off-by: Marco Pagani <marpagan@redhat.com>
+Acked-by: Michal Simek <michal.simek@amd.com>
+Link: https://lore.kernel.org/r/20221125113112.219290-1-marpagan@redhat.com
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/iio/adc/xilinx-ams.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/iio/adc/xilinx-ams.c
++++ b/drivers/iio/adc/xilinx-ams.c
+@@ -1329,7 +1329,7 @@ static int ams_parse_firmware(struct iio
+
+ dev_channels = devm_krealloc(dev, ams_channels, dev_size, GFP_KERNEL);
+ if (!dev_channels)
+- ret = -ENOMEM;
++ return -ENOMEM;
+
+ indio_dev->channels = dev_channels;
+ indio_dev->num_channels = num_channels;
--- /dev/null
+From f7b23d1c35d8b8de1425bdfccaefd01f3b7c9d1c Mon Sep 17 00:00:00 2001
+From: Dmitry Perchanov <dmitry.perchanov@intel.com>
+Date: Wed, 11 Jan 2023 14:22:10 +0200
+Subject: iio: hid: fix the retval in accel_3d_capture_sample
+
+From: Dmitry Perchanov <dmitry.perchanov@intel.com>
+
+commit f7b23d1c35d8b8de1425bdfccaefd01f3b7c9d1c upstream.
+
+Return value should be zero for success. This was forgotten for timestamp
+feature. Verified on RealSense cameras.
+
+Fixes: a96cd0f901ee ("iio: accel: hid-sensor-accel-3d: Add timestamp")
+Signed-off-by: Dmitry Perchanov <dmitry.perchanov@intel.com>
+Link: https://lore.kernel.org/r/a6dc426498221c81fa71045b41adf782ebd42136.camel@intel.com
+Cc: <Stable@vger.kernel.org>
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/iio/accel/hid-sensor-accel-3d.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/drivers/iio/accel/hid-sensor-accel-3d.c
++++ b/drivers/iio/accel/hid-sensor-accel-3d.c
+@@ -280,6 +280,7 @@ static int accel_3d_capture_sample(struc
+ hid_sensor_convert_timestamp(
+ &accel_state->common_attributes,
+ *(int64_t *)raw_data);
++ ret = 0;
+ break;
+ default:
+ break;
--- /dev/null
+From eb50cd5bfdac61627a5026566cf3b90ced7b141c Mon Sep 17 00:00:00 2001
+From: Dmitry Perchanov <dmitry.perchanov@intel.com>
+Date: Wed, 11 Jan 2023 14:24:25 +0200
+Subject: iio: hid: fix the retval in gyro_3d_capture_sample
+
+From: Dmitry Perchanov <dmitry.perchanov@intel.com>
+
+commit eb50cd5bfdac61627a5026566cf3b90ced7b141c upstream.
+
+Return value should be zero for success. This was forgotten for timestamp
+feature. Verified on RealSense cameras.
+
+Fixes: 4648cbd8fb92 ("iio: hid-sensor-gyro-3d: Add timestamp channel")
+Signed-off-by: Dmitry Perchanov <dmitry.perchanov@intel.com>
+Link: https://lore.kernel.org/r/7c1809dc74eb2f58a20595f4d02e76934f8e9219.camel@intel.com
+Cc: <Stable@vger.kernel.org>
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/iio/gyro/hid-sensor-gyro-3d.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
++++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
+@@ -231,6 +231,7 @@ static int gyro_3d_capture_sample(struct
+ gyro_state->timestamp =
+ hid_sensor_convert_timestamp(&gyro_state->common_attributes,
+ *(s64 *)raw_data);
++ ret = 0;
+ break;
+ default:
+ break;
--- /dev/null
+From 9d61c1820598a5ea474576ed55318a6dadee37ed Mon Sep 17 00:00:00 2001
+From: Carlos Song <carlos.song@nxp.com>
+Date: Thu, 8 Dec 2022 15:19:09 +0800
+Subject: iio: imu: fxos8700: fix ACCEL measurement range selection
+
+From: Carlos Song <carlos.song@nxp.com>
+
+commit 9d61c1820598a5ea474576ed55318a6dadee37ed upstream.
+
+When device is in active mode, it fails to set an ACCEL full-scale
+range(2g/4g/8g) in FXOS8700_XYZ_DATA_CFG. This is not align with the
+datasheet, but it is a fxos8700 chip behavior.
+
+Keep the device in standby mode before setting ACCEL full-scale range
+into FXOS8700_XYZ_DATA_CFG in chip initialization phase and setting
+scale phase.
+
+Fixes: 84e5ddd5c46e ("iio: imu: Add support for the FXOS8700 IMU")
+Signed-off-by: Carlos Song <carlos.song@nxp.com>
+Link: https://lore.kernel.org/r/20221208071911.2405922-6-carlos.song@nxp.com
+Cc: <Stable@vger.kernel.org>
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/iio/imu/fxos8700_core.c | 41 +++++++++++++++++++++++++++++++++-------
+ 1 file changed, 34 insertions(+), 7 deletions(-)
+
+--- a/drivers/iio/imu/fxos8700_core.c
++++ b/drivers/iio/imu/fxos8700_core.c
+@@ -345,7 +345,8 @@ static int fxos8700_set_active_mode(stru
+ static int fxos8700_set_scale(struct fxos8700_data *data,
+ enum fxos8700_sensor t, int uscale)
+ {
+- int i;
++ int i, ret, val;
++ bool active_mode;
+ static const int scale_num = ARRAY_SIZE(fxos8700_accel_scale);
+ struct device *dev = regmap_get_device(data->regmap);
+
+@@ -354,6 +355,25 @@ static int fxos8700_set_scale(struct fxo
+ return -EINVAL;
+ }
+
++ /*
++ * When device is in active mode, it failed to set an ACCEL
++ * full-scale range(2g/4g/8g) in FXOS8700_XYZ_DATA_CFG.
++ * This is not align with the datasheet, but it is a fxos8700
++ * chip behavier. Set the device in standby mode before setting
++ * an ACCEL full-scale range.
++ */
++ ret = regmap_read(data->regmap, FXOS8700_CTRL_REG1, &val);
++ if (ret)
++ return ret;
++
++ active_mode = val & FXOS8700_ACTIVE;
++ if (active_mode) {
++ ret = regmap_write(data->regmap, FXOS8700_CTRL_REG1,
++ val & ~FXOS8700_ACTIVE);
++ if (ret)
++ return ret;
++ }
++
+ for (i = 0; i < scale_num; i++)
+ if (fxos8700_accel_scale[i].uscale == uscale)
+ break;
+@@ -361,8 +381,12 @@ static int fxos8700_set_scale(struct fxo
+ if (i == scale_num)
+ return -EINVAL;
+
+- return regmap_write(data->regmap, FXOS8700_XYZ_DATA_CFG,
++ ret = regmap_write(data->regmap, FXOS8700_XYZ_DATA_CFG,
+ fxos8700_accel_scale[i].bits);
++ if (ret)
++ return ret;
++ return regmap_write(data->regmap, FXOS8700_CTRL_REG1,
++ active_mode);
+ }
+
+ static int fxos8700_get_scale(struct fxos8700_data *data,
+@@ -592,14 +616,17 @@ static int fxos8700_chip_init(struct fxo
+ if (ret)
+ return ret;
+
+- /* Max ODR (800Hz individual or 400Hz hybrid), active mode */
+- ret = regmap_write(data->regmap, FXOS8700_CTRL_REG1,
+- FXOS8700_CTRL_ODR_MAX | FXOS8700_ACTIVE);
++ /*
++ * Set max full-scale range (+/-8G) for ACCEL sensor in chip
++ * initialization then activate the device.
++ */
++ ret = regmap_write(data->regmap, FXOS8700_XYZ_DATA_CFG, MODE_8G);
+ if (ret)
+ return ret;
+
+- /* Set for max full-scale range (+/-8G) */
+- return regmap_write(data->regmap, FXOS8700_XYZ_DATA_CFG, MODE_8G);
++ /* Max ODR (800Hz individual or 400Hz hybrid), active mode */
++ return regmap_write(data->regmap, FXOS8700_CTRL_REG1,
++ FXOS8700_CTRL_ODR_MAX | FXOS8700_ACTIVE);
+ }
+
+ static void fxos8700_chip_uninit(void *data)
--- /dev/null
+From eb6d8f8705bc19141bac81d8161461f9e256948a Mon Sep 17 00:00:00 2001
+From: Carlos Song <carlos.song@nxp.com>
+Date: Wed, 18 Jan 2023 15:42:25 +0800
+Subject: iio: imu: fxos8700: fix failed initialization ODR mode assignment
+
+From: Carlos Song <carlos.song@nxp.com>
+
+commit eb6d8f8705bc19141bac81d8161461f9e256948a upstream.
+
+The absence of correct offset leads a failed initialization ODR mode
+assignment.
+
+Select MAX ODR mode as the initialization ODR mode by field mask and
+FIELD_PREP.
+
+Fixes: 84e5ddd5c46e ("iio: imu: Add support for the FXOS8700 IMU")
+Signed-off-by: Carlos Song <carlos.song@nxp.com>
+Link: https://lore.kernel.org/r/20230118074227.1665098-3-carlos.song@nxp.com
+Cc: <Stable@vger.kernel.org>
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/iio/imu/fxos8700_core.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+--- a/drivers/iio/imu/fxos8700_core.c
++++ b/drivers/iio/imu/fxos8700_core.c
+@@ -664,8 +664,10 @@ static int fxos8700_chip_init(struct fxo
+ return ret;
+
+ /* Max ODR (800Hz individual or 400Hz hybrid), active mode */
+- return regmap_write(data->regmap, FXOS8700_CTRL_REG1,
+- FXOS8700_CTRL_ODR_MAX | FXOS8700_ACTIVE);
++ return regmap_update_bits(data->regmap, FXOS8700_CTRL_REG1,
++ FXOS8700_CTRL_ODR_MSK | FXOS8700_ACTIVE,
++ FIELD_PREP(FXOS8700_CTRL_ODR_MSK, FXOS8700_CTRL_ODR_MAX) |
++ FXOS8700_ACTIVE);
+ }
+
+ static void fxos8700_chip_uninit(void *data)
--- /dev/null
+From a53f945879c0cb9de3a4c05a665f5157884b5208 Mon Sep 17 00:00:00 2001
+From: Carlos Song <carlos.song@nxp.com>
+Date: Thu, 8 Dec 2022 15:19:08 +0800
+Subject: iio: imu: fxos8700: fix IMU data bits returned to user space
+
+From: Carlos Song <carlos.song@nxp.com>
+
+commit a53f945879c0cb9de3a4c05a665f5157884b5208 upstream.
+
+ACCEL output data registers contain the X-axis, Y-axis, and Z-axis
+14-bit left-justified sample data and MAGN output data registers
+contain the X-axis, Y-axis, and Z-axis 16-bit sample data. The ACCEL
+raw register output data should be divided by 4 before sent to
+userspace.
+
+Apply a 2 bits signed right shift to the raw data from ACCEL output
+data register but keep that from MAGN sensor as the origin.
+
+Fixes: 84e5ddd5c46e ("iio: imu: Add support for the FXOS8700 IMU")
+Signed-off-by: Carlos Song <carlos.song@nxp.com>
+Link: https://lore.kernel.org/r/20221208071911.2405922-5-carlos.song@nxp.com
+Cc: <Stable@vger.kernel.org>
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/iio/imu/fxos8700_core.c | 28 +++++++++++++++++++++++++++-
+ 1 file changed, 27 insertions(+), 1 deletion(-)
+
+--- a/drivers/iio/imu/fxos8700_core.c
++++ b/drivers/iio/imu/fxos8700_core.c
+@@ -418,6 +418,7 @@ static int fxos8700_get_data(struct fxos
+ int axis, int *val)
+ {
+ u8 base, reg;
++ s16 tmp;
+ int ret;
+ enum fxos8700_sensor type = fxos8700_to_sensor(chan_type);
+
+@@ -432,8 +433,33 @@ static int fxos8700_get_data(struct fxos
+ /* Convert axis to buffer index */
+ reg = axis - IIO_MOD_X;
+
++ /*
++ * Convert to native endianness. The accel data and magn data
++ * are signed, so a forced type conversion is needed.
++ */
++ tmp = be16_to_cpu(data->buf[reg]);
++
++ /*
++ * ACCEL output data registers contain the X-axis, Y-axis, and Z-axis
++ * 14-bit left-justified sample data and MAGN output data registers
++ * contain the X-axis, Y-axis, and Z-axis 16-bit sample data. Apply
++ * a signed 2 bits right shift to the readback raw data from ACCEL
++ * output data register and keep that from MAGN sensor as the origin.
++ * Value should be extended to 32 bit.
++ */
++ switch (chan_type) {
++ case IIO_ACCEL:
++ tmp = tmp >> 2;
++ break;
++ case IIO_MAGN:
++ /* Nothing to do */
++ break;
++ default:
++ return -EINVAL;
++ }
++
+ /* Convert to native endianness */
+- *val = sign_extend32(be16_to_cpu(data->buf[reg]), 15);
++ *val = sign_extend32(tmp, 15);
+
+ return 0;
+ }
--- /dev/null
+From 37a94d86d7050665d6d01378b2c916c28e454f10 Mon Sep 17 00:00:00 2001
+From: Carlos Song <carlos.song@nxp.com>
+Date: Thu, 8 Dec 2022 15:19:07 +0800
+Subject: iio: imu: fxos8700: fix incomplete ACCEL and MAGN channels readback
+
+From: Carlos Song <carlos.song@nxp.com>
+
+commit 37a94d86d7050665d6d01378b2c916c28e454f10 upstream.
+
+The length of ACCEL and MAGN 3-axis channels output data is 6 byte
+individually. However block only read 3 bytes data into buffer from
+ACCEL or MAGN output data registers every time. It causes an incomplete
+ACCEL and MAGN channels readback.
+
+Set correct value count for regmap_bulk_read to get 6 bytes ACCEL and
+MAGN channels readback.
+
+Fixes: 84e5ddd5c46e ("iio: imu: Add support for the FXOS8700 IMU")
+Signed-off-by: Carlos Song <carlos.song@nxp.com>
+Link: https://lore.kernel.org/r/20221208071911.2405922-4-carlos.song@nxp.com
+Cc: <Stable@vger.kernel.org>
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/iio/imu/fxos8700_core.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/iio/imu/fxos8700_core.c
++++ b/drivers/iio/imu/fxos8700_core.c
+@@ -425,7 +425,7 @@ static int fxos8700_get_data(struct fxos
+
+ /* Block read 6 bytes of device output registers to avoid data loss */
+ ret = regmap_bulk_read(data->regmap, base, data->buf,
+- FXOS8700_DATA_BUF_SIZE);
++ sizeof(data->buf));
+ if (ret)
+ return ret;
+
--- /dev/null
+From 78ad6864e9e012cdba7c353d044d21ffcfd5f34b Mon Sep 17 00:00:00 2001
+From: Carlos Song <carlos.song@nxp.com>
+Date: Wed, 18 Jan 2023 15:42:24 +0800
+Subject: iio: imu: fxos8700: fix incorrect ODR mode readback
+
+From: Carlos Song <carlos.song@nxp.com>
+
+commit 78ad6864e9e012cdba7c353d044d21ffcfd5f34b upstream.
+
+The absence of a correct offset leads an incorrect ODR mode
+readback after use a hexadecimal number to mark the value from
+FXOS8700_CTRL_REG1.
+
+Get ODR mode by field mask and FIELD_GET clearly and conveniently.
+And attach other additional fix for keeping the original code logic
+and a good readability.
+
+Fixes: 84e5ddd5c46e ("iio: imu: Add support for the FXOS8700 IMU")
+Signed-off-by: Carlos Song <carlos.song@nxp.com>
+Link: https://lore.kernel.org/r/20230118074227.1665098-2-carlos.song@nxp.com
+Cc: <Stable@vger.kernel.org>
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/iio/imu/fxos8700_core.c | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+--- a/drivers/iio/imu/fxos8700_core.c
++++ b/drivers/iio/imu/fxos8700_core.c
+@@ -10,6 +10,7 @@
+ #include <linux/regmap.h>
+ #include <linux/acpi.h>
+ #include <linux/bitops.h>
++#include <linux/bitfield.h>
+
+ #include <linux/iio/iio.h>
+ #include <linux/iio/sysfs.h>
+@@ -144,9 +145,9 @@
+ #define FXOS8700_NVM_DATA_BNK0 0xa7
+
+ /* Bit definitions for FXOS8700_CTRL_REG1 */
+-#define FXOS8700_CTRL_ODR_MSK 0x38
+ #define FXOS8700_CTRL_ODR_MAX 0x00
+ #define FXOS8700_CTRL_ODR_MIN GENMASK(4, 3)
++#define FXOS8700_CTRL_ODR_MSK GENMASK(5, 3)
+
+ /* Bit definitions for FXOS8700_M_CTRL_REG1 */
+ #define FXOS8700_HMS_MASK GENMASK(1, 0)
+@@ -508,10 +509,9 @@ static int fxos8700_set_odr(struct fxos8
+ if (i >= odr_num)
+ return -EINVAL;
+
+- return regmap_update_bits(data->regmap,
+- FXOS8700_CTRL_REG1,
+- FXOS8700_CTRL_ODR_MSK + FXOS8700_ACTIVE,
+- fxos8700_odr[i].bits << 3 | active_mode);
++ val &= ~FXOS8700_CTRL_ODR_MSK;
++ val |= FIELD_PREP(FXOS8700_CTRL_ODR_MSK, fxos8700_odr[i].bits) | FXOS8700_ACTIVE;
++ return regmap_write(data->regmap, FXOS8700_CTRL_REG1, val);
+ }
+
+ static int fxos8700_get_odr(struct fxos8700_data *data, enum fxos8700_sensor t,
+@@ -524,7 +524,7 @@ static int fxos8700_get_odr(struct fxos8
+ if (ret)
+ return ret;
+
+- val &= FXOS8700_CTRL_ODR_MSK;
++ val = FIELD_GET(FXOS8700_CTRL_ODR_MSK, val);
+
+ for (i = 0; i < odr_num; i++)
+ if (val == fxos8700_odr[i].bits)
--- /dev/null
+From 2acd031347f645871959a799238a7caf6803aa18 Mon Sep 17 00:00:00 2001
+From: Carlos Song <carlos.song@nxp.com>
+Date: Wed, 18 Jan 2023 15:42:27 +0800
+Subject: iio: imu: fxos8700: fix MAGN sensor scale and unit
+
+From: Carlos Song <carlos.song@nxp.com>
+
+commit 2acd031347f645871959a799238a7caf6803aa18 upstream.
+
++/-1200uT is a MAGN sensor full measurement range. Magnetometer scale
+is the magnetic sensitivity parameter. It is referenced as 0.1uT
+according to datasheet and magnetometer channel unit is Gauss in
+sysfs-bus-iio documentation. Gauss and uTesla unit conversion
+relationship as follows: 0.1uT = 0.001Gs.
+
+Set magnetometer scale and available magnetometer scale as fixed 0.001Gs.
+
+Fixes: 84e5ddd5c46e ("iio: imu: Add support for the FXOS8700 IMU")
+Signed-off-by: Carlos Song <carlos.song@nxp.com>
+Link: https://lore.kernel.org/r/20230118074227.1665098-5-carlos.song@nxp.com
+Cc: <Stable@vger.kernel.org>
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/iio/imu/fxos8700_core.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+--- a/drivers/iio/imu/fxos8700_core.c
++++ b/drivers/iio/imu/fxos8700_core.c
+@@ -351,7 +351,7 @@ static int fxos8700_set_scale(struct fxo
+ struct device *dev = regmap_get_device(data->regmap);
+
+ if (t == FXOS8700_MAGN) {
+- dev_err(dev, "Magnetometer scale is locked at 1200uT\n");
++ dev_err(dev, "Magnetometer scale is locked at 0.001Gs\n");
+ return -EINVAL;
+ }
+
+@@ -396,7 +396,7 @@ static int fxos8700_get_scale(struct fxo
+ static const int scale_num = ARRAY_SIZE(fxos8700_accel_scale);
+
+ if (t == FXOS8700_MAGN) {
+- *uscale = 1200; /* Magnetometer is locked at 1200uT */
++ *uscale = 1000; /* Magnetometer is locked at 0.001Gs */
+ return 0;
+ }
+
+@@ -588,7 +588,7 @@ static IIO_CONST_ATTR(in_accel_sampling_
+ static IIO_CONST_ATTR(in_magn_sampling_frequency_available,
+ "1.5625 6.25 12.5 50 100 200 400 800");
+ static IIO_CONST_ATTR(in_accel_scale_available, "0.000244 0.000488 0.000976");
+-static IIO_CONST_ATTR(in_magn_scale_available, "0.000001200");
++static IIO_CONST_ATTR(in_magn_scale_available, "0.001000");
+
+ static struct attribute *fxos8700_attrs[] = {
+ &iio_const_attr_in_accel_sampling_frequency_available.dev_attr.attr,
--- /dev/null
+From 429e1e8ec696e0e7a0742904e3dc2f83b7b23dfb Mon Sep 17 00:00:00 2001
+From: Carlos Song <carlos.song@nxp.com>
+Date: Thu, 8 Dec 2022 15:19:05 +0800
+Subject: iio: imu: fxos8700: fix map label of channel type to MAGN sensor
+
+From: Carlos Song <carlos.song@nxp.com>
+
+commit 429e1e8ec696e0e7a0742904e3dc2f83b7b23dfb upstream.
+
+FXOS8700 is an IMU sensor with ACCEL sensor and MAGN sensor.
+Sensor type is indexed by corresponding channel type in a switch.
+IIO_ANGL_VEL channel type mapped to MAGN sensor has caused confusion.
+
+Fix the mapping label of "IIO_MAGN" channel type instead of
+"IIO_ANGL_VEL" channel type to MAGN sensor.
+
+Fixes: 84e5ddd5c46e ("iio: imu: Add support for the FXOS8700 IMU")
+Signed-off-by: Carlos Song <carlos.song@nxp.com>
+Link: https://lore.kernel.org/r/20221208071911.2405922-2-carlos.song@nxp.com
+Cc: <Stable@vger.kernel.org>
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/iio/imu/fxos8700_core.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/iio/imu/fxos8700_core.c
++++ b/drivers/iio/imu/fxos8700_core.c
+@@ -320,7 +320,7 @@ static enum fxos8700_sensor fxos8700_to_
+ switch (iio_type) {
+ case IIO_ACCEL:
+ return FXOS8700_ACCEL;
+- case IIO_ANGL_VEL:
++ case IIO_MAGN:
+ return FXOS8700_MAGN;
+ default:
+ return -EINVAL;
--- /dev/null
+From c68b44bc7d9b1469774a1c985ee71d2cbc5ebef5 Mon Sep 17 00:00:00 2001
+From: Carlos Song <carlos.song@nxp.com>
+Date: Thu, 8 Dec 2022 15:19:06 +0800
+Subject: iio: imu: fxos8700: fix swapped ACCEL and MAGN channels readback
+
+From: Carlos Song <carlos.song@nxp.com>
+
+commit c68b44bc7d9b1469774a1c985ee71d2cbc5ebef5 upstream.
+
+Because ACCEL and MAGN channels data register base address is
+swapped the accelerometer and magnetometer channels readback is
+swapped.
+
+Fixes: 84e5ddd5c46e ("iio: imu: Add support for the FXOS8700 IMU")
+Signed-off-by: Carlos Song <carlos.song@nxp.com>
+Link: https://lore.kernel.org/r/20221208071911.2405922-3-carlos.song@nxp.com
+Cc: <Stable@vger.kernel.org>
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/iio/imu/fxos8700_core.c | 17 +++++++++++++++--
+ 1 file changed, 15 insertions(+), 2 deletions(-)
+
+--- a/drivers/iio/imu/fxos8700_core.c
++++ b/drivers/iio/imu/fxos8700_core.c
+@@ -420,9 +420,22 @@ static int fxos8700_get_data(struct fxos
+ u8 base, reg;
+ s16 tmp;
+ int ret;
+- enum fxos8700_sensor type = fxos8700_to_sensor(chan_type);
+
+- base = type ? FXOS8700_OUT_X_MSB : FXOS8700_M_OUT_X_MSB;
++ /*
++ * Different register base addresses varies with channel types.
++ * This bug hasn't been noticed before because using an enum is
++ * really hard to read. Use an a switch statement to take over that.
++ */
++ switch (chan_type) {
++ case IIO_ACCEL:
++ base = FXOS8700_OUT_X_MSB;
++ break;
++ case IIO_MAGN:
++ base = FXOS8700_M_OUT_X_MSB;
++ break;
++ default:
++ return -EINVAL;
++ }
+
+ /* Block read 6 bytes of device output registers to avoid data loss */
+ ret = regmap_bulk_read(data->regmap, base, data->buf,
--- /dev/null
+From ff5e2cd92ffda9a25ffa2cbdb3a0cf17650172a6 Mon Sep 17 00:00:00 2001
+From: Carlos Song <carlos.song@nxp.com>
+Date: Wed, 18 Jan 2023 15:42:26 +0800
+Subject: iio: imu: fxos8700: remove definition FXOS8700_CTRL_ODR_MIN
+
+From: Carlos Song <carlos.song@nxp.com>
+
+commit ff5e2cd92ffda9a25ffa2cbdb3a0cf17650172a6 upstream.
+
+FXOS8700_CTRL_ODR_MIN is not used but value is probably wrong.
+
+Remove it for a good readability.
+
+Fixes: 84e5ddd5c46e ("iio: imu: Add support for the FXOS8700 IMU")
+Signed-off-by: Carlos Song <carlos.song@nxp.com>
+Link: https://lore.kernel.org/r/20230118074227.1665098-4-carlos.song@nxp.com
+Cc: <Stable@vger.kernel.org>
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/iio/imu/fxos8700_core.c | 1 -
+ 1 file changed, 1 deletion(-)
+
+--- a/drivers/iio/imu/fxos8700_core.c
++++ b/drivers/iio/imu/fxos8700_core.c
+@@ -146,7 +146,6 @@
+
+ /* Bit definitions for FXOS8700_CTRL_REG1 */
+ #define FXOS8700_CTRL_ODR_MAX 0x00
+-#define FXOS8700_CTRL_ODR_MIN GENMASK(4, 3)
+ #define FXOS8700_CTRL_ODR_MSK GENMASK(5, 3)
+
+ /* Bit definitions for FXOS8700_M_CTRL_REG1 */
--- /dev/null
+From 0fc3562a993c3dc41d1177b3983d9300d0db1d4d Mon Sep 17 00:00:00 2001
+From: Frank Li <Frank.Li@nxp.com>
+Date: Thu, 1 Dec 2022 09:01:10 -0500
+Subject: iio: imx8qxp-adc: fix irq flood when call imx8qxp_adc_read_raw()
+
+From: Frank Li <Frank.Li@nxp.com>
+
+commit 0fc3562a993c3dc41d1177b3983d9300d0db1d4d upstream.
+
+irq flood happen when run
+ cat /sys/bus/iio/devices/iio:device0/in_voltage1_raw
+
+imx8qxp_adc_read_raw()
+{
+ ...
+ enable irq
+ /* adc start */
+ writel(1, adc->regs + IMX8QXP_ADR_ADC_SWTRIG);
+ ^^^^ trigger irq flood.
+ wait_for_completion_interruptible_timeout();
+ readl(adc->regs + IMX8QXP_ADR_ADC_RESFIFO);
+ ^^^^ clear irq here.
+ ...
+}
+
+There is only FIFO watermark interrupt at this ADC controller.
+IRQ line will be assert until software read data from FIFO.
+So IRQ flood happen during wait_for_completion_interruptible_timeout().
+
+Move FIFO read into irq handle to avoid irq flood.
+
+Fixes: 1e23dcaa1a9f ("iio: imx8qxp-adc: Add driver support for NXP IMX8QXP ADC")
+Cc: stable@vger.kernel.org
+
+Signed-off-by: Frank Li <Frank.Li@nxp.com>
+Reviewed-by: Cai Huoqing <cai.huoqing@linux.dev>
+Reviewed-by: Haibo Chen <haibo.chen@nxp.com>
+Link: https://lore.kernel.org/r/20221201140110.2653501-1-Frank.Li@nxp.com
+Cc: <Stable@vger.kernel.org>
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/iio/adc/imx8qxp-adc.c | 11 +++++++++--
+ 1 file changed, 9 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/iio/adc/imx8qxp-adc.c b/drivers/iio/adc/imx8qxp-adc.c
+index 36777b827165..f5a0fc9e64c5 100644
+--- a/drivers/iio/adc/imx8qxp-adc.c
++++ b/drivers/iio/adc/imx8qxp-adc.c
+@@ -86,6 +86,8 @@
+
+ #define IMX8QXP_ADC_TIMEOUT msecs_to_jiffies(100)
+
++#define IMX8QXP_ADC_MAX_FIFO_SIZE 16
++
+ struct imx8qxp_adc {
+ struct device *dev;
+ void __iomem *regs;
+@@ -95,6 +97,7 @@ struct imx8qxp_adc {
+ /* Serialise ADC channel reads */
+ struct mutex lock;
+ struct completion completion;
++ u32 fifo[IMX8QXP_ADC_MAX_FIFO_SIZE];
+ };
+
+ #define IMX8QXP_ADC_CHAN(_idx) { \
+@@ -238,8 +241,7 @@ static int imx8qxp_adc_read_raw(struct iio_dev *indio_dev,
+ return ret;
+ }
+
+- *val = FIELD_GET(IMX8QXP_ADC_RESFIFO_VAL_MASK,
+- readl(adc->regs + IMX8QXP_ADR_ADC_RESFIFO));
++ *val = adc->fifo[0];
+
+ mutex_unlock(&adc->lock);
+ return IIO_VAL_INT;
+@@ -265,10 +267,15 @@ static irqreturn_t imx8qxp_adc_isr(int irq, void *dev_id)
+ {
+ struct imx8qxp_adc *adc = dev_id;
+ u32 fifo_count;
++ int i;
+
+ fifo_count = FIELD_GET(IMX8QXP_ADC_FCTRL_FCOUNT_MASK,
+ readl(adc->regs + IMX8QXP_ADR_ADC_FCTRL));
+
++ for (i = 0; i < fifo_count; i++)
++ adc->fifo[i] = FIELD_GET(IMX8QXP_ADC_RESFIFO_VAL_MASK,
++ readl_relaxed(adc->regs + IMX8QXP_ADR_ADC_RESFIFO));
++
+ if (fifo_count)
+ complete(&adc->completion);
+
+--
+2.39.1
+
--- /dev/null
+From ee3c5b644a0fdcfed27515a39fb2dd3a016704c1 Mon Sep 17 00:00:00 2001
+From: Kai-Heng Feng <kai.heng.feng@canonical.com>
+Date: Thu, 19 Jan 2023 01:04:22 +0800
+Subject: iio: light: cm32181: Fix PM support on system with 2 I2C resources
+
+From: Kai-Heng Feng <kai.heng.feng@canonical.com>
+
+commit ee3c5b644a0fdcfed27515a39fb2dd3a016704c1 upstream.
+
+Commit c1e62062ff54 ("iio: light: cm32181: Handle CM3218 ACPI devices
+with 2 I2C resources") creates a second client for the actual I2C
+address, but the "struct device" passed to PM ops is the first I2C
+client that can't talk to the sensor.
+
+That means the I2C transfers in both suspend and resume routines can
+fail and blocking the whole suspend process.
+
+Instead of using the first client for I2C transfer, use the I2C client
+stored in the cm32181 private struct so the PM ops can get the correct
+I2C client to really talk to the sensor device.
+
+Fixes: 68c1b3dd5c48 ("iio: light: cm32181: Add PM support")
+BugLink: https://bugs.launchpad.net/bugs/1988346
+Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2152281
+Tested-by: Wahaj <wahajaved@protonmail.com>
+Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
+Reviewed-by: Hans de Goede <hdegoede@redhat.com>
+Link: https://lore.kernel.org/r/20230118170422.339619-1-kai.heng.feng@canonical.com
+Cc: <Stable@vger.kernel.org>
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/iio/light/cm32181.c | 9 +++++----
+ 1 file changed, 5 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/iio/light/cm32181.c b/drivers/iio/light/cm32181.c
+index 001055d09750..b1674a5bfa36 100644
+--- a/drivers/iio/light/cm32181.c
++++ b/drivers/iio/light/cm32181.c
+@@ -440,6 +440,8 @@ static int cm32181_probe(struct i2c_client *client)
+ if (!indio_dev)
+ return -ENOMEM;
+
++ i2c_set_clientdata(client, indio_dev);
++
+ /*
+ * Some ACPI systems list 2 I2C resources for the CM3218 sensor, the
+ * SMBus Alert Response Address (ARA, 0x0c) and the actual I2C address.
+@@ -460,8 +462,6 @@ static int cm32181_probe(struct i2c_client *client)
+ return PTR_ERR(client);
+ }
+
+- i2c_set_clientdata(client, indio_dev);
+-
+ cm32181 = iio_priv(indio_dev);
+ cm32181->client = client;
+ cm32181->dev = dev;
+@@ -490,7 +490,8 @@ static int cm32181_probe(struct i2c_client *client)
+
+ static int cm32181_suspend(struct device *dev)
+ {
+- struct i2c_client *client = to_i2c_client(dev);
++ struct cm32181_chip *cm32181 = iio_priv(dev_get_drvdata(dev));
++ struct i2c_client *client = cm32181->client;
+
+ return i2c_smbus_write_word_data(client, CM32181_REG_ADDR_CMD,
+ CM32181_CMD_ALS_DISABLE);
+@@ -498,8 +499,8 @@ static int cm32181_suspend(struct device *dev)
+
+ static int cm32181_resume(struct device *dev)
+ {
+- struct i2c_client *client = to_i2c_client(dev);
+ struct cm32181_chip *cm32181 = iio_priv(dev_get_drvdata(dev));
++ struct i2c_client *client = cm32181->client;
+
+ return i2c_smbus_write_word_data(client, CM32181_REG_ADDR_CMD,
+ cm32181->conf_regs[CM32181_REG_ADDR_CMD]);
+--
+2.39.1
+
--- /dev/null
+From 29de68c2b32ce58d64dea496d281e25ad0f551bd Mon Sep 17 00:00:00 2001
+From: Natalia Petrova <n.petrova@fintech.ru>
+Date: Wed, 25 Jan 2023 16:48:31 +0300
+Subject: net: qrtr: free memory on error path in radix_tree_insert()
+
+From: Natalia Petrova <n.petrova@fintech.ru>
+
+commit 29de68c2b32ce58d64dea496d281e25ad0f551bd upstream.
+
+Function radix_tree_insert() returns errors if the node hasn't
+been initialized and added to the tree.
+
+"kfree(node)" and return value "NULL" of node_get() help
+to avoid using unclear node in other calls.
+
+Found by Linux Verification Center (linuxtesting.org) with SVACE.
+
+Cc: <stable@vger.kernel.org> # 5.7
+Fixes: 0c2204a4ad71 ("net: qrtr: Migrate nameservice to kernel from userspace")
+Signed-off-by: Natalia Petrova <n.petrova@fintech.ru>
+Reviewed-by: Simon Horman <simon.horman@corigine.com>
+Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
+Link: https://lore.kernel.org/r/20230125134831.8090-1-n.petrova@fintech.ru
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/qrtr/ns.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+--- a/net/qrtr/ns.c
++++ b/net/qrtr/ns.c
+@@ -83,7 +83,10 @@ static struct qrtr_node *node_get(unsign
+
+ node->id = node_id;
+
+- radix_tree_insert(&nodes, node_id, node);
++ if (radix_tree_insert(&nodes, node_id, node)) {
++ kfree(node);
++ return NULL;
++ }
+
+ return node;
+ }
--- /dev/null
+From b0576ade3aaf24b376ea1a4406ae138e2a22b0c0 Mon Sep 17 00:00:00 2001
+From: Jiasheng Jiang <jiasheng@iscas.ac.cn>
+Date: Fri, 27 Jan 2023 10:40:06 +0000
+Subject: nvmem: brcm_nvram: Add check for kzalloc
+
+From: Jiasheng Jiang <jiasheng@iscas.ac.cn>
+
+commit b0576ade3aaf24b376ea1a4406ae138e2a22b0c0 upstream.
+
+Add the check for the return value of kzalloc in order to avoid
+NULL pointer dereference.
+
+Fixes: 6e977eaa8280 ("nvmem: brcm_nvram: parse NVRAM content into NVMEM cells")
+Cc: stable@vger.kernel.org
+Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
+Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
+Link: https://lore.kernel.org/r/20230127104015.23839-2-srinivas.kandagatla@linaro.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/nvmem/brcm_nvram.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/drivers/nvmem/brcm_nvram.c
++++ b/drivers/nvmem/brcm_nvram.c
+@@ -97,6 +97,9 @@ static int brcm_nvram_parse(struct brcm_
+ len = le32_to_cpu(header.len);
+
+ data = kzalloc(len, GFP_KERNEL);
++ if (!data)
++ return -ENOMEM;
++
+ memcpy_fromio(data, priv->base, len);
+ data[len - 1] = '\0';
+
--- /dev/null
+From 1ca7fca349316231bbaa68d16f819a08d683c5a7 Mon Sep 17 00:00:00 2001
+From: Johan Hovold <johan+linaro@kernel.org>
+Date: Fri, 27 Jan 2023 10:40:15 +0000
+Subject: nvmem: qcom-spmi-sdam: fix module autoloading
+
+From: Johan Hovold <johan+linaro@kernel.org>
+
+commit 1ca7fca349316231bbaa68d16f819a08d683c5a7 upstream.
+
+Add the missing module device table so that the driver can be autoloaded
+when built as a module.
+
+Fixes: 40ce9798794f ("nvmem: add QTI SDAM driver")
+Cc: stable@vger.kernel.org # 5.6
+Reviewed-by: Bjorn Andersson <andersson@kernel.org>
+Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
+Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
+Link: https://lore.kernel.org/r/20230127104015.23839-11-srinivas.kandagatla@linaro.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/nvmem/qcom-spmi-sdam.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/drivers/nvmem/qcom-spmi-sdam.c b/drivers/nvmem/qcom-spmi-sdam.c
+index 4fcb63507ecd..8499892044b7 100644
+--- a/drivers/nvmem/qcom-spmi-sdam.c
++++ b/drivers/nvmem/qcom-spmi-sdam.c
+@@ -166,6 +166,7 @@ static const struct of_device_id sdam_match_table[] = {
+ { .compatible = "qcom,spmi-sdam" },
+ {},
+ };
++MODULE_DEVICE_TABLE(of, sdam_match_table);
+
+ static struct platform_driver sdam_driver = {
+ .driver = {
+--
+2.39.1
+
--- /dev/null
+From c151d5ed8e8fe0474bd61dce7f2076ca5916c683 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 27 Jan 2023 10:40:07 +0000
+Subject: nvmem: sunxi_sid: Always use 32-bit MMIO reads
+
+From: Samuel Holland <samuel@sholland.org>
+
+commit c151d5ed8e8fe0474bd61dce7f2076ca5916c683 upstream.
+
+The SID SRAM on at least some SoCs (A64 and D1) returns different values
+when read with bus cycles narrower than 32 bits. This is not immediately
+obvious, because memcpy_fromio() uses word-size accesses as long as
+enough data is being copied.
+
+The vendor driver always uses 32-bit MMIO reads, so do the same here.
+This is faster than the register-based method, which is currently used
+as a workaround on A64. And it fixes the values returned on D1, where
+the SRAM method was being used.
+
+The special case for the last word is needed to maintain .word_size == 1
+for sysfs ABI compatibility, as noted previously in commit de2a3eaea552
+("nvmem: sunxi_sid: Optimize register read-out method").
+
+Fixes: 07ae4fde9efa ("nvmem: sunxi_sid: Add support for D1 variant")
+Cc: stable@vger.kernel.org
+Tested-by: Heiko Stuebner <heiko@sntech.de>
+Signed-off-by: Samuel Holland <samuel@sholland.org>
+Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
+Link: https://lore.kernel.org/r/20230127104015.23839-3-srinivas.kandagatla@linaro.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/nvmem/sunxi_sid.c | 15 ++++++++++++++-
+ 1 file changed, 14 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/nvmem/sunxi_sid.c b/drivers/nvmem/sunxi_sid.c
+index 5750e1f4bcdb..92dfe4cb10e3 100644
+--- a/drivers/nvmem/sunxi_sid.c
++++ b/drivers/nvmem/sunxi_sid.c
+@@ -41,8 +41,21 @@ static int sunxi_sid_read(void *context, unsigned int offset,
+ void *val, size_t bytes)
+ {
+ struct sunxi_sid *sid = context;
++ u32 word;
++
++ /* .stride = 4 so offset is guaranteed to be aligned */
++ __ioread32_copy(val, sid->base + sid->value_offset + offset, bytes / 4);
+
+- memcpy_fromio(val, sid->base + sid->value_offset + offset, bytes);
++ val += round_down(bytes, 4);
++ offset += round_down(bytes, 4);
++ bytes = bytes % 4;
++
++ if (!bytes)
++ return 0;
++
++ /* Handle any trailing bytes */
++ word = readl_relaxed(sid->base + sid->value_offset + offset);
++ memcpy(val, &word, bytes);
+
+ return 0;
+ }
+--
+2.39.1
+
--- /dev/null
+From 5d1335dabb3c493a3d6d5b233953b6ac7b6c1ff2 Mon Sep 17 00:00:00 2001
+From: Helge Deller <deller@gmx.de>
+Date: Mon, 19 Dec 2022 20:56:36 +0100
+Subject: parisc: Fix return code of pdc_iodc_print()
+
+From: Helge Deller <deller@gmx.de>
+
+commit 5d1335dabb3c493a3d6d5b233953b6ac7b6c1ff2 upstream.
+
+There is an off-by-one if the printed string includes a new-line
+char.
+
+Cc: stable@vger.kernel.org
+Signed-off-by: Helge Deller <deller@gmx.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/parisc/kernel/firmware.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+--- a/arch/parisc/kernel/firmware.c
++++ b/arch/parisc/kernel/firmware.c
+@@ -1303,7 +1303,7 @@ static char iodc_dbuf[4096] __page_align
+ */
+ int pdc_iodc_print(const unsigned char *str, unsigned count)
+ {
+- unsigned int i;
++ unsigned int i, found = 0;
+ unsigned long flags;
+
+ count = min_t(unsigned int, count, sizeof(iodc_dbuf));
+@@ -1315,6 +1315,7 @@ int pdc_iodc_print(const unsigned char *
+ iodc_dbuf[i+0] = '\r';
+ iodc_dbuf[i+1] = '\n';
+ i += 2;
++ found = 1;
+ goto print;
+ default:
+ iodc_dbuf[i] = str[i];
+@@ -1330,7 +1331,7 @@ print:
+ __pa(pdc_result), 0, __pa(iodc_dbuf), i, 0);
+ spin_unlock_irqrestore(&pdc_lock, flags);
+
+- return i;
++ return i - found;
+ }
+
+ #if !defined(BOOTLOADER)
--- /dev/null
+From 3f0c17809a098d3f0c1ec83f1fb3ca61638d3dcd Mon Sep 17 00:00:00 2001
+From: Helge Deller <deller@gmx.de>
+Date: Wed, 1 Feb 2023 11:04:06 +0100
+Subject: parisc: Replace hardcoded value with PRIV_USER constant in ptrace.c
+
+From: Helge Deller <deller@gmx.de>
+
+commit 3f0c17809a098d3f0c1ec83f1fb3ca61638d3dcd upstream.
+
+Prefer usage of the PRIV_USER constant over the hard-coded value to set
+the lowest 2 bits for the userspace privilege.
+
+Signed-off-by: Helge Deller <deller@gmx.de>
+Cc: stable@vger.kernel.org # 5.16+
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/parisc/kernel/ptrace.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+--- a/arch/parisc/kernel/ptrace.c
++++ b/arch/parisc/kernel/ptrace.c
+@@ -166,7 +166,7 @@ long arch_ptrace(struct task_struct *chi
+ addr >= sizeof(struct pt_regs))
+ break;
+ if (addr == PT_IAOQ0 || addr == PT_IAOQ1) {
+- data |= 3; /* ensure userspace privilege */
++ data |= PRIV_USER; /* ensure userspace privilege */
+ }
+ if ((addr >= PT_GR1 && addr <= PT_GR31) ||
+ addr == PT_IAOQ0 || addr == PT_IAOQ1 ||
+@@ -285,7 +285,7 @@ long compat_arch_ptrace(struct task_stru
+ if (addr >= sizeof(struct pt_regs))
+ break;
+ if (addr == PT_IAOQ0+4 || addr == PT_IAOQ1+4) {
+- data |= 3; /* ensure userspace privilege */
++ data |= PRIV_USER; /* ensure userspace privilege */
+ }
+ if (addr >= PT_FR0 && addr <= PT_FR31 + 4) {
+ /* Special case, fp regs are 64 bits anyway */
+@@ -483,7 +483,7 @@ static void set_reg(struct pt_regs *regs
+ case RI(iaoq[0]):
+ case RI(iaoq[1]):
+ /* set 2 lowest bits to ensure userspace privilege: */
+- regs->iaoq[num - RI(iaoq[0])] = val | 3;
++ regs->iaoq[num - RI(iaoq[0])] = val | PRIV_USER;
+ return;
+ case RI(sar): regs->sar = val;
+ return;
--- /dev/null
+From 316f1f42b5cc1d95124c1f0387c867c1ba7b6d0e Mon Sep 17 00:00:00 2001
+From: Helge Deller <deller@gmx.de>
+Date: Wed, 1 Feb 2023 16:41:54 +0100
+Subject: parisc: Wire up PTRACE_GETREGS/PTRACE_SETREGS for compat case
+
+From: Helge Deller <deller@gmx.de>
+
+commit 316f1f42b5cc1d95124c1f0387c867c1ba7b6d0e upstream.
+
+Wire up the missing ptrace requests PTRACE_GETREGS, PTRACE_SETREGS,
+PTRACE_GETFPREGS and PTRACE_SETFPREGS when running 32-bit applications
+on 64-bit kernels.
+
+Signed-off-by: Helge Deller <deller@gmx.de>
+Cc: stable@vger.kernel.org # 4.7+
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/parisc/kernel/ptrace.c | 15 +++++++++++++--
+ 1 file changed, 13 insertions(+), 2 deletions(-)
+
+--- a/arch/parisc/kernel/ptrace.c
++++ b/arch/parisc/kernel/ptrace.c
+@@ -126,6 +126,12 @@ long arch_ptrace(struct task_struct *chi
+ unsigned long tmp;
+ long ret = -EIO;
+
++ unsigned long user_regs_struct_size = sizeof(struct user_regs_struct);
++#ifdef CONFIG_64BIT
++ if (is_compat_task())
++ user_regs_struct_size /= 2;
++#endif
++
+ switch (request) {
+
+ /* Read the word at location addr in the USER area. For ptraced
+@@ -181,14 +187,14 @@ long arch_ptrace(struct task_struct *chi
+ return copy_regset_to_user(child,
+ task_user_regset_view(current),
+ REGSET_GENERAL,
+- 0, sizeof(struct user_regs_struct),
++ 0, user_regs_struct_size,
+ datap);
+
+ case PTRACE_SETREGS: /* Set all gp regs in the child. */
+ return copy_regset_from_user(child,
+ task_user_regset_view(current),
+ REGSET_GENERAL,
+- 0, sizeof(struct user_regs_struct),
++ 0, user_regs_struct_size,
+ datap);
+
+ case PTRACE_GETFPREGS: /* Get the child FPU state. */
+@@ -302,6 +308,11 @@ long compat_arch_ptrace(struct task_stru
+ }
+ }
+ break;
++ case PTRACE_GETREGS:
++ case PTRACE_SETREGS:
++ case PTRACE_GETFPREGS:
++ case PTRACE_SETFPREGS:
++ return arch_ptrace(child, request, addr, data);
+
+ default:
+ ret = compat_ptrace_request(child, request, addr, data);
--- /dev/null
+From 2f394c0e7d1129a35156e492bc8f445fb20f43ac Mon Sep 17 00:00:00 2001
+From: Andreas Schwab <schwab@suse.de>
+Date: Wed, 1 Feb 2023 10:29:45 +0100
+Subject: riscv: disable generation of unwind tables
+
+From: Andreas Schwab <schwab@suse.de>
+
+commit 2f394c0e7d1129a35156e492bc8f445fb20f43ac upstream.
+
+GCC 13 will enable -fasynchronous-unwind-tables by default on riscv. In
+the kernel, we don't have any use for unwind tables yet, so disable them.
+More importantly, the .eh_frame section brings relocations
+(R_RISC_32_PCREL, R_RISCV_SET{6,8,16}, R_RISCV_SUB{6,8,16}) into modules
+that we are not prepared to handle.
+
+Signed-off-by: Andreas Schwab <schwab@suse.de>
+Link: https://lore.kernel.org/r/mvmzg9xybqu.fsf@suse.de
+Cc: stable@vger.kernel.org
+Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/riscv/Makefile | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/arch/riscv/Makefile
++++ b/arch/riscv/Makefile
+@@ -80,6 +80,9 @@ ifeq ($(CONFIG_PERF_EVENTS),y)
+ KBUILD_CFLAGS += -fno-omit-frame-pointer
+ endif
+
++# Avoid generating .eh_frame sections.
++KBUILD_CFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables
++
+ KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-relax)
+ KBUILD_AFLAGS_MODULE += $(call as-option,-Wa$(comma)-mno-relax)
+
--- /dev/null
+From 101ca8d05913b7d1e6e8b9dd792193d4082fff86 Mon Sep 17 00:00:00 2001
+From: Shanker Donthineni <sdonthineni@nvidia.com>
+Date: Mon, 2 Jan 2023 17:06:30 -0600
+Subject: rtc: efi: Enable SET/GET WAKEUP services as optional
+
+From: Shanker Donthineni <sdonthineni@nvidia.com>
+
+commit 101ca8d05913b7d1e6e8b9dd792193d4082fff86 upstream.
+
+The current implementation of rtc-efi is expecting all the 4
+time services GET{SET}_TIME{WAKEUP} must be supported by UEFI
+firmware. As per the EFI_RT_PROPERTIES_TABLE, the platform
+specific implementations can choose to enable selective time
+services based on the RTC device capabilities.
+
+This patch does the following changes to provide GET/SET RTC
+services on platforms that do not support the WAKEUP feature.
+
+1) Relax time services cap check when creating a platform device.
+2) Clear RTC_FEATURE_ALARM bit in the absence of WAKEUP services.
+3) Conditional alarm entries in '/proc/driver/rtc'.
+
+Cc: <stable@vger.kernel.org> # v6.0+
+Signed-off-by: Shanker Donthineni <sdonthineni@nvidia.com>
+Link: https://lore.kernel.org/r/20230102230630.192911-1-sdonthineni@nvidia.com
+Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/rtc/rtc-efi.c | 48 +++++++++++++++++++++++++++---------------------
+ include/linux/efi.h | 3 ++-
+ 2 files changed, 29 insertions(+), 22 deletions(-)
+
+--- a/drivers/rtc/rtc-efi.c
++++ b/drivers/rtc/rtc-efi.c
+@@ -188,9 +188,10 @@ static int efi_set_time(struct device *d
+
+ static int efi_procfs(struct device *dev, struct seq_file *seq)
+ {
+- efi_time_t eft, alm;
+- efi_time_cap_t cap;
+- efi_bool_t enabled, pending;
++ efi_time_t eft, alm;
++ efi_time_cap_t cap;
++ efi_bool_t enabled, pending;
++ struct rtc_device *rtc = dev_get_drvdata(dev);
+
+ memset(&eft, 0, sizeof(eft));
+ memset(&alm, 0, sizeof(alm));
+@@ -213,23 +214,25 @@ static int efi_procfs(struct device *dev
+ /* XXX fixme: convert to string? */
+ seq_printf(seq, "Timezone\t: %u\n", eft.timezone);
+
+- seq_printf(seq,
+- "Alarm Time\t: %u:%u:%u.%09u\n"
+- "Alarm Date\t: %u-%u-%u\n"
+- "Alarm Daylight\t: %u\n"
+- "Enabled\t\t: %s\n"
+- "Pending\t\t: %s\n",
+- alm.hour, alm.minute, alm.second, alm.nanosecond,
+- alm.year, alm.month, alm.day,
+- alm.daylight,
+- enabled == 1 ? "yes" : "no",
+- pending == 1 ? "yes" : "no");
+-
+- if (eft.timezone == EFI_UNSPECIFIED_TIMEZONE)
+- seq_puts(seq, "Timezone\t: unspecified\n");
+- else
+- /* XXX fixme: convert to string? */
+- seq_printf(seq, "Timezone\t: %u\n", alm.timezone);
++ if (test_bit(RTC_FEATURE_ALARM, rtc->features)) {
++ seq_printf(seq,
++ "Alarm Time\t: %u:%u:%u.%09u\n"
++ "Alarm Date\t: %u-%u-%u\n"
++ "Alarm Daylight\t: %u\n"
++ "Enabled\t\t: %s\n"
++ "Pending\t\t: %s\n",
++ alm.hour, alm.minute, alm.second, alm.nanosecond,
++ alm.year, alm.month, alm.day,
++ alm.daylight,
++ enabled == 1 ? "yes" : "no",
++ pending == 1 ? "yes" : "no");
++
++ if (eft.timezone == EFI_UNSPECIFIED_TIMEZONE)
++ seq_puts(seq, "Timezone\t: unspecified\n");
++ else
++ /* XXX fixme: convert to string? */
++ seq_printf(seq, "Timezone\t: %u\n", alm.timezone);
++ }
+
+ /*
+ * now prints the capabilities
+@@ -269,7 +272,10 @@ static int __init efi_rtc_probe(struct p
+
+ rtc->ops = &efi_rtc_ops;
+ clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, rtc->features);
+- set_bit(RTC_FEATURE_ALARM_WAKEUP_ONLY, rtc->features);
++ if (efi_rt_services_supported(EFI_RT_SUPPORTED_WAKEUP_SERVICES))
++ set_bit(RTC_FEATURE_ALARM_WAKEUP_ONLY, rtc->features);
++ else
++ clear_bit(RTC_FEATURE_ALARM, rtc->features);
+
+ return devm_rtc_register_device(rtc);
+ }
+--- a/include/linux/efi.h
++++ b/include/linux/efi.h
+@@ -668,7 +668,8 @@ extern struct efi {
+
+ #define EFI_RT_SUPPORTED_ALL 0x3fff
+
+-#define EFI_RT_SUPPORTED_TIME_SERVICES 0x000f
++#define EFI_RT_SUPPORTED_TIME_SERVICES 0x0003
++#define EFI_RT_SUPPORTED_WAKEUP_SERVICES 0x000c
+ #define EFI_RT_SUPPORTED_VARIABLE_SERVICES 0x0070
+
+ extern struct mm_struct efi_mm;
usb-dwc3-qcom-enable-vbus-override-when-in-otg-dr-mo.patch
usb-gadget-f_fs-fix-unbalanced-spinlock-in-__ffs_ep0.patch
vc_screen-move-load-of-struct-vc_data-pointer-in-vcs.patch
+fbcon-check-font-dimension-limits.patch
+cgroup-cpuset-fix-wrong-check-in-update_parent_subparts_cpumask.patch
+hv_netvsc-fix-missed-pagebuf-entries-in-netvsc_dma_map-unmap.patch
+arm-dts-imx7d-smegw01-fix-usb-host-over-current-polarity.patch
+net-qrtr-free-memory-on-error-path-in-radix_tree_insert.patch
+can-isotp-split-tx-timer-into-transmission-and-timeout.patch
+can-isotp-handle-wait_event_interruptible-return-values.patch
+watchdog-diag288_wdt-do-not-use-stack-buffers-for-hardware-data.patch
+watchdog-diag288_wdt-fix-__diag288-inline-assembly.patch
+alsa-hda-realtek-add-acer-predator-ph315-54.patch
+alsa-hda-realtek-fix-mute-micmute-leds-speaker-don-t-work-for-a-hp-platform.patch
+asoc-codecs-wsa883x-correct-playback-min-max-rates.patch
+asoc-sof-sof-audio-unprepare-when-swidget-use_count-0.patch
+asoc-sof-sof-audio-skip-prepare-unprepare-if-swidget-is-null.patch
+asoc-sof-keep-prepare-unprepare-widgets-in-sink-path.patch
+efi-accept-version-2-of-memory-attributes-table.patch
+rtc-efi-enable-set-get-wakeup-services-as-optional.patch
+iio-hid-fix-the-retval-in-accel_3d_capture_sample.patch
+iio-hid-fix-the-retval-in-gyro_3d_capture_sample.patch
+iio-adc-xilinx-ams-fix-devm_krealloc-return-value-check.patch
+iio-adc-berlin2-adc-add-missing-of_node_put-in-error-path.patch
+iio-imx8qxp-adc-fix-irq-flood-when-call-imx8qxp_adc_read_raw.patch
+iio-adc-twl6030-enable-measurements-of-vusb-vbat-and-others.patch
+iio-light-cm32181-fix-pm-support-on-system-with-2-i2c-resources.patch
+iio-imu-fxos8700-fix-accel-measurement-range-selection.patch
+iio-imu-fxos8700-fix-incomplete-accel-and-magn-channels-readback.patch
+iio-imu-fxos8700-fix-imu-data-bits-returned-to-user-space.patch
+iio-imu-fxos8700-fix-map-label-of-channel-type-to-magn-sensor.patch
+iio-imu-fxos8700-fix-swapped-accel-and-magn-channels-readback.patch
+iio-imu-fxos8700-fix-incorrect-odr-mode-readback.patch
+iio-imu-fxos8700-fix-failed-initialization-odr-mode-assignment.patch
+iio-imu-fxos8700-remove-definition-fxos8700_ctrl_odr_min.patch
+iio-imu-fxos8700-fix-magn-sensor-scale-and-unit.patch
+nvmem-brcm_nvram-add-check-for-kzalloc.patch
+nvmem-sunxi_sid-always-use-32-bit-mmio-reads.patch
+nvmem-qcom-spmi-sdam-fix-module-autoloading.patch
+parisc-fix-return-code-of-pdc_iodc_print.patch
+parisc-replace-hardcoded-value-with-priv_user-constant-in-ptrace.c.patch
+parisc-wire-up-ptrace_getregs-ptrace_setregs-for-compat-case.patch
+riscv-disable-generation-of-unwind-tables.patch
--- /dev/null
+From fe8973a3ad0905cb9ba2d42db42ed51de14737df Mon Sep 17 00:00:00 2001
+From: Alexander Egorenkov <egorenar@linux.ibm.com>
+Date: Fri, 27 Jan 2023 14:52:41 +0100
+Subject: watchdog: diag288_wdt: do not use stack buffers for hardware data
+
+From: Alexander Egorenkov <egorenar@linux.ibm.com>
+
+commit fe8973a3ad0905cb9ba2d42db42ed51de14737df upstream.
+
+With CONFIG_VMAP_STACK=y the stack is allocated from the vmalloc space.
+Data passed to a hardware or a hypervisor interface that
+requires V=R can no longer be allocated on the stack.
+
+Use kmalloc() to get memory for a diag288 command.
+
+Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
+Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/watchdog/diag288_wdt.c | 13 +++++++++++--
+ 1 file changed, 11 insertions(+), 2 deletions(-)
+
+--- a/drivers/watchdog/diag288_wdt.c
++++ b/drivers/watchdog/diag288_wdt.c
+@@ -268,12 +268,21 @@ static int __init diag288_init(void)
+ char ebc_begin[] = {
+ 194, 197, 199, 201, 213
+ };
++ char *ebc_cmd;
+
+ watchdog_set_nowayout(&wdt_dev, nowayout_info);
+
+ if (MACHINE_IS_VM) {
+- if (__diag288_vm(WDT_FUNC_INIT, 15,
+- ebc_begin, sizeof(ebc_begin)) != 0) {
++ ebc_cmd = kmalloc(sizeof(ebc_begin), GFP_KERNEL);
++ if (!ebc_cmd) {
++ pr_err("The watchdog cannot be initialized\n");
++ return -ENOMEM;
++ }
++ memcpy(ebc_cmd, ebc_begin, sizeof(ebc_begin));
++ ret = __diag288_vm(WDT_FUNC_INIT, 15,
++ ebc_cmd, sizeof(ebc_begin));
++ kfree(ebc_cmd);
++ if (ret != 0) {
+ pr_err("The watchdog cannot be initialized\n");
+ return -EINVAL;
+ }
--- /dev/null
+From 32e40f9506b9e32917eb73154f93037b443124d1 Mon Sep 17 00:00:00 2001
+From: Alexander Egorenkov <egorenar@linux.ibm.com>
+Date: Fri, 27 Jan 2023 14:52:42 +0100
+Subject: watchdog: diag288_wdt: fix __diag288() inline assembly
+
+From: Alexander Egorenkov <egorenar@linux.ibm.com>
+
+commit 32e40f9506b9e32917eb73154f93037b443124d1 upstream.
+
+The DIAG 288 statement consumes an EBCDIC string the address of which is
+passed in a register. Use a "memory" clobber to tell the compiler that
+memory is accessed within the inline assembly.
+
+Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
+Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/watchdog/diag288_wdt.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/watchdog/diag288_wdt.c
++++ b/drivers/watchdog/diag288_wdt.c
+@@ -86,7 +86,7 @@ static int __diag288(unsigned int func,
+ "1:\n"
+ EX_TABLE(0b, 1b)
+ : "+d" (err) : "d"(__func), "d"(__timeout),
+- "d"(__action), "d"(__len) : "1", "cc");
++ "d"(__action), "d"(__len) : "1", "cc", "memory");
+ return err;
+ }
+