2018-10-22 10:25:58

by Sasha Levin

[permalink] [raw]
Subject: [PATCH AUTOSEL 4.14 01/15] ARM: dts: imx53-qsb: disable 1.2GHz OPP

From: Sascha Hauer <[email protected]>

[ Upstream commit eea96566c189c77e5272585984eb2729881a2f1d ]

The maximum CPU frequency for the i.MX53 QSB is 1GHz, so disable the
1.2GHz OPP. This makes the board work again with configs that have
cpufreq enabled like imx_v6_v7_defconfig on which the board stopped
working with the addition of cpufreq-dt support.

Fixes: 791f416608 ("ARM: dts: imx53: add cpufreq-dt support")

Signed-off-by: Sascha Hauer <[email protected]>
Signed-off-by: Shawn Guo <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
---
arch/arm/boot/dts/imx53-qsb-common.dtsi | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/arch/arm/boot/dts/imx53-qsb-common.dtsi b/arch/arm/boot/dts/imx53-qsb-common.dtsi
index 683dcbe27cbd..8c11190c5218 100644
--- a/arch/arm/boot/dts/imx53-qsb-common.dtsi
+++ b/arch/arm/boot/dts/imx53-qsb-common.dtsi
@@ -130,6 +130,17 @@
};
};

+&cpu0 {
+ /* CPU rated to 1GHz, not 1.2GHz as per the default settings */
+ operating-points = <
+ /* kHz uV */
+ 166666 850000
+ 400000 900000
+ 800000 1050000
+ 1000000 1200000
+ >;
+};
+
&esdhc1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_esdhc1>;
--
2.17.1



2018-10-22 10:22:13

by Sasha Levin

[permalink] [raw]
Subject: [PATCH AUTOSEL 4.14 03/15] Input: i8042 - enable keyboard wakeups by default when s2idle is used

From: Daniel Drake <[email protected]>

[ Upstream commit 684bec1092b6991ff2a7751e8a763898576eb5c2 ]

Previously, on typical consumer laptops, pressing a key on the keyboard
when the system is in suspend would cause it to wake up (default or
unconditional behaviour). This happens because the EC generates a SCI
interrupt in this scenario.

That is no longer true on modern laptops based on Intel WhiskeyLake,
including Acer Swift SF314-55G, Asus UX333FA, Asus UX433FN and Asus
UX533FD. We confirmed with Asus EC engineers that the "Modern Standby"
design has been modified so that the EC no longer generates a SCI
in this case; the keyboard controller itself should be used for wakeup.

In order to retain the standard behaviour of being able to use the
keyboard to wake up the system, enable serio wakeups by default on
platforms that are using s2idle.

Link: https://lkml.kernel.org/r/CAB4CAwfQ0mPMqCLp95TVjw4J0r5zKPWkSvvkK4cpZUGE--w8bQ@mail.gmail.com
Reviewed-by: Rafael J. Wysocki <[email protected]>
Signed-off-by: Daniel Drake <[email protected]>
Signed-off-by: Dmitry Torokhov <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
---
drivers/input/serio/i8042.c | 29 ++++++++++++++++++++---------
include/linux/suspend.h | 2 ++
kernel/power/suspend.c | 6 ++++++
3 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 824f4c1c1f31..6462f1798fbb 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -1392,15 +1392,26 @@ static void __init i8042_register_ports(void)
for (i = 0; i < I8042_NUM_PORTS; i++) {
struct serio *serio = i8042_ports[i].serio;

- if (serio) {
- printk(KERN_INFO "serio: %s at %#lx,%#lx irq %d\n",
- serio->name,
- (unsigned long) I8042_DATA_REG,
- (unsigned long) I8042_COMMAND_REG,
- i8042_ports[i].irq);
- serio_register_port(serio);
- device_set_wakeup_capable(&serio->dev, true);
- }
+ if (!serio)
+ continue;
+
+ printk(KERN_INFO "serio: %s at %#lx,%#lx irq %d\n",
+ serio->name,
+ (unsigned long) I8042_DATA_REG,
+ (unsigned long) I8042_COMMAND_REG,
+ i8042_ports[i].irq);
+ serio_register_port(serio);
+ device_set_wakeup_capable(&serio->dev, true);
+
+ /*
+ * On platforms using suspend-to-idle, allow the keyboard to
+ * wake up the system from sleep by enabling keyboard wakeups
+ * by default. This is consistent with keyboard wakeup
+ * behavior on many platforms using suspend-to-RAM (ACPI S3)
+ * by default.
+ */
+ if (pm_suspend_via_s2idle() && i == I8042_KBD_PORT_NO)
+ device_set_wakeup_enable(&serio->dev, true);
}
}

diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 8544357d92d0..950b56d255ac 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -251,6 +251,7 @@ static inline bool idle_should_enter_s2idle(void)
return unlikely(s2idle_state == S2IDLE_STATE_ENTER);
}

+extern bool pm_suspend_via_s2idle(void);
extern void __init pm_states_init(void);
extern void s2idle_set_ops(const struct platform_s2idle_ops *ops);
extern void s2idle_wake(void);
@@ -282,6 +283,7 @@ static inline void pm_set_suspend_via_firmware(void) {}
static inline void pm_set_resume_via_firmware(void) {}
static inline bool pm_suspend_via_firmware(void) { return false; }
static inline bool pm_resume_via_firmware(void) { return false; }
+static inline bool pm_suspend_via_s2idle(void) { return false; }

static inline void suspend_set_ops(const struct platform_suspend_ops *ops) {}
static inline int pm_suspend(suspend_state_t state) { return -ENOSYS; }
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index c0bc2c89697a..405e80219fe4 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -62,6 +62,12 @@ static DECLARE_WAIT_QUEUE_HEAD(s2idle_wait_head);
enum s2idle_states __read_mostly s2idle_state;
static DEFINE_RAW_SPINLOCK(s2idle_lock);

+bool pm_suspend_via_s2idle(void)
+{
+ return mem_sleep_current == PM_SUSPEND_TO_IDLE;
+}
+EXPORT_SYMBOL_GPL(pm_suspend_via_s2idle);
+
void s2idle_set_ops(const struct platform_s2idle_ops *ops)
{
lock_system_sleep();
--
2.17.1


2018-10-22 10:22:14

by Sasha Levin

[permalink] [raw]
Subject: [PATCH AUTOSEL 4.14 07/15] Input: uinput - add a schedule point in uinput_inject_events()

From: Dmitry Torokhov <[email protected]>

[ Upstream commit cecf10704899467a787975e3d94a1f0129b9688e ]

Large writes to uinput interface may cause rcu stalls. Let's add
cond_resched() to the loop to avoid this.

Reviewed-by: Paul E. McKenney <[email protected]>
Signed-off-by: Dmitry Torokhov <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
---
drivers/input/misc/uinput.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
index 443151de90c6..13d17e85f2cf 100644
--- a/drivers/input/misc/uinput.c
+++ b/drivers/input/misc/uinput.c
@@ -561,6 +561,7 @@ static ssize_t uinput_inject_events(struct uinput_device *udev,

input_event(udev->dev, ev.type, ev.code, ev.value);
bytes += input_event_size();
+ cond_resched();
}

return bytes;
--
2.17.1


2018-10-22 10:23:30

by Sasha Levin

[permalink] [raw]
Subject: [PATCH AUTOSEL 4.14 14/15] selftests: rtnetlink.sh explicitly requires bash.

From: Paolo Abeni <[email protected]>

[ Upstream commit 3c718e677c2b35b449992adc36ecce883c467e98 ]

the script rtnetlink.sh requires a bash-only features (sleep with sub-second
precision). This may cause random test failure if the default shell is not
bash.
Address the above explicitly requiring bash as the script interpreter.

Fixes: 33b01b7b4f19 ("selftests: add rtnetlink test script")
Signed-off-by: Paolo Abeni <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
---
tools/testing/selftests/net/rtnetlink.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/rtnetlink.sh b/tools/testing/selftests/net/rtnetlink.sh
index 57b5ff576240..891130daac7c 100755
--- a/tools/testing/selftests/net/rtnetlink.sh
+++ b/tools/testing/selftests/net/rtnetlink.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
#
# This test is for checking rtnetlink callpaths, and get as much coverage as possible.
#
--
2.17.1


2018-10-22 10:23:30

by Sasha Levin

[permalink] [raw]
Subject: [PATCH AUTOSEL 4.14 15/15] fs/fat/fatent.c: add cond_resched() to fat_count_free_clusters()

From: Khazhismel Kumykov <[email protected]>

[ Upstream commit ac081c3be3fae6d0cc3e1862507fca3862d30b67 ]

On non-preempt kernels this loop can take a long time (more than 50 ticks)
processing through entries.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Khazhismel Kumykov <[email protected]>
Acked-by: OGAWA Hirofumi <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
---
fs/fat/fatent.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/fs/fat/fatent.c b/fs/fat/fatent.c
index a40f36b1b292..9635df94db7d 100644
--- a/fs/fat/fatent.c
+++ b/fs/fat/fatent.c
@@ -681,6 +681,7 @@ int fat_count_free_clusters(struct super_block *sb)
if (ops->ent_get(&fatent) == FAT_ENT_FREE)
free++;
} while (fat_ent_next(sbi, &fatent));
+ cond_resched();
}
sbi->free_clusters = free;
sbi->free_clus_valid = 1;
--
2.17.1


2018-10-22 10:23:33

by Sasha Levin

[permalink] [raw]
Subject: [PATCH AUTOSEL 4.14 13/15] libertas: call into generic suspend code before turning off power

From: Daniel Mack <[email protected]>

[ Upstream commit 4f666675cdff0b986195413215eb062b7da6586f ]

When powering down a SDIO connected card during suspend, make sure to call
into the generic lbs_suspend() function before pulling the plug. This will
make sure the card is successfully deregistered from the system to avoid
communication to the card starving out.

Fixes: 7444a8092906 ("libertas: fix suspend and resume for SDIO connected cards")
Signed-off-by: Daniel Mack <[email protected]>
Reviewed-by: Ulf Hansson <[email protected]>
Acked-by: Kalle Valo <[email protected]>
Signed-off-by: Ulf Hansson <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
---
drivers/net/wireless/marvell/libertas/if_sdio.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/net/wireless/marvell/libertas/if_sdio.c b/drivers/net/wireless/marvell/libertas/if_sdio.c
index 43743c26c071..39bf85d0ade0 100644
--- a/drivers/net/wireless/marvell/libertas/if_sdio.c
+++ b/drivers/net/wireless/marvell/libertas/if_sdio.c
@@ -1317,6 +1317,10 @@ static int if_sdio_suspend(struct device *dev)
if (priv->wol_criteria == EHS_REMOVE_WAKEUP) {
dev_info(dev, "Suspend without wake params -- powering down card\n");
if (priv->fw_ready) {
+ ret = lbs_suspend(priv);
+ if (ret)
+ return ret;
+
priv->power_up_on_resume = true;
if_sdio_power_off(card);
}
--
2.17.1


2018-10-22 10:24:10

by Sasha Levin

[permalink] [raw]
Subject: [PATCH AUTOSEL 4.14 11/15] net: ena: fix warning in rmmod caused by double iounmap

From: Arthur Kiyanovski <[email protected]>

[ Upstream commit d79c3888bde6581da7ff9f9d6f581900ecb5e632 ]

Memory mapped with devm_ioremap is automatically freed when the driver
is disconnected from the device. Therefore there is no need to
explicitly call devm_iounmap.

Fixes: 0857d92f71b6 ("net: ena: add missing unmap bars on device removal")
Fixes: 411838e7b41c ("net: ena: fix rare kernel crash when bar memory remap fails")
Signed-off-by: Arthur Kiyanovski <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
---
drivers/net/ethernet/amazon/ena/ena_netdev.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index 60b3ee29d82c..08c9c99a8331 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -3059,15 +3059,8 @@ static int ena_rss_init_default(struct ena_adapter *adapter)

static void ena_release_bars(struct ena_com_dev *ena_dev, struct pci_dev *pdev)
{
- int release_bars;
+ int release_bars = pci_select_bars(pdev, IORESOURCE_MEM) & ENA_BAR_MASK;

- if (ena_dev->mem_bar)
- devm_iounmap(&pdev->dev, ena_dev->mem_bar);
-
- if (ena_dev->reg_bar)
- devm_iounmap(&pdev->dev, ena_dev->reg_bar);
-
- release_bars = pci_select_bars(pdev, IORESOURCE_MEM) & ENA_BAR_MASK;
pci_release_selected_regions(pdev, release_bars);
}

--
2.17.1


2018-10-22 10:25:17

by Sasha Levin

[permalink] [raw]
Subject: [PATCH AUTOSEL 4.14 09/15] rxrpc: Only take the rwind and mtu values from latest ACK

From: David Howells <[email protected]>

[ Upstream commit 298bc15b2079c324e82d0a6fda39c3d762af7282 ]

Move the out-of-order and duplicate ACK packet check to before the call to
rxrpc_input_ackinfo() so that the receive window size and MTU size are only
checked in the latest ACK packet and don't regress.

Fixes: 248f219cb8bc ("rxrpc: Rewrite the data and ack handling code")
Signed-off-by: David Howells <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
---
net/rxrpc/input.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c
index 3a501bf0fc1a..ea506a77f3c8 100644
--- a/net/rxrpc/input.c
+++ b/net/rxrpc/input.c
@@ -806,6 +806,16 @@ static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb,
rxrpc_propose_ack_respond_to_ack);
}

+ /* Discard any out-of-order or duplicate ACKs. */
+ if (before_eq(sp->hdr.serial, call->acks_latest)) {
+ _debug("discard ACK %d <= %d",
+ sp->hdr.serial, call->acks_latest);
+ return;
+ }
+ call->acks_latest_ts = skb->tstamp;
+ call->acks_latest = sp->hdr.serial;
+
+ /* Parse rwind and mtu sizes if provided. */
ioffset = offset + nr_acks + 3;
if (skb->len >= ioffset + sizeof(buf.info)) {
if (skb_copy_bits(skb, ioffset, &buf.info, sizeof(buf.info)) < 0)
@@ -827,15 +837,6 @@ static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb,
return;
}

- /* Discard any out-of-order or duplicate ACKs. */
- if (before_eq(sp->hdr.serial, call->acks_latest)) {
- _debug("discard ACK %d <= %d",
- sp->hdr.serial, call->acks_latest);
- return;
- }
- call->acks_latest_ts = skb->tstamp;
- call->acks_latest = sp->hdr.serial;
-
if (before(hard_ack, call->tx_hard_ack) ||
after(hard_ack, call->tx_top))
return rxrpc_proto_abort("AKW", call, 0);
--
2.17.1


2018-10-22 10:25:28

by Sasha Levin

[permalink] [raw]
Subject: [PATCH AUTOSEL 4.14 06/15] Input: evdev - add a schedule point in evdev_write()

From: Dmitry Torokhov <[email protected]>

[ Upstream commit 36d2582ff235b4e01ad64a734c877a52dc762d9c ]

Large writes to evdev interface may cause rcu stalls. Let's add
cond_resched() to the loop to avoid this.

Reviewed-by: Paul E. McKenney <[email protected]>
Signed-off-by: Dmitry Torokhov <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
---
drivers/input/evdev.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 925571475005..d6de0c0ed52f 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -558,6 +558,7 @@ static ssize_t evdev_write(struct file *file, const char __user *buffer,

input_inject_event(&evdev->handle,
event.type, event.code, event.value);
+ cond_resched();
}

out:
--
2.17.1


2018-10-22 10:25:28

by Sasha Levin

[permalink] [raw]
Subject: [PATCH AUTOSEL 4.14 10/15] rxrpc: Fix connection-level abort handling

From: David Howells <[email protected]>

[ Upstream commit 647530924f47c93db472ee3cf43b7ef1425581b6 ]

Fix connection-level abort handling to cache the abort and error codes
properly so that a new incoming call can be properly aborted if it races
with the parent connection being aborted by another CPU.

The abort_code and error parameters can then be dropped from
rxrpc_abort_calls().

Fixes: f5c17aaeb2ae ("rxrpc: Calls should only have one terminal state")
Signed-off-by: David Howells <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
---
net/rxrpc/ar-internal.h | 4 ++--
net/rxrpc/call_accept.c | 4 ++--
net/rxrpc/conn_event.c | 26 +++++++++++++++-----------
3 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
index e6c2c4f56fb1..71c7f1dd4599 100644
--- a/net/rxrpc/ar-internal.h
+++ b/net/rxrpc/ar-internal.h
@@ -424,8 +424,7 @@ struct rxrpc_connection {
spinlock_t state_lock; /* state-change lock */
enum rxrpc_conn_cache_state cache_state;
enum rxrpc_conn_proto_state state; /* current state of connection */
- u32 local_abort; /* local abort code */
- u32 remote_abort; /* remote abort code */
+ u32 abort_code; /* Abort code of connection abort */
int debug_id; /* debug ID for printks */
atomic_t serial; /* packet serial number counter */
unsigned int hi_serial; /* highest serial number received */
@@ -435,6 +434,7 @@ struct rxrpc_connection {
u8 security_size; /* security header size */
u8 security_ix; /* security type */
u8 out_clientflag; /* RXRPC_CLIENT_INITIATED if we are client */
+ short error; /* Local error code */
};

/*
diff --git a/net/rxrpc/call_accept.c b/net/rxrpc/call_accept.c
index 62b1581d44a5..2dd13f5c47c8 100644
--- a/net/rxrpc/call_accept.c
+++ b/net/rxrpc/call_accept.c
@@ -418,11 +418,11 @@ struct rxrpc_call *rxrpc_new_incoming_call(struct rxrpc_local *local,

case RXRPC_CONN_REMOTELY_ABORTED:
rxrpc_set_call_completion(call, RXRPC_CALL_REMOTELY_ABORTED,
- conn->remote_abort, -ECONNABORTED);
+ conn->abort_code, conn->error);
break;
case RXRPC_CONN_LOCALLY_ABORTED:
rxrpc_abort_call("CON", call, sp->hdr.seq,
- conn->local_abort, -ECONNABORTED);
+ conn->abort_code, conn->error);
break;
default:
BUG();
diff --git a/net/rxrpc/conn_event.c b/net/rxrpc/conn_event.c
index 0435c4167a1a..75ec1ad595b7 100644
--- a/net/rxrpc/conn_event.c
+++ b/net/rxrpc/conn_event.c
@@ -117,7 +117,7 @@ static void rxrpc_conn_retransmit_call(struct rxrpc_connection *conn,

switch (chan->last_type) {
case RXRPC_PACKET_TYPE_ABORT:
- _proto("Tx ABORT %%%u { %d } [re]", serial, conn->local_abort);
+ _proto("Tx ABORT %%%u { %d } [re]", serial, conn->abort_code);
break;
case RXRPC_PACKET_TYPE_ACK:
trace_rxrpc_tx_ack(NULL, serial, chan->last_seq, 0,
@@ -135,13 +135,12 @@ static void rxrpc_conn_retransmit_call(struct rxrpc_connection *conn,
* pass a connection-level abort onto all calls on that connection
*/
static void rxrpc_abort_calls(struct rxrpc_connection *conn,
- enum rxrpc_call_completion compl,
- u32 abort_code, int error)
+ enum rxrpc_call_completion compl)
{
struct rxrpc_call *call;
int i;

- _enter("{%d},%x", conn->debug_id, abort_code);
+ _enter("{%d},%x", conn->debug_id, conn->abort_code);

spin_lock(&conn->channel_lock);

@@ -153,9 +152,11 @@ static void rxrpc_abort_calls(struct rxrpc_connection *conn,
if (compl == RXRPC_CALL_LOCALLY_ABORTED)
trace_rxrpc_abort("CON", call->cid,
call->call_id, 0,
- abort_code, error);
+ conn->abort_code,
+ conn->error);
if (rxrpc_set_call_completion(call, compl,
- abort_code, error))
+ conn->abort_code,
+ conn->error))
rxrpc_notify_socket(call);
}
}
@@ -188,10 +189,12 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
return 0;
}

+ conn->error = error;
+ conn->abort_code = abort_code;
conn->state = RXRPC_CONN_LOCALLY_ABORTED;
spin_unlock_bh(&conn->state_lock);

- rxrpc_abort_calls(conn, RXRPC_CALL_LOCALLY_ABORTED, abort_code, error);
+ rxrpc_abort_calls(conn, RXRPC_CALL_LOCALLY_ABORTED);

msg.msg_name = &conn->params.peer->srx.transport;
msg.msg_namelen = conn->params.peer->srx.transport_len;
@@ -210,7 +213,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
whdr._rsvd = 0;
whdr.serviceId = htons(conn->service_id);

- word = htonl(conn->local_abort);
+ word = htonl(conn->abort_code);

iov[0].iov_base = &whdr;
iov[0].iov_len = sizeof(whdr);
@@ -221,7 +224,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,

serial = atomic_inc_return(&conn->serial);
whdr.serial = htonl(serial);
- _proto("Tx CONN ABORT %%%u { %d }", serial, conn->local_abort);
+ _proto("Tx CONN ABORT %%%u { %d }", serial, conn->abort_code);

ret = kernel_sendmsg(conn->params.local->socket, &msg, iov, 2, len);
if (ret < 0) {
@@ -289,9 +292,10 @@ static int rxrpc_process_event(struct rxrpc_connection *conn,
abort_code = ntohl(wtmp);
_proto("Rx ABORT %%%u { ac=%d }", sp->hdr.serial, abort_code);

+ conn->error = -ECONNABORTED;
+ conn->abort_code = abort_code;
conn->state = RXRPC_CONN_REMOTELY_ABORTED;
- rxrpc_abort_calls(conn, RXRPC_CALL_REMOTELY_ABORTED,
- abort_code, -ECONNABORTED);
+ rxrpc_abort_calls(conn, RXRPC_CALL_REMOTELY_ABORTED);
return -ECONNABORTED;

case RXRPC_PACKET_TYPE_CHALLENGE:
--
2.17.1


2018-10-22 10:25:30

by Sasha Levin

[permalink] [raw]
Subject: [PATCH AUTOSEL 4.14 05/15] perf python: Use -Wno-redundant-decls to build with PYTHON=python3

From: Arnaldo Carvalho de Melo <[email protected]>

[ Upstream commit 05a2f54679861deb188750ba2a70187000b2c71f ]

When building in ClearLinux using 'make PYTHON=python3' with gcc 8.2.1
it fails with:

GEN /tmp/build/perf/python/perf.so
In file included from /usr/include/python3.7m/Python.h:126,
from /git/linux/tools/perf/util/python.c:2:
/usr/include/python3.7m/import.h:58:24: error: redundant redeclaration of ‘_PyImport_AddModuleObject’ [-Werror=redundant-decls]
PyAPI_FUNC(PyObject *) _PyImport_AddModuleObject(PyObject *, PyObject *);
^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/python3.7m/import.h:47:24: note: previous declaration of ‘_PyImport_AddModuleObject’ was here
PyAPI_FUNC(PyObject *) _PyImport_AddModuleObject(PyObject *name,
^~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
error: command 'gcc' failed with exit status 1

And indeed there is a redundant declaration in that Python.h file, one
with parameter names and the other without, so just add
-Wno-error=redundant-decls to the python setup instructions.

Now perf builds with gcc in ClearLinux with the following Dockerfile:

# docker.io/acmel/linux-perf-tools-build-clearlinux:latest
FROM docker.io/clearlinux:latest
MAINTAINER Arnaldo Carvalho de Melo <[email protected]>
RUN swupd update && \
swupd bundle-add sysadmin-basic-dev
RUN mkdir -m 777 -p /git /tmp/build/perf /tmp/build/objtool /tmp/build/linux && \
groupadd -r perfbuilder && \
useradd -m -r -g perfbuilder perfbuilder && \
chown -R perfbuilder.perfbuilder /tmp/build/ /git/
USER perfbuilder
COPY rx_and_build.sh /
ENV EXTRA_MAKE_ARGS=PYTHON=python3
ENTRYPOINT ["/rx_and_build.sh"]

Now to figure out why the build fails with clang, that is present in the
above container as detected by the rx_and_build.sh script:

clang version 6.0.1 (tags/RELEASE_601/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/sbin
make: Entering directory '/git/linux/tools/perf'
BUILD: Doing 'make -j4' parallel build
HOSTCC /tmp/build/perf/fixdep.o
HOSTLD /tmp/build/perf/fixdep-in.o
LINK /tmp/build/perf/fixdep

Auto-detecting system features:
... dwarf: [ OFF ]
... dwarf_getlocations: [ OFF ]
... glibc: [ OFF ]
... gtk2: [ OFF ]
... libaudit: [ OFF ]
... libbfd: [ OFF ]
... libelf: [ OFF ]
... libnuma: [ OFF ]
... numa_num_possible_cpus: [ OFF ]
... libperl: [ OFF ]
... libpython: [ OFF ]
... libslang: [ OFF ]
... libcrypto: [ OFF ]
... libunwind: [ OFF ]
... libdw-dwarf-unwind: [ OFF ]
... zlib: [ OFF ]
... lzma: [ OFF ]
... get_cpuid: [ OFF ]
... bpf: [ OFF ]

Makefile.config:331: *** No gnu/libc-version.h found, please install glibc-dev[el]. Stop.
make[1]: *** [Makefile.perf:206: sub-make] Error 2
make: *** [Makefile:70: all] Error 2
make: Leaving directory '/git/linux/tools/perf'

Cc: Adrian Hunter <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Thiago Macieira <[email protected]>
Cc: Wang Nan <[email protected]>
Link: https://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
---
tools/perf/util/setup.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/setup.py b/tools/perf/util/setup.py
index da4df7fd43a2..23f1bf175179 100644
--- a/tools/perf/util/setup.py
+++ b/tools/perf/util/setup.py
@@ -27,7 +27,7 @@ class install_lib(_install_lib):

cflags = getenv('CFLAGS', '').split()
# switch off several checks (need to be at the end of cflags list)
-cflags += ['-fno-strict-aliasing', '-Wno-write-strings', '-Wno-unused-parameter' ]
+cflags += ['-fno-strict-aliasing', '-Wno-write-strings', '-Wno-unused-parameter', '-Wno-redundant-decls' ]
if cc != "clang":
cflags += ['-Wno-cast-function-type' ]

--
2.17.1


2018-10-22 10:26:21

by Sasha Levin

[permalink] [raw]
Subject: [PATCH AUTOSEL 4.14 02/15] s390/hibernate: fix error handling when suspend cpu != resume cpu

From: Gerald Schaefer <[email protected]>

[ Upstream commit 55a5542a546238354d1f209f794414168cf8c71d ]

The resume code checks if the resume cpu is the same as the suspend cpu.
If not, and if it is also not possible to switch to the suspend cpu, an
error message should be printed and the resume process should be stopped
by loading a disabled wait psw.

The current logic is broken in multiple ways, the message is never printed,
and the disabled wait psw never loaded because the kernel panics before that:
- sam31 and SIGP_SET_ARCHITECTURE to ESA mode is wrong, this will break
on the first 64bit instruction in sclp_early_printk().
- The init stack should be used, but the stack pointer is not set up correctly
(missing aghi %r15,-STACK_FRAME_OVERHEAD).
- __sclp_early_printk() checks the sclp_init_state. If it is not
sclp_init_state_uninitialized, it simply returns w/o printing anything.
In the resumed kernel however, sclp_init_state will never be uninitialized.

This patch fixes those issues by removing the sam31/ESA logic, adding a
correct init stack pointer, and also introducing sclp_early_printk_force()
to allow using sclp_early_printk() even when sclp_init_state is not
uninitialized.

Reviewed-by: Heiko Carstens <[email protected]>
Signed-off-by: Gerald Schaefer <[email protected]>
Signed-off-by: Martin Schwidefsky <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
---
arch/s390/include/asm/sclp.h | 3 ++-
arch/s390/kernel/early_printk.c | 2 +-
arch/s390/kernel/swsusp.S | 8 +++-----
drivers/s390/char/sclp_early_core.c | 11 ++++++++---
4 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/arch/s390/include/asm/sclp.h b/arch/s390/include/asm/sclp.h
index d3c1a8a2e3ad..d90a84770ce5 100644
--- a/arch/s390/include/asm/sclp.h
+++ b/arch/s390/include/asm/sclp.h
@@ -107,7 +107,8 @@ int sclp_early_get_core_info(struct sclp_core_info *info);
void sclp_early_get_ipl_info(struct sclp_ipl_info *info);
void sclp_early_detect(void);
void sclp_early_printk(const char *s);
-void __sclp_early_printk(const char *s, unsigned int len);
+void sclp_early_printk_force(const char *s);
+void __sclp_early_printk(const char *s, unsigned int len, unsigned int force);

int _sclp_get_core_info(struct sclp_core_info *info);
int sclp_core_configure(u8 core);
diff --git a/arch/s390/kernel/early_printk.c b/arch/s390/kernel/early_printk.c
index 9431784d7796..40c1dfec944e 100644
--- a/arch/s390/kernel/early_printk.c
+++ b/arch/s390/kernel/early_printk.c
@@ -10,7 +10,7 @@

static void sclp_early_write(struct console *con, const char *s, unsigned int len)
{
- __sclp_early_printk(s, len);
+ __sclp_early_printk(s, len, 0);
}

static struct console sclp_early_console = {
diff --git a/arch/s390/kernel/swsusp.S b/arch/s390/kernel/swsusp.S
index a049a7b9d6e8..c1a080b11ae9 100644
--- a/arch/s390/kernel/swsusp.S
+++ b/arch/s390/kernel/swsusp.S
@@ -198,12 +198,10 @@ pgm_check_entry:

/* Suspend CPU not available -> panic */
larl %r15,init_thread_union
- ahi %r15,1<<(PAGE_SHIFT+THREAD_SIZE_ORDER)
+ aghi %r15,1<<(PAGE_SHIFT+THREAD_SIZE_ORDER)
+ aghi %r15,-STACK_FRAME_OVERHEAD
larl %r2,.Lpanic_string
- lghi %r1,0
- sam31
- sigp %r1,%r0,SIGP_SET_ARCHITECTURE
- brasl %r14,sclp_early_printk
+ brasl %r14,sclp_early_printk_force
larl %r3,.Ldisabled_wait_31
lpsw 0(%r3)
4:
diff --git a/drivers/s390/char/sclp_early_core.c b/drivers/s390/char/sclp_early_core.c
index edeb2597b0b8..4daf797a6423 100644
--- a/drivers/s390/char/sclp_early_core.c
+++ b/drivers/s390/char/sclp_early_core.c
@@ -188,11 +188,11 @@ static int sclp_early_setup(int disable, int *have_linemode, int *have_vt220)
* Output one or more lines of text on the SCLP console (VT220 and /
* or line-mode).
*/
-void __sclp_early_printk(const char *str, unsigned int len)
+void __sclp_early_printk(const char *str, unsigned int len, unsigned int force)
{
int have_linemode, have_vt220;

- if (sclp_init_state != sclp_init_state_uninitialized)
+ if (!force && sclp_init_state != sclp_init_state_uninitialized)
return;
if (sclp_early_setup(0, &have_linemode, &have_vt220) != 0)
return;
@@ -205,5 +205,10 @@ void __sclp_early_printk(const char *str, unsigned int len)

void sclp_early_printk(const char *str)
{
- __sclp_early_printk(str, strlen(str));
+ __sclp_early_printk(str, strlen(str), 0);
+}
+
+void sclp_early_printk_force(const char *str)
+{
+ __sclp_early_printk(str, strlen(str), 1);
}
--
2.17.1


2018-10-22 10:26:33

by Sasha Levin

[permalink] [raw]
Subject: [PATCH AUTOSEL 4.14 08/15] rxrpc: Don't check RXRPC_CALL_TX_LAST after calling rxrpc_rotate_tx_window()

From: David Howells <[email protected]>

[ Upstream commit c479d5f2c2e1ce609da08c075054440d97ddff52 ]

We should only call the function to end a call's Tx phase if we rotated the
marked-last packet out of the transmission buffer.

Make rxrpc_rotate_tx_window() return an indication of whether it just
rotated the packet marked as the last out of the transmit buffer, carrying
the information out of the locked section in that function.

We can then check the return value instead of examining RXRPC_CALL_TX_LAST.

Fixes: 70790dbe3f66 ("rxrpc: Pass the last Tx packet marker in the annotation buffer")
Signed-off-by: David Howells <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
---
net/rxrpc/input.c | 35 +++++++++++++++++++----------------
1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c
index 5edb636dbc4d..3a501bf0fc1a 100644
--- a/net/rxrpc/input.c
+++ b/net/rxrpc/input.c
@@ -216,10 +216,11 @@ static void rxrpc_send_ping(struct rxrpc_call *call, struct sk_buff *skb,
/*
* Apply a hard ACK by advancing the Tx window.
*/
-static void rxrpc_rotate_tx_window(struct rxrpc_call *call, rxrpc_seq_t to,
+static bool rxrpc_rotate_tx_window(struct rxrpc_call *call, rxrpc_seq_t to,
struct rxrpc_ack_summary *summary)
{
struct sk_buff *skb, *list = NULL;
+ bool rot_last = false;
int ix;
u8 annotation;

@@ -243,15 +244,17 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, rxrpc_seq_t to,
skb->next = list;
list = skb;

- if (annotation & RXRPC_TX_ANNO_LAST)
+ if (annotation & RXRPC_TX_ANNO_LAST) {
set_bit(RXRPC_CALL_TX_LAST, &call->flags);
+ rot_last = true;
+ }
if ((annotation & RXRPC_TX_ANNO_MASK) != RXRPC_TX_ANNO_ACK)
summary->nr_rot_new_acks++;
}

spin_unlock(&call->lock);

- trace_rxrpc_transmit(call, (test_bit(RXRPC_CALL_TX_LAST, &call->flags) ?
+ trace_rxrpc_transmit(call, (rot_last ?
rxrpc_transmit_rotate_last :
rxrpc_transmit_rotate));
wake_up(&call->waitq);
@@ -262,6 +265,8 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, rxrpc_seq_t to,
skb->next = NULL;
rxrpc_free_skb(skb, rxrpc_skb_tx_freed);
}
+
+ return rot_last;
}

/*
@@ -332,11 +337,11 @@ static bool rxrpc_receiving_reply(struct rxrpc_call *call)
ktime_get_real());
}

- if (!test_bit(RXRPC_CALL_TX_LAST, &call->flags))
- rxrpc_rotate_tx_window(call, top, &summary);
if (!test_bit(RXRPC_CALL_TX_LAST, &call->flags)) {
- rxrpc_proto_abort("TXL", call, top);
- return false;
+ if (!rxrpc_rotate_tx_window(call, top, &summary)) {
+ rxrpc_proto_abort("TXL", call, top);
+ return false;
+ }
}
if (!rxrpc_end_tx_phase(call, true, "ETD"))
return false;
@@ -837,8 +842,12 @@ static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb,
if (nr_acks > call->tx_top - hard_ack)
return rxrpc_proto_abort("AKN", call, 0);

- if (after(hard_ack, call->tx_hard_ack))
- rxrpc_rotate_tx_window(call, hard_ack, &summary);
+ if (after(hard_ack, call->tx_hard_ack)) {
+ if (rxrpc_rotate_tx_window(call, hard_ack, &summary)) {
+ rxrpc_end_tx_phase(call, false, "ETA");
+ return;
+ }
+ }

if (nr_acks > 0) {
if (skb_copy_bits(skb, offset, buf.acks, nr_acks) < 0)
@@ -847,11 +856,6 @@ static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb,
&summary);
}

- if (test_bit(RXRPC_CALL_TX_LAST, &call->flags)) {
- rxrpc_end_tx_phase(call, false, "ETA");
- return;
- }
-
if (call->rxtx_annotations[call->tx_top & RXRPC_RXTX_BUFF_MASK] &
RXRPC_TX_ANNO_LAST &&
summary.nr_acks == call->tx_top - hard_ack &&
@@ -873,8 +877,7 @@ static void rxrpc_input_ackall(struct rxrpc_call *call, struct sk_buff *skb)

_proto("Rx ACKALL %%%u", sp->hdr.serial);

- rxrpc_rotate_tx_window(call, call->tx_top, &summary);
- if (test_bit(RXRPC_CALL_TX_LAST, &call->flags))
+ if (rxrpc_rotate_tx_window(call, call->tx_top, &summary))
rxrpc_end_tx_phase(call, false, "ETL");
}

--
2.17.1


2018-10-22 11:35:11

by Sasha Levin

[permalink] [raw]
Subject: [PATCH AUTOSEL 4.14 04/15] Input: mousedev - add a schedule point in mousedev_write()

From: Eric Dumazet <[email protected]>

[ Upstream commit f74c371fe72a4f820d287db8067683fb533e4ede ]

syzbot was able to trigger rcu stalls by calling write()
with large number of bytes.

Add a cond_resched() in the loop to avoid this.

Link: https://lkml.org/lkml/2018/8/23/1106
Signed-off-by: Eric Dumazet <[email protected]>
Reported-by: [email protected]
Reviewed-by: Paul E. McKenney <[email protected]>
Signed-off-by: Dmitry Torokhov <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
---
drivers/input/mousedev.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
index 2d7f691ec71c..770960b0d9fc 100644
--- a/drivers/input/mousedev.c
+++ b/drivers/input/mousedev.c
@@ -707,6 +707,7 @@ static ssize_t mousedev_write(struct file *file, const char __user *buffer,
mousedev_generate_response(client, c);

spin_unlock_irq(&client->packet_lock);
+ cond_resched();
}

kill_fasync(&client->fasync, SIGIO, POLL_IN);
--
2.17.1


2018-10-22 11:36:21

by Sasha Levin

[permalink] [raw]
Subject: [PATCH AUTOSEL 4.14 12/15] net: ena: fix NULL dereference due to untimely napi initialization

From: Arthur Kiyanovski <[email protected]>

[ Upstream commit 78a55d05def95144ca5fa9a64c49b2a0636a9866 ]

napi poll functions should be initialized before running request_irq(),
to handle a rare condition where there is a pending interrupt, causing
the ISR to fire immediately while the poll function wasn't set yet,
causing a NULL dereference.

Fixes: 1738cd3ed342 ("net: ena: Add a driver for Amazon Elastic Network Adapters (ENA)")
Signed-off-by: Arthur Kiyanovski <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
---
drivers/net/ethernet/amazon/ena/ena_netdev.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index 08c9c99a8331..3c7813f04962 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -1571,8 +1571,6 @@ static int ena_up_complete(struct ena_adapter *adapter)
if (rc)
return rc;

- ena_init_napi(adapter);
-
ena_change_mtu(adapter->netdev, adapter->netdev->mtu);

ena_refill_all_rx_bufs(adapter);
@@ -1726,6 +1724,13 @@ static int ena_up(struct ena_adapter *adapter)

ena_setup_io_intr(adapter);

+ /* napi poll functions should be initialized before running
+ * request_irq(), to handle a rare condition where there is a pending
+ * interrupt, causing the ISR to fire immediately while the poll
+ * function wasn't set yet, causing a null dereference
+ */
+ ena_init_napi(adapter);
+
rc = ena_request_io_irq(adapter);
if (rc)
goto err_req_irq;
--
2.17.1


2018-10-26 09:05:59

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH AUTOSEL 4.14 03/15] Input: i8042 - enable keyboard wakeups by default when s2idle is used

On Mon 2018-10-22 06:20:14, Sasha Levin wrote:
> From: Daniel Drake <[email protected]>
>
> [ Upstream commit 684bec1092b6991ff2a7751e8a763898576eb5c2 ]
>
> Previously, on typical consumer laptops, pressing a key on the keyboard
> when the system is in suspend would cause it to wake up (default or
> unconditional behaviour). This happens because the EC generates a SCI
> interrupt in this scenario.
>
> That is no longer true on modern laptops based on Intel WhiskeyLake,
> including Acer Swift SF314-55G, Asus UX333FA, Asus UX433FN and Asus
> UX533FD. We confirmed with Asus EC engineers that the "Modern Standby"
> design has been modified so that the EC no longer generates a SCI
> in this case; the keyboard controller itself should be used for wakeup.
>
> In order to retain the standard behaviour of being able to use the
> keyboard to wake up the system, enable serio wakeups by default on
> platforms that are using s2idle.

Behaviour change, not a bugfix. Someone may like their laptop sleeping
after keypress, we should not change it in the middle of -stable
series.


>
> Link: https://lkml.kernel.org/r/CAB4CAwfQ0mPMqCLp95TVjw4J0r5zKPWkSvvkK4cpZUGE--w8bQ@mail.gmail.com
> Reviewed-by: Rafael J. Wysocki <[email protected]>
> Signed-off-by: Daniel Drake <[email protected]>
> Signed-off-by: Dmitry Torokhov <[email protected]>
> Signed-off-by: Sasha Levin <[email protected]>
> ---
> drivers/input/serio/i8042.c | 29 ++++++++++++++++++++---------
> include/linux/suspend.h | 2 ++
> kernel/power/suspend.c | 6 ++++++
> 3 files changed, 28 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
> index 824f4c1c1f31..6462f1798fbb 100644
> --- a/drivers/input/serio/i8042.c
> +++ b/drivers/input/serio/i8042.c
> @@ -1392,15 +1392,26 @@ static void __init i8042_register_ports(void)
> for (i = 0; i < I8042_NUM_PORTS; i++) {
> struct serio *serio = i8042_ports[i].serio;
>
> - if (serio) {
> - printk(KERN_INFO "serio: %s at %#lx,%#lx irq %d\n",
> - serio->name,
> - (unsigned long) I8042_DATA_REG,
> - (unsigned long) I8042_COMMAND_REG,
> - i8042_ports[i].irq);
> - serio_register_port(serio);
> - device_set_wakeup_capable(&serio->dev, true);
> - }
> + if (!serio)
> + continue;
> +
> + printk(KERN_INFO "serio: %s at %#lx,%#lx irq %d\n",
> + serio->name,
> + (unsigned long) I8042_DATA_REG,
> + (unsigned long) I8042_COMMAND_REG,
> + i8042_ports[i].irq);
> + serio_register_port(serio);
> + device_set_wakeup_capable(&serio->dev, true);
> +
> + /*
> + * On platforms using suspend-to-idle, allow the keyboard to
> + * wake up the system from sleep by enabling keyboard wakeups
> + * by default. This is consistent with keyboard wakeup
> + * behavior on many platforms using suspend-to-RAM (ACPI S3)
> + * by default.
> + */
> + if (pm_suspend_via_s2idle() && i == I8042_KBD_PORT_NO)
> + device_set_wakeup_enable(&serio->dev, true);
> }
> }
>
> diff --git a/include/linux/suspend.h b/include/linux/suspend.h
> index 8544357d92d0..950b56d255ac 100644
> --- a/include/linux/suspend.h
> +++ b/include/linux/suspend.h
> @@ -251,6 +251,7 @@ static inline bool idle_should_enter_s2idle(void)
> return unlikely(s2idle_state == S2IDLE_STATE_ENTER);
> }
>
> +extern bool pm_suspend_via_s2idle(void);
> extern void __init pm_states_init(void);
> extern void s2idle_set_ops(const struct platform_s2idle_ops *ops);
> extern void s2idle_wake(void);
> @@ -282,6 +283,7 @@ static inline void pm_set_suspend_via_firmware(void) {}
> static inline void pm_set_resume_via_firmware(void) {}
> static inline bool pm_suspend_via_firmware(void) { return false; }
> static inline bool pm_resume_via_firmware(void) { return false; }
> +static inline bool pm_suspend_via_s2idle(void) { return false; }
>
> static inline void suspend_set_ops(const struct platform_suspend_ops *ops) {}
> static inline int pm_suspend(suspend_state_t state) { return -ENOSYS; }
> diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
> index c0bc2c89697a..405e80219fe4 100644
> --- a/kernel/power/suspend.c
> +++ b/kernel/power/suspend.c
> @@ -62,6 +62,12 @@ static DECLARE_WAIT_QUEUE_HEAD(s2idle_wait_head);
> enum s2idle_states __read_mostly s2idle_state;
> static DEFINE_RAW_SPINLOCK(s2idle_lock);
>
> +bool pm_suspend_via_s2idle(void)
> +{
> + return mem_sleep_current == PM_SUSPEND_TO_IDLE;
> +}
> +EXPORT_SYMBOL_GPL(pm_suspend_via_s2idle);
> +
> void s2idle_set_ops(const struct platform_s2idle_ops *ops)
> {
> lock_system_sleep();

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Attachments:
(No filename) (4.73 kB)
signature.asc (188.00 B)
Digital signature
Download all attachments

2018-10-26 09:06:49

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH AUTOSEL 4.14 02/15] s390/hibernate: fix error handling when suspend cpu != resume cpu

On Mon 2018-10-22 06:20:13, Sasha Levin wrote:
> From: Gerald Schaefer <[email protected]>
>
> [ Upstream commit 55a5542a546238354d1f209f794414168cf8c71d ]
>
> The resume code checks if the resume cpu is the same as the suspend cpu.
> If not, and if it is also not possible to switch to the suspend cpu, an
> error message should be printed and the resume process should be stopped
> by loading a disabled wait psw.
>
> The current logic is broken in multiple ways, the message is never printed,
> and the disabled wait psw never loaded because the kernel panics before that:
> - sam31 and SIGP_SET_ARCHITECTURE to ESA mode is wrong, this will break
> on the first 64bit instruction in sclp_early_printk().
> - The init stack should be used, but the stack pointer is not set up correctly
> (missing aghi %r15,-STACK_FRAME_OVERHEAD).
> - __sclp_early_printk() checks the sclp_init_state. If it is not
> sclp_init_state_uninitialized, it simply returns w/o printing anything.
> In the resumed kernel however, sclp_init_state will never be uninitialized.

Stable patches should fix one bug, and one bug only.

pavel
> ---
> arch/s390/include/asm/sclp.h | 3 ++-
> arch/s390/kernel/early_printk.c | 2 +-
> arch/s390/kernel/swsusp.S | 8 +++-----
> drivers/s390/char/sclp_early_core.c | 11 ++++++++---
> 4 files changed, 14 insertions(+), 10 deletions(-)
>
> diff --git a/arch/s390/include/asm/sclp.h b/arch/s390/include/asm/sclp.h
> index d3c1a8a2e3ad..d90a84770ce5 100644
> --- a/arch/s390/include/asm/sclp.h
> +++ b/arch/s390/include/asm/sclp.h
> @@ -107,7 +107,8 @@ int sclp_early_get_core_info(struct sclp_core_info *info);
> void sclp_early_get_ipl_info(struct sclp_ipl_info *info);
> void sclp_early_detect(void);
> void sclp_early_printk(const char *s);
> -void __sclp_early_printk(const char *s, unsigned int len);
> +void sclp_early_printk_force(const char *s);
> +void __sclp_early_printk(const char *s, unsigned int len, unsigned int force);
>
> int _sclp_get_core_info(struct sclp_core_info *info);
> int sclp_core_configure(u8 core);
> diff --git a/arch/s390/kernel/early_printk.c b/arch/s390/kernel/early_printk.c
> index 9431784d7796..40c1dfec944e 100644
> --- a/arch/s390/kernel/early_printk.c
> +++ b/arch/s390/kernel/early_printk.c
> @@ -10,7 +10,7 @@
>
> static void sclp_early_write(struct console *con, const char *s, unsigned int len)
> {
> - __sclp_early_printk(s, len);
> + __sclp_early_printk(s, len, 0);
> }
>
> static struct console sclp_early_console = {
> diff --git a/arch/s390/kernel/swsusp.S b/arch/s390/kernel/swsusp.S
> index a049a7b9d6e8..c1a080b11ae9 100644
> --- a/arch/s390/kernel/swsusp.S
> +++ b/arch/s390/kernel/swsusp.S
> @@ -198,12 +198,10 @@ pgm_check_entry:
>
> /* Suspend CPU not available -> panic */
> larl %r15,init_thread_union
> - ahi %r15,1<<(PAGE_SHIFT+THREAD_SIZE_ORDER)
> + aghi %r15,1<<(PAGE_SHIFT+THREAD_SIZE_ORDER)
> + aghi %r15,-STACK_FRAME_OVERHEAD
> larl %r2,.Lpanic_string
> - lghi %r1,0
> - sam31
> - sigp %r1,%r0,SIGP_SET_ARCHITECTURE
> - brasl %r14,sclp_early_printk
> + brasl %r14,sclp_early_printk_force
> larl %r3,.Ldisabled_wait_31
> lpsw 0(%r3)
> 4:
> diff --git a/drivers/s390/char/sclp_early_core.c b/drivers/s390/char/sclp_early_core.c
> index edeb2597b0b8..4daf797a6423 100644
> --- a/drivers/s390/char/sclp_early_core.c
> +++ b/drivers/s390/char/sclp_early_core.c
> @@ -188,11 +188,11 @@ static int sclp_early_setup(int disable, int *have_linemode, int *have_vt220)
> * Output one or more lines of text on the SCLP console (VT220 and /
> * or line-mode).
> */
> -void __sclp_early_printk(const char *str, unsigned int len)
> +void __sclp_early_printk(const char *str, unsigned int len, unsigned int force)
> {
> int have_linemode, have_vt220;
>
> - if (sclp_init_state != sclp_init_state_uninitialized)
> + if (!force && sclp_init_state != sclp_init_state_uninitialized)
> return;
> if (sclp_early_setup(0, &have_linemode, &have_vt220) != 0)
> return;
> @@ -205,5 +205,10 @@ void __sclp_early_printk(const char *str, unsigned int len)
>
> void sclp_early_printk(const char *str)
> {
> - __sclp_early_printk(str, strlen(str));
> + __sclp_early_printk(str, strlen(str), 0);
> +}
> +
> +void sclp_early_printk_force(const char *str)
> +{
> + __sclp_early_printk(str, strlen(str), 1);
> }

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Attachments:
(No filename) (4.50 kB)
signature.asc (188.00 B)
Digital signature
Download all attachments

2018-10-26 09:23:05

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH AUTOSEL 4.14 02/15] s390/hibernate: fix error handling when suspend cpu != resume cpu

On Fri, Oct 26, 2018 at 11:05:43AM +0200, Pavel Machek wrote:
> On Mon 2018-10-22 06:20:13, Sasha Levin wrote:
> > From: Gerald Schaefer <[email protected]>
> >
> > [ Upstream commit 55a5542a546238354d1f209f794414168cf8c71d ]
> >
> > The resume code checks if the resume cpu is the same as the suspend cpu.
> > If not, and if it is also not possible to switch to the suspend cpu, an
> > error message should be printed and the resume process should be stopped
> > by loading a disabled wait psw.
> >
> > The current logic is broken in multiple ways, the message is never printed,
> > and the disabled wait psw never loaded because the kernel panics before that:
> > - sam31 and SIGP_SET_ARCHITECTURE to ESA mode is wrong, this will break
> > on the first 64bit instruction in sclp_early_printk().
> > - The init stack should be used, but the stack pointer is not set up correctly
> > (missing aghi %r15,-STACK_FRAME_OVERHEAD).
> > - __sclp_early_printk() checks the sclp_init_state. If it is not
> > sclp_init_state_uninitialized, it simply returns w/o printing anything.
> > In the resumed kernel however, sclp_init_state will never be uninitialized.
>
> Stable patches should fix one bug, and one bug only.

So should upstream patches, but the rule of "stable patches match
upstream identically" overrules this :)

2018-10-26 10:16:29

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH AUTOSEL 4.14 02/15] s390/hibernate: fix error handling when suspend cpu != resume cpu

On Fri 2018-10-26 10:22:14, Greg KH wrote:
> On Fri, Oct 26, 2018 at 11:05:43AM +0200, Pavel Machek wrote:
> > On Mon 2018-10-22 06:20:13, Sasha Levin wrote:
> > > From: Gerald Schaefer <[email protected]>
> > >
> > > [ Upstream commit 55a5542a546238354d1f209f794414168cf8c71d ]
> > >
> > > The resume code checks if the resume cpu is the same as the suspend cpu.
> > > If not, and if it is also not possible to switch to the suspend cpu, an
> > > error message should be printed and the resume process should be stopped
> > > by loading a disabled wait psw.
> > >
> > > The current logic is broken in multiple ways, the message is never printed,
> > > and the disabled wait psw never loaded because the kernel panics before that:
> > > - sam31 and SIGP_SET_ARCHITECTURE to ESA mode is wrong, this will break
> > > on the first 64bit instruction in sclp_early_printk().
> > > - The init stack should be used, but the stack pointer is not set up correctly
> > > (missing aghi %r15,-STACK_FRAME_OVERHEAD).
> > > - __sclp_early_printk() checks the sclp_init_state. If it is not
> > > sclp_init_state_uninitialized, it simply returns w/o printing anything.
> > > In the resumed kernel however, sclp_init_state will never be uninitialized.
> >
> > Stable patches should fix one bug, and one bug only.
>
> So should upstream patches, but the rule of "stable patches match
> upstream identically" overrules this :)

a) There is no such rule for upstream.

b) You should split the patch if it is important enough.

c) The "stable patches match upstream identically" rule does not
exist. Check the documentation.

:-(
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Attachments:
(No filename) (1.78 kB)
signature.asc (188.00 B)
Digital signature
Download all attachments

2018-10-26 10:57:00

by Sasha Levin

[permalink] [raw]
Subject: Re: [PATCH AUTOSEL 4.14 03/15] Input: i8042 - enable keyboard wakeups by default when s2idle is used

On Fri, Oct 26, 2018 at 11:04:52AM +0200, Pavel Machek wrote:
>On Mon 2018-10-22 06:20:14, Sasha Levin wrote:
>> From: Daniel Drake <[email protected]>
>>
>> [ Upstream commit 684bec1092b6991ff2a7751e8a763898576eb5c2 ]
>>
>> Previously, on typical consumer laptops, pressing a key on the keyboard
>> when the system is in suspend would cause it to wake up (default or
>> unconditional behaviour). This happens because the EC generates a SCI
>> interrupt in this scenario.
>>
>> That is no longer true on modern laptops based on Intel WhiskeyLake,
>> including Acer Swift SF314-55G, Asus UX333FA, Asus UX433FN and Asus
>> UX533FD. We confirmed with Asus EC engineers that the "Modern Standby"
>> design has been modified so that the EC no longer generates a SCI
>> in this case; the keyboard controller itself should be used for wakeup.
>>
>> In order to retain the standard behaviour of being able to use the
>> keyboard to wake up the system, enable serio wakeups by default on
>> platforms that are using s2idle.
>
>Behaviour change, not a bugfix. Someone may like their laptop sleeping
>after keypress, we should not change it in the middle of -stable
>series.

Dmitry already asked for it to be dropped, so it's gone.

--
Thanks,
Sasha

2018-10-26 11:10:54

by Sasha Levin

[permalink] [raw]
Subject: Re: [PATCH AUTOSEL 4.14 02/15] s390/hibernate: fix error handling when suspend cpu != resume cpu

On Fri, Oct 26, 2018 at 12:15:49PM +0200, Pavel Machek wrote:
>On Fri 2018-10-26 10:22:14, Greg KH wrote:
>> On Fri, Oct 26, 2018 at 11:05:43AM +0200, Pavel Machek wrote:
>> > On Mon 2018-10-22 06:20:13, Sasha Levin wrote:
>> > > From: Gerald Schaefer <[email protected]>
>> > >
>> > > [ Upstream commit 55a5542a546238354d1f209f794414168cf8c71d ]
>> > >
>> > > The resume code checks if the resume cpu is the same as the suspend cpu.
>> > > If not, and if it is also not possible to switch to the suspend cpu, an
>> > > error message should be printed and the resume process should be stopped
>> > > by loading a disabled wait psw.
>> > >
>> > > The current logic is broken in multiple ways, the message is never printed,
>> > > and the disabled wait psw never loaded because the kernel panics before that:
>> > > - sam31 and SIGP_SET_ARCHITECTURE to ESA mode is wrong, this will break
>> > > on the first 64bit instruction in sclp_early_printk().
>> > > - The init stack should be used, but the stack pointer is not set up correctly
>> > > (missing aghi %r15,-STACK_FRAME_OVERHEAD).
>> > > - __sclp_early_printk() checks the sclp_init_state. If it is not
>> > > sclp_init_state_uninitialized, it simply returns w/o printing anything.
>> > > In the resumed kernel however, sclp_init_state will never be uninitialized.
>> >
>> > Stable patches should fix one bug, and one bug only.
>>
>> So should upstream patches, but the rule of "stable patches match
>> upstream identically" overrules this :)
>
>a) There is no such rule for upstream.

I invite you to read the docs in Documentation/process/ where you'll
find gems like "Each logically independent change should be formatted as
a separate patch".

>b) You should split the patch if it is important enough.
>
>c) The "stable patches match upstream identically" rule does not
>exist. Check the documentation.

The rule in question here is that every patch that goes into -stable
must be upstream. If we were to split this patch, it would create 2+
patches that do not exist upstream, thus breaking our own rules.

Anyway, given that this is an upstream issue, I'll also invite you to
have this discussion with the maintainer of the subsystem this patch
went into; you raise a valid concern which can hopefully be addressed by
that maintainer.

--
Thanks,
Sasha

2018-10-26 12:19:57

by Gerald Schaefer

[permalink] [raw]
Subject: Re: [PATCH AUTOSEL 4.14 02/15] s390/hibernate: fix error handling when suspend cpu != resume cpu

On Fri, 26 Oct 2018 07:09:20 -0400
Sasha Levin <[email protected]> wrote:

> On Fri, Oct 26, 2018 at 12:15:49PM +0200, Pavel Machek wrote:
> >On Fri 2018-10-26 10:22:14, Greg KH wrote:
> >> On Fri, Oct 26, 2018 at 11:05:43AM +0200, Pavel Machek wrote:
> >> > On Mon 2018-10-22 06:20:13, Sasha Levin wrote:
> >> > > From: Gerald Schaefer <[email protected]>
> >> > >
> >> > > [ Upstream commit 55a5542a546238354d1f209f794414168cf8c71d ]
> >> > >
> >> > > The resume code checks if the resume cpu is the same as the suspend cpu.
> >> > > If not, and if it is also not possible to switch to the suspend cpu, an
> >> > > error message should be printed and the resume process should be stopped
> >> > > by loading a disabled wait psw.
> >> > >
> >> > > The current logic is broken in multiple ways, the message is never printed,
> >> > > and the disabled wait psw never loaded because the kernel panics before that:
> >> > > - sam31 and SIGP_SET_ARCHITECTURE to ESA mode is wrong, this will break
> >> > > on the first 64bit instruction in sclp_early_printk().
> >> > > - The init stack should be used, but the stack pointer is not set up correctly
> >> > > (missing aghi %r15,-STACK_FRAME_OVERHEAD).
> >> > > - __sclp_early_printk() checks the sclp_init_state. If it is not
> >> > > sclp_init_state_uninitialized, it simply returns w/o printing anything.
> >> > > In the resumed kernel however, sclp_init_state will never be uninitialized.
> >> >
> >> > Stable patches should fix one bug, and one bug only.
> >>
> >> So should upstream patches, but the rule of "stable patches match
> >> upstream identically" overrules this :)
> >
> >a) There is no such rule for upstream.
>
> I invite you to read the docs in Documentation/process/ where you'll
> find gems like "Each logically independent change should be formatted as
> a separate patch".
>
> >b) You should split the patch if it is important enough.
> >
> >c) The "stable patches match upstream identically" rule does not
> >exist. Check the documentation.
>
> The rule in question here is that every patch that goes into -stable
> must be upstream. If we were to split this patch, it would create 2+
> patches that do not exist upstream, thus breaking our own rules.
>
> Anyway, given that this is an upstream issue, I'll also invite you to
> have this discussion with the maintainer of the subsystem this patch
> went into; you raise a valid concern which can hopefully be addressed by
> that maintainer.

It fixes the error message when suspend cpu != resume cpu, and splitting
it up would result in multiple patches where none of them would fix the
issue by itself, so they are logically connected.

Anyway, that patch did not have a cc: stable on purpose, it fixes an
esoteric special case, where the kernel would end up in disabled wait
anyway, with or without the patch. So it would be perfectly fine to not
include it in any stable update.