--- /dev/null
+From 308bf82a262c70045545cffb8593828975e49f29 Mon Sep 17 00:00:00 2001
+From: Chao Fan <fanc.fnst@cn.fujitsu.com>
+Date: Wed, 26 Dec 2018 11:34:50 +0800
+Subject: ACPI: NUMA: Use correct type for printing addresses on i386-PAE
+
+[ Upstream commit b9ced18acf68dffebe6888c7ec765a2b1db7a039 ]
+
+The addresses of NUMA nodes are not printed correctly on i386-PAE
+which is misleading.
+
+Here is a debian9-32bit with PAE in a QEMU guest having more than 4G
+of memory:
+
+qemu-system-i386 \
+-hda /var/lib/libvirt/images/debian32.qcow2 \
+-m 5G \
+-enable-kvm \
+-smp 10 \
+-numa node,mem=512M,nodeid=0,cpus=0 \
+-numa node,mem=512M,nodeid=1,cpus=1 \
+-numa node,mem=512M,nodeid=2,cpus=2 \
+-numa node,mem=512M,nodeid=3,cpus=3 \
+-numa node,mem=512M,nodeid=4,cpus=4 \
+-numa node,mem=512M,nodeid=5,cpus=5 \
+-numa node,mem=512M,nodeid=6,cpus=6 \
+-numa node,mem=512M,nodeid=7,cpus=7 \
+-numa node,mem=512M,nodeid=8,cpus=8 \
+-numa node,mem=512M,nodeid=9,cpus=9 \
+-serial stdio
+
+Because of the wrong value type, it prints as below:
+
+[ 0.021049] ACPI: SRAT Memory (0x0 length 0xa0000) in proximity domain 0 enabled
+[ 0.021740] ACPI: SRAT Memory (0x100000 length 0x1ff00000) in proximity domain 0 enabled
+[ 0.022425] ACPI: SRAT Memory (0x20000000 length 0x20000000) in proximity domain 1 enabled
+[ 0.023092] ACPI: SRAT Memory (0x40000000 length 0x20000000) in proximity domain 2 enabled
+[ 0.023764] ACPI: SRAT Memory (0x60000000 length 0x20000000) in proximity domain 3 enabled
+[ 0.024431] ACPI: SRAT Memory (0x80000000 length 0x20000000) in proximity domain 4 enabled
+[ 0.025104] ACPI: SRAT Memory (0xa0000000 length 0x20000000) in proximity domain 5 enabled
+[ 0.025791] ACPI: SRAT Memory (0x0 length 0x20000000) in proximity domain 6 enabled
+[ 0.026412] ACPI: SRAT Memory (0x20000000 length 0x20000000) in proximity domain 7 enabled
+[ 0.027118] ACPI: SRAT Memory (0x40000000 length 0x20000000) in proximity domain 8 enabled
+[ 0.027802] ACPI: SRAT Memory (0x60000000 length 0x20000000) in proximity domain 9 enabled
+
+The upper half of the start address of the NUMA domains between 6
+and 9 inclusive was cut, so the printed values are incorrect.
+
+Fix the value type, to get the correct values in the log as follows:
+
+[ 0.023698] ACPI: SRAT Memory (0x0 length 0xa0000) in proximity domain 0 enabled
+[ 0.024325] ACPI: SRAT Memory (0x100000 length 0x1ff00000) in proximity domain 0 enabled
+[ 0.024981] ACPI: SRAT Memory (0x20000000 length 0x20000000) in proximity domain 1 enabled
+[ 0.025659] ACPI: SRAT Memory (0x40000000 length 0x20000000) in proximity domain 2 enabled
+[ 0.026317] ACPI: SRAT Memory (0x60000000 length 0x20000000) in proximity domain 3 enabled
+[ 0.026980] ACPI: SRAT Memory (0x80000000 length 0x20000000) in proximity domain 4 enabled
+[ 0.027635] ACPI: SRAT Memory (0xa0000000 length 0x20000000) in proximity domain 5 enabled
+[ 0.028311] ACPI: SRAT Memory (0x100000000 length 0x20000000) in proximity domain 6 enabled
+[ 0.028985] ACPI: SRAT Memory (0x120000000 length 0x20000000) in proximity domain 7 enabled
+[ 0.029667] ACPI: SRAT Memory (0x140000000 length 0x20000000) in proximity domain 8 enabled
+[ 0.030334] ACPI: SRAT Memory (0x160000000 length 0x20000000) in proximity domain 9 enabled
+
+Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
+[ rjw: Subject & changelog ]
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/acpi/numa.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c
+index 274699463b4f..7bbbf8256a41 100644
+--- a/drivers/acpi/numa.c
++++ b/drivers/acpi/numa.c
+@@ -146,9 +146,9 @@ acpi_table_print_srat_entry(struct acpi_subtable_header *header)
+ {
+ struct acpi_srat_mem_affinity *p =
+ (struct acpi_srat_mem_affinity *)header;
+- pr_debug("SRAT Memory (0x%lx length 0x%lx) in proximity domain %d %s%s%s\n",
+- (unsigned long)p->base_address,
+- (unsigned long)p->length,
++ pr_debug("SRAT Memory (0x%llx length 0x%llx) in proximity domain %d %s%s%s\n",
++ (unsigned long long)p->base_address,
++ (unsigned long long)p->length,
+ p->proximity_domain,
+ (p->flags & ACPI_SRAT_MEM_ENABLED) ?
+ "enabled" : "disabled",
+--
+2.19.1
+
--- /dev/null
+From 8f1ea8f96de1d62316e643c27eb345de7ea28667 Mon Sep 17 00:00:00 2001
+From: Peter Ujfalusi <peter.ujfalusi@ti.com>
+Date: Wed, 19 Dec 2018 13:47:23 +0200
+Subject: ARM: dts: da850-evm: Correct the audio codec regulators
+
+[ Upstream commit 706edaa88835e3d8de8920584ad5da76dd3d6666 ]
+
+Add the board level fixed regulators for 3.3V and 1.8V which is used to
+power - among other things - the tlv320aic3106 codec.
+
+Apart from removing the following warning during boot:
+tlv320aic3x-codec 0-0018: Too high supply voltage(s) AVDD: 5000000, DVDD: 5000000
+
+With the correct voltages the driver can select correct OCMV value to
+reduce pop noise.
+
+Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
+Signed-off-by: Sekhar Nori <nsekhar@ti.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm/boot/dts/da850-evm.dts | 29 +++++++++++++++++++++++++----
+ 1 file changed, 25 insertions(+), 4 deletions(-)
+
+diff --git a/arch/arm/boot/dts/da850-evm.dts b/arch/arm/boot/dts/da850-evm.dts
+index a3c9b346721d..482a54587b44 100644
+--- a/arch/arm/boot/dts/da850-evm.dts
++++ b/arch/arm/boot/dts/da850-evm.dts
+@@ -94,6 +94,28 @@
+ regulator-boot-on;
+ };
+
++ baseboard_3v3: fixedregulator-3v3 {
++ /* TPS73701DCQ */
++ compatible = "regulator-fixed";
++ regulator-name = "baseboard_3v3";
++ regulator-min-microvolt = <3300000>;
++ regulator-max-microvolt = <3300000>;
++ vin-supply = <&vbat>;
++ regulator-always-on;
++ regulator-boot-on;
++ };
++
++ baseboard_1v8: fixedregulator-1v8 {
++ /* TPS73701DCQ */
++ compatible = "regulator-fixed";
++ regulator-name = "baseboard_1v8";
++ regulator-min-microvolt = <1800000>;
++ regulator-max-microvolt = <1800000>;
++ vin-supply = <&vbat>;
++ regulator-always-on;
++ regulator-boot-on;
++ };
++
+ backlight_lcd: backlight-regulator {
+ compatible = "regulator-fixed";
+ regulator-name = "lcd_backlight_pwr";
+@@ -210,10 +232,9 @@
+
+ /* Regulators */
+ IOVDD-supply = <&vdcdc2_reg>;
+- /* Derived from VBAT: Baseboard 3.3V / 1.8V */
+- AVDD-supply = <&vbat>;
+- DRVDD-supply = <&vbat>;
+- DVDD-supply = <&vbat>;
++ AVDD-supply = <&baseboard_3v3>;
++ DRVDD-supply = <&baseboard_3v3>;
++ DVDD-supply = <&baseboard_1v8>;
+ };
+ tca6416: gpio@20 {
+ compatible = "ti,tca6416";
+--
+2.19.1
+
--- /dev/null
+From 5cf1c3e9352c8d23978d6d33eba0d3cc5cfb2027 Mon Sep 17 00:00:00 2001
+From: Peter Ujfalusi <peter.ujfalusi@ti.com>
+Date: Wed, 19 Dec 2018 13:47:24 +0200
+Subject: ARM: dts: da850-evm: Correct the sound card name
+
+[ Upstream commit 7fca69d4e43fa1ae9cb4f652772c132dc5a659c6 ]
+
+To avoid the following error:
+asoc-simple-card sound: ASoC: Failed to create card debugfs directory
+
+Which is because the card name contains '/' character, which can not be
+used in file or directory names.
+
+Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
+Signed-off-by: Sekhar Nori <nsekhar@ti.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm/boot/dts/da850-evm.dts | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/arch/arm/boot/dts/da850-evm.dts b/arch/arm/boot/dts/da850-evm.dts
+index 482a54587b44..f04bc3e15332 100644
+--- a/arch/arm/boot/dts/da850-evm.dts
++++ b/arch/arm/boot/dts/da850-evm.dts
+@@ -127,7 +127,7 @@
+
+ sound {
+ compatible = "simple-audio-card";
+- simple-audio-card,name = "DA850/OMAP-L138 EVM";
++ simple-audio-card,name = "DA850-OMAPL138 EVM";
+ simple-audio-card,widgets =
+ "Line", "Line In",
+ "Line", "Line Out";
+--
+2.19.1
+
--- /dev/null
+From ba61cc8a7cd81153c6ee55979b503c8c8226cf11 Mon Sep 17 00:00:00 2001
+From: Peter Ujfalusi <peter.ujfalusi@ti.com>
+Date: Wed, 19 Dec 2018 13:47:25 +0200
+Subject: ARM: dts: da850-lcdk: Correct the audio codec regulators
+
+[ Upstream commit bd540ebe68c3017194a1caa38e075bbbc0832749 ]
+
+Add the board level fixed regulators for 3.3V and 1.8V which is used to
+power - among other things - the tlv320aic3106 codec.
+
+Apart from removing the following warning during boot:
+tlv320aic3x-codec 0-0018: Invalid supply voltage(s) AVDD: -22, DVDD: -22
+
+With the correct voltages the driver can select correct OCMV value to
+reduce pop noise.
+
+Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
+Signed-off-by: Sekhar Nori <nsekhar@ti.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm/boot/dts/da850-lcdk.dts | 36 ++++++++++++++++++++++++++++++++
+ 1 file changed, 36 insertions(+)
+
+diff --git a/arch/arm/boot/dts/da850-lcdk.dts b/arch/arm/boot/dts/da850-lcdk.dts
+index 0177e3ed20fe..c196e37606c4 100644
+--- a/arch/arm/boot/dts/da850-lcdk.dts
++++ b/arch/arm/boot/dts/da850-lcdk.dts
+@@ -39,6 +39,36 @@
+ };
+ };
+
++ vcc_5vd: fixedregulator-vcc_5vd {
++ compatible = "regulator-fixed";
++ regulator-name = "vcc_5vd";
++ regulator-min-microvolt = <5000000>;
++ regulator-max-microvolt = <5000000>;
++ regulator-boot-on;
++ };
++
++ vcc_3v3d: fixedregulator-vcc_3v3d {
++ /* TPS650250 - VDCDC1 */
++ compatible = "regulator-fixed";
++ regulator-name = "vcc_3v3d";
++ regulator-min-microvolt = <3300000>;
++ regulator-max-microvolt = <3300000>;
++ vin-supply = <&vcc_5vd>;
++ regulator-always-on;
++ regulator-boot-on;
++ };
++
++ vcc_1v8d: fixedregulator-vcc_1v8d {
++ /* TPS650250 - VDCDC2 */
++ compatible = "regulator-fixed";
++ regulator-name = "vcc_1v8d";
++ regulator-min-microvolt = <1800000>;
++ regulator-max-microvolt = <1800000>;
++ vin-supply = <&vcc_5vd>;
++ regulator-always-on;
++ regulator-boot-on;
++ };
++
+ sound {
+ compatible = "simple-audio-card";
+ simple-audio-card,name = "DA850/OMAP-L138 LCDK";
+@@ -221,6 +251,12 @@
+ compatible = "ti,tlv320aic3106";
+ reg = <0x18>;
+ status = "okay";
++
++ /* Regulators */
++ IOVDD-supply = <&vcc_3v3d>;
++ AVDD-supply = <&vcc_3v3d>;
++ DRVDD-supply = <&vcc_3v3d>;
++ DVDD-supply = <&vcc_1v8d>;
+ };
+ };
+
+--
+2.19.1
+
--- /dev/null
+From e89caa70c7c929877817ccf3f9d5b6de6421067b Mon Sep 17 00:00:00 2001
+From: Peter Ujfalusi <peter.ujfalusi@ti.com>
+Date: Wed, 19 Dec 2018 13:47:26 +0200
+Subject: ARM: dts: da850-lcdk: Correct the sound card name
+
+[ Upstream commit c25748acc5c20786ecb7518bfeae8fcef93472d6 ]
+
+To avoid the following error:
+asoc-simple-card sound: ASoC: Failed to create card debugfs directory
+
+Which is because the card name contains '/' character, which can not be
+used in file or directory names.
+
+Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
+Signed-off-by: Sekhar Nori <nsekhar@ti.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm/boot/dts/da850-lcdk.dts | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/arch/arm/boot/dts/da850-lcdk.dts b/arch/arm/boot/dts/da850-lcdk.dts
+index c196e37606c4..3a2fa6e035a3 100644
+--- a/arch/arm/boot/dts/da850-lcdk.dts
++++ b/arch/arm/boot/dts/da850-lcdk.dts
+@@ -71,7 +71,7 @@
+
+ sound {
+ compatible = "simple-audio-card";
+- simple-audio-card,name = "DA850/OMAP-L138 LCDK";
++ simple-audio-card,name = "DA850-OMAPL138 LCDK";
+ simple-audio-card,widgets =
+ "Line", "Line In",
+ "Line", "Line Out";
+--
+2.19.1
+
--- /dev/null
+From 4427d4078eed737155b9b7d0829317cc874bf129 Mon Sep 17 00:00:00 2001
+From: Linus Walleij <linus.walleij@linaro.org>
+Date: Tue, 8 Jan 2019 00:08:18 +0100
+Subject: ARM: dts: kirkwood: Fix polarity of GPIO fan lines
+
+[ Upstream commit b5f034845e70916fd33e172fad5ad530a29c10ab ]
+
+These two lines are active high, not active low. The bug was
+found when we changed the kernel to respect the polarity defined
+in the device tree.
+
+Fixes: 1b90e06b1429 ("ARM: kirkwood: Use devicetree to define DNS-32[05] fan")
+Cc: Jamie Lentin <jm@lentin.co.uk>
+Cc: Guenter Roeck <linux@roeck-us.net>
+Cc: Jason Cooper <jason@lakedaemon.net>
+Cc: Andrew Lunn <andrew@lunn.ch>
+Cc: Gregory Clement <gregory.clement@bootlin.com>
+Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
+Cc: Julien D'Ascenzio <jdascenzio@posteo.net>
+Reviewed-by: Andrew Lunn <andrew@lunn.ch>
+Tested-by: Jamie Lentin <jm@lentin.co.uk>
+Reported-by: Julien D'Ascenzio <jdascenzio@posteo.net>
+Tested-by: Julien D'Ascenzio <jdascenzio@posteo.net>
+Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
+Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm/boot/dts/kirkwood-dnskw.dtsi | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/arch/arm/boot/dts/kirkwood-dnskw.dtsi b/arch/arm/boot/dts/kirkwood-dnskw.dtsi
+index cbaf06f2f78e..eb917462b219 100644
+--- a/arch/arm/boot/dts/kirkwood-dnskw.dtsi
++++ b/arch/arm/boot/dts/kirkwood-dnskw.dtsi
+@@ -36,8 +36,8 @@
+ compatible = "gpio-fan";
+ pinctrl-0 = <&pmx_fan_high_speed &pmx_fan_low_speed>;
+ pinctrl-names = "default";
+- gpios = <&gpio1 14 GPIO_ACTIVE_LOW
+- &gpio1 13 GPIO_ACTIVE_LOW>;
++ gpios = <&gpio1 14 GPIO_ACTIVE_HIGH
++ &gpio1 13 GPIO_ACTIVE_HIGH>;
+ gpio-fan,speed-map = <0 0
+ 3000 1
+ 6000 2>;
+--
+2.19.1
+
--- /dev/null
+From 922df46b1a769b200dc02615f834acc7350d345f Mon Sep 17 00:00:00 2001
+From: Jianchao Wang <jianchao.w.wang@oracle.com>
+Date: Wed, 30 Jan 2019 17:01:56 +0800
+Subject: blk-mq: fix a hung issue when fsync
+
+[ Upstream commit 85bd6e61f34dffa8ec2dc75ff3c02ee7b2f1cbce ]
+
+Florian reported a io hung issue when fsync(). It should be
+triggered by following race condition.
+
+data + post flush a flush
+
+blk_flush_complete_seq
+ case REQ_FSEQ_DATA
+ blk_flush_queue_rq
+ issued to driver blk_mq_dispatch_rq_list
+ try to issue a flush req
+ failed due to NON-NCQ command
+ .queue_rq return BLK_STS_DEV_RESOURCE
+
+request completion
+ req->end_io // doesn't check RESTART
+ mq_flush_data_end_io
+ case REQ_FSEQ_POSTFLUSH
+ blk_kick_flush
+ do nothing because previous flush
+ has not been completed
+ blk_mq_run_hw_queue
+ insert rq to hctx->dispatch
+ due to RESTART is still set, do nothing
+
+To fix this, replace the blk_mq_run_hw_queue in mq_flush_data_end_io
+with blk_mq_sched_restart to check and clear the RESTART flag.
+
+Fixes: bd166ef1 (blk-mq-sched: add framework for MQ capable IO schedulers)
+Reported-by: Florian Stecker <m19@florianstecker.de>
+Tested-by: Florian Stecker <m19@florianstecker.de>
+Signed-off-by: Jianchao Wang <jianchao.w.wang@oracle.com>
+Signed-off-by: Jens Axboe <axboe@kernel.dk>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ block/blk-flush.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/block/blk-flush.c b/block/blk-flush.c
+index 8b44b86779da..87fc49daa2b4 100644
+--- a/block/blk-flush.c
++++ b/block/blk-flush.c
+@@ -424,7 +424,7 @@ static void mq_flush_data_end_io(struct request *rq, blk_status_t error)
+ blk_flush_complete_seq(rq, fq, REQ_FSEQ_DATA, error);
+ spin_unlock_irqrestore(&fq->mq_flush_lock, flags);
+
+- blk_mq_run_hw_queue(hctx, true);
++ blk_mq_sched_restart(hctx);
+ }
+
+ /**
+--
+2.19.1
+
--- /dev/null
+From 17f2bc8e0bdb19c13c5fa6cfaa97de86b576a76c Mon Sep 17 00:00:00 2001
+From: Pavel Shilovsky <pshilov@microsoft.com>
+Date: Tue, 15 Jan 2019 15:08:48 -0800
+Subject: CIFS: Do not assume one credit for async responses
+
+[ Upstream commit 0fd1d37b0501efc6e295f56ab55cdaff784aa50c ]
+
+If we don't receive a response we can't assume that the server
+granted one credit. Assume zero credits in such cases.
+
+Signed-off-by: Pavel Shilovsky <pshilov@microsoft.com>
+Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>
+Signed-off-by: Steve French <stfrench@microsoft.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/cifs/smb2pdu.c | 15 +++++++++++----
+ 1 file changed, 11 insertions(+), 4 deletions(-)
+
+diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
+index c393ac255af7..28712080add9 100644
+--- a/fs/cifs/smb2pdu.c
++++ b/fs/cifs/smb2pdu.c
+@@ -2826,9 +2826,10 @@ smb2_echo_callback(struct mid_q_entry *mid)
+ {
+ struct TCP_Server_Info *server = mid->callback_data;
+ struct smb2_echo_rsp *rsp = (struct smb2_echo_rsp *)mid->resp_buf;
+- unsigned int credits_received = 1;
++ unsigned int credits_received = 0;
+
+- if (mid->mid_state == MID_RESPONSE_RECEIVED)
++ if (mid->mid_state == MID_RESPONSE_RECEIVED
++ || mid->mid_state == MID_RESPONSE_MALFORMED)
+ credits_received = le16_to_cpu(rsp->sync_hdr.CreditRequest);
+
+ DeleteMidQEntry(mid);
+@@ -3085,7 +3086,7 @@ smb2_readv_callback(struct mid_q_entry *mid)
+ struct TCP_Server_Info *server = tcon->ses->server;
+ struct smb2_sync_hdr *shdr =
+ (struct smb2_sync_hdr *)rdata->iov[0].iov_base;
+- unsigned int credits_received = 1;
++ unsigned int credits_received = 0;
+ struct smb_rqst rqst = { .rq_iov = rdata->iov,
+ .rq_nvec = 2,
+ .rq_pages = rdata->pages,
+@@ -3124,6 +3125,9 @@ smb2_readv_callback(struct mid_q_entry *mid)
+ task_io_account_read(rdata->got_bytes);
+ cifs_stats_bytes_read(tcon, rdata->got_bytes);
+ break;
++ case MID_RESPONSE_MALFORMED:
++ credits_received = le16_to_cpu(shdr->CreditRequest);
++ /* fall through */
+ default:
+ if (rdata->result != -ENODATA)
+ rdata->result = -EIO;
+@@ -3317,7 +3321,7 @@ smb2_writev_callback(struct mid_q_entry *mid)
+ struct cifs_tcon *tcon = tlink_tcon(wdata->cfile->tlink);
+ unsigned int written;
+ struct smb2_write_rsp *rsp = (struct smb2_write_rsp *)mid->resp_buf;
+- unsigned int credits_received = 1;
++ unsigned int credits_received = 0;
+
+ switch (mid->mid_state) {
+ case MID_RESPONSE_RECEIVED:
+@@ -3345,6 +3349,9 @@ smb2_writev_callback(struct mid_q_entry *mid)
+ case MID_RETRY_NEEDED:
+ wdata->result = -EAGAIN;
+ break;
++ case MID_RESPONSE_MALFORMED:
++ credits_received = le16_to_cpu(rsp->sync_hdr.CreditRequest);
++ /* fall through */
+ default:
+ wdata->result = -EIO;
+ break;
+--
+2.19.1
+
--- /dev/null
+From 3c21d9158b050ff0d1a3ed3572c7a1fc3d09d151 Mon Sep 17 00:00:00 2001
+From: Pavel Shilovsky <pshilov@microsoft.com>
+Date: Tue, 22 Jan 2019 16:50:21 -0800
+Subject: CIFS: Fix credit calculations in compound mid callback
+
+[ Upstream commit 3d3003fce8e837acc4e3960fe3cbabebc356dcb5 ]
+
+The current code doesn't do proper accounting for credits
+in SMB1 case: it adds one credit per response only if we get
+a complete response while it needs to return it unconditionally.
+Fix this and also include malformed responses for SMB2+ into
+accounting for credits because such responses have Credit
+Granted field, thus nothing prevents to get a proper credit
+value from them.
+
+Signed-off-by: Pavel Shilovsky <pshilov@microsoft.com>
+Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>
+Signed-off-by: Steve French <stfrench@microsoft.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/cifs/smb2ops.c | 6 +++++-
+ fs/cifs/transport.c | 11 +----------
+ 2 files changed, 6 insertions(+), 11 deletions(-)
+
+diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
+index d7dd7d38fad6..aa71e620f3cd 100644
+--- a/fs/cifs/smb2ops.c
++++ b/fs/cifs/smb2ops.c
+@@ -154,7 +154,11 @@ smb2_get_credits(struct mid_q_entry *mid)
+ {
+ struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)mid->resp_buf;
+
+- return le16_to_cpu(shdr->CreditRequest);
++ if (mid->mid_state == MID_RESPONSE_RECEIVED
++ || mid->mid_state == MID_RESPONSE_MALFORMED)
++ return le16_to_cpu(shdr->CreditRequest);
++
++ return 0;
+ }
+
+ static int
+diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
+index 0dab276eced8..6f937e826910 100644
+--- a/fs/cifs/transport.c
++++ b/fs/cifs/transport.c
+@@ -784,17 +784,8 @@ static void
+ cifs_compound_callback(struct mid_q_entry *mid)
+ {
+ struct TCP_Server_Info *server = mid->server;
+- unsigned int optype = mid->optype;
+- unsigned int credits_received = 0;
+
+- if (mid->mid_state == MID_RESPONSE_RECEIVED) {
+- if (mid->resp_buf)
+- credits_received = server->ops->get_credits(mid);
+- else
+- cifs_dbg(FYI, "Bad state for cancelled MID\n");
+- }
+-
+- add_credits(server, credits_received, optype);
++ add_credits(server, server->ops->get_credits(mid), mid->optype);
+ }
+
+ static void
+--
+2.19.1
+
--- /dev/null
+From 1de8afe6486518bc34eafa8b3993f4cdbb2da6f4 Mon Sep 17 00:00:00 2001
+From: Pavel Shilovsky <pshilov@microsoft.com>
+Date: Thu, 3 Jan 2019 16:45:27 -0800
+Subject: CIFS: Fix credits calculation for cancelled requests
+
+[ Upstream commit 8a26f0f781f56d3016b34a2217e346973d067e7b ]
+
+If a request is cancelled, we can't assume that the server returns
+1 credit back. Instead we need to wait for a response and process
+the number of credits granted by the server.
+
+Create a separate mid callback for cancelled request, parse the number
+of credits in a response buffer and add them to the client's credits.
+If the didn't get a response (no response buffer available) assume
+0 credits granted. The latter most probably happens together with
+session reconnect, so the client's credits are adjusted anyway.
+
+Signed-off-by: Pavel Shilovsky <pshilov@microsoft.com>
+Signed-off-by: Steve French <stfrench@microsoft.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/cifs/cifsglob.h | 1 +
+ fs/cifs/transport.c | 28 ++++++++++++++++++++++++++--
+ 2 files changed, 27 insertions(+), 2 deletions(-)
+
+diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
+index 38ab0fca49e1..7a4fae0dc566 100644
+--- a/fs/cifs/cifsglob.h
++++ b/fs/cifs/cifsglob.h
+@@ -1426,6 +1426,7 @@ struct mid_q_entry {
+ int mid_state; /* wish this were enum but can not pass to wait_event */
+ unsigned int mid_flags;
+ __le16 command; /* smb command code */
++ unsigned int optype; /* operation type */
+ bool large_buf:1; /* if valid response, is pointer to large buf */
+ bool multiRsp:1; /* multiple trans2 responses for one request */
+ bool multiEnd:1; /* both received */
+diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
+index d51064c1ba42..4dbf62bb51b2 100644
+--- a/fs/cifs/transport.c
++++ b/fs/cifs/transport.c
+@@ -785,6 +785,24 @@ cifs_noop_callback(struct mid_q_entry *mid)
+ {
+ }
+
++static void
++cifs_cancelled_callback(struct mid_q_entry *mid)
++{
++ struct TCP_Server_Info *server = mid->server;
++ unsigned int optype = mid->optype;
++ unsigned int credits_received = 0;
++
++ if (mid->mid_state == MID_RESPONSE_RECEIVED) {
++ if (mid->resp_buf)
++ credits_received = server->ops->get_credits(mid);
++ else
++ cifs_dbg(FYI, "Bad state for cancelled MID\n");
++ }
++
++ DeleteMidQEntry(mid);
++ add_credits(server, credits_received, optype);
++}
++
+ int
+ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
+ const int flags, const int num_rqst, struct smb_rqst *rqst,
+@@ -860,6 +878,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
+ }
+
+ midQ[i]->mid_state = MID_REQUEST_SUBMITTED;
++ midQ[i]->optype = optype;
+ /*
+ * We don't invoke the callback compounds unless it is the last
+ * request.
+@@ -894,15 +913,20 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
+
+ for (i = 0; i < num_rqst; i++) {
+ rc = wait_for_response(ses->server, midQ[i]);
+- if (rc != 0) {
++ if (rc != 0)
++ break;
++ }
++ if (rc != 0) {
++ for (; i < num_rqst; i++) {
+ cifs_dbg(VFS, "Cancelling wait for mid %llu cmd: %d\n",
+ midQ[i]->mid, le16_to_cpu(midQ[i]->command));
+ send_cancel(ses->server, &rqst[i], midQ[i]);
+ spin_lock(&GlobalMid_Lock);
+ if (midQ[i]->mid_state == MID_REQUEST_SUBMITTED) {
+ midQ[i]->mid_flags |= MID_WAIT_CANCELLED;
+- midQ[i]->callback = DeleteMidQEntry;
++ midQ[i]->callback = cifs_cancelled_callback;
+ cancelled_mid[i] = true;
++ credits[i] = 0;
+ }
+ spin_unlock(&GlobalMid_Lock);
+ }
+--
+2.19.1
+
--- /dev/null
+From 5928d2898a62e58a4a77b8fd5207787445008f3c Mon Sep 17 00:00:00 2001
+From: Pavel Shilovsky <pshilov@microsoft.com>
+Date: Tue, 8 Jan 2019 11:15:28 -0800
+Subject: CIFS: Fix error paths in writeback code
+
+[ Upstream commit 9a66396f1857cc1de06f4f4771797315e1a4ea56 ]
+
+This patch aims to address writeback code problems related to error
+paths. In particular it respects EINTR and related error codes and
+stores and returns the first error occurred during writeback.
+
+Signed-off-by: Pavel Shilovsky <pshilov@microsoft.com>
+Acked-by: Jeff Layton <jlayton@kernel.org>
+Signed-off-by: Steve French <stfrench@microsoft.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/cifs/cifsglob.h | 19 +++++++++++++++++++
+ fs/cifs/cifssmb.c | 7 ++++---
+ fs/cifs/file.c | 29 +++++++++++++++++++++++------
+ fs/cifs/inode.c | 10 ++++++++++
+ 4 files changed, 56 insertions(+), 9 deletions(-)
+
+diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
+index 7a4fae0dc566..373639199291 100644
+--- a/fs/cifs/cifsglob.h
++++ b/fs/cifs/cifsglob.h
+@@ -1563,6 +1563,25 @@ static inline void free_dfs_info_array(struct dfs_info3_param *param,
+ kfree(param);
+ }
+
++static inline bool is_interrupt_error(int error)
++{
++ switch (error) {
++ case -EINTR:
++ case -ERESTARTSYS:
++ case -ERESTARTNOHAND:
++ case -ERESTARTNOINTR:
++ return true;
++ }
++ return false;
++}
++
++static inline bool is_retryable_error(int error)
++{
++ if (is_interrupt_error(error) || error == -EAGAIN)
++ return true;
++ return false;
++}
++
+ #define MID_FREE 0
+ #define MID_REQUEST_ALLOCATED 1
+ #define MID_REQUEST_SUBMITTED 2
+diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
+index fce610f6cd24..327a101f7894 100644
+--- a/fs/cifs/cifssmb.c
++++ b/fs/cifs/cifssmb.c
+@@ -2043,7 +2043,7 @@ cifs_writev_requeue(struct cifs_writedata *wdata)
+
+ for (j = 0; j < nr_pages; j++) {
+ unlock_page(wdata2->pages[j]);
+- if (rc != 0 && rc != -EAGAIN) {
++ if (rc != 0 && !is_retryable_error(rc)) {
+ SetPageError(wdata2->pages[j]);
+ end_page_writeback(wdata2->pages[j]);
+ put_page(wdata2->pages[j]);
+@@ -2052,7 +2052,7 @@ cifs_writev_requeue(struct cifs_writedata *wdata)
+
+ if (rc) {
+ kref_put(&wdata2->refcount, cifs_writedata_release);
+- if (rc == -EAGAIN)
++ if (is_retryable_error(rc))
+ continue;
+ break;
+ }
+@@ -2061,7 +2061,8 @@ cifs_writev_requeue(struct cifs_writedata *wdata)
+ i += nr_pages;
+ } while (i < wdata->nr_pages);
+
+- mapping_set_error(inode->i_mapping, rc);
++ if (rc != 0 && !is_retryable_error(rc))
++ mapping_set_error(inode->i_mapping, rc);
+ kref_put(&wdata->refcount, cifs_writedata_release);
+ }
+
+diff --git a/fs/cifs/file.c b/fs/cifs/file.c
+index 116f8af0384f..c13effbaadba 100644
+--- a/fs/cifs/file.c
++++ b/fs/cifs/file.c
+@@ -732,7 +732,8 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
+
+ if (can_flush) {
+ rc = filemap_write_and_wait(inode->i_mapping);
+- mapping_set_error(inode->i_mapping, rc);
++ if (!is_interrupt_error(rc))
++ mapping_set_error(inode->i_mapping, rc);
+
+ if (tcon->unix_ext)
+ rc = cifs_get_inode_info_unix(&inode, full_path,
+@@ -2117,6 +2118,7 @@ static int cifs_writepages(struct address_space *mapping,
+ pgoff_t end, index;
+ struct cifs_writedata *wdata;
+ int rc = 0;
++ int saved_rc = 0;
+ unsigned int xid;
+
+ /*
+@@ -2145,8 +2147,10 @@ static int cifs_writepages(struct address_space *mapping,
+
+ rc = server->ops->wait_mtu_credits(server, cifs_sb->wsize,
+ &wsize, &credits);
+- if (rc)
++ if (rc != 0) {
++ done = true;
+ break;
++ }
+
+ tofind = min((wsize / PAGE_SIZE) - 1, end - index) + 1;
+
+@@ -2154,6 +2158,7 @@ static int cifs_writepages(struct address_space *mapping,
+ &found_pages);
+ if (!wdata) {
+ rc = -ENOMEM;
++ done = true;
+ add_credits_and_wake_if(server, credits, 0);
+ break;
+ }
+@@ -2182,7 +2187,7 @@ static int cifs_writepages(struct address_space *mapping,
+ if (rc != 0) {
+ add_credits_and_wake_if(server, wdata->credits, 0);
+ for (i = 0; i < nr_pages; ++i) {
+- if (rc == -EAGAIN)
++ if (is_retryable_error(rc))
+ redirty_page_for_writepage(wbc,
+ wdata->pages[i]);
+ else
+@@ -2190,7 +2195,7 @@ static int cifs_writepages(struct address_space *mapping,
+ end_page_writeback(wdata->pages[i]);
+ put_page(wdata->pages[i]);
+ }
+- if (rc != -EAGAIN)
++ if (!is_retryable_error(rc))
+ mapping_set_error(mapping, rc);
+ }
+ kref_put(&wdata->refcount, cifs_writedata_release);
+@@ -2200,6 +2205,15 @@ static int cifs_writepages(struct address_space *mapping,
+ continue;
+ }
+
++ /* Return immediately if we received a signal during writing */
++ if (is_interrupt_error(rc)) {
++ done = true;
++ break;
++ }
++
++ if (rc != 0 && saved_rc == 0)
++ saved_rc = rc;
++
+ wbc->nr_to_write -= nr_pages;
+ if (wbc->nr_to_write <= 0)
+ done = true;
+@@ -2217,6 +2231,9 @@ static int cifs_writepages(struct address_space *mapping,
+ goto retry;
+ }
+
++ if (saved_rc != 0)
++ rc = saved_rc;
++
+ if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0))
+ mapping->writeback_index = index;
+
+@@ -2249,8 +2266,8 @@ cifs_writepage_locked(struct page *page, struct writeback_control *wbc)
+ set_page_writeback(page);
+ retry_write:
+ rc = cifs_partialpagewrite(page, 0, PAGE_SIZE);
+- if (rc == -EAGAIN) {
+- if (wbc->sync_mode == WB_SYNC_ALL)
++ if (is_retryable_error(rc)) {
++ if (wbc->sync_mode == WB_SYNC_ALL && rc == -EAGAIN)
+ goto retry_write;
+ redirty_page_for_writepage(wbc, page);
+ } else if (rc != 0) {
+diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
+index a81a9df997c1..84d51ca91ef7 100644
+--- a/fs/cifs/inode.c
++++ b/fs/cifs/inode.c
+@@ -2261,6 +2261,11 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)
+ * the flush returns error?
+ */
+ rc = filemap_write_and_wait(inode->i_mapping);
++ if (is_interrupt_error(rc)) {
++ rc = -ERESTARTSYS;
++ goto out;
++ }
++
+ mapping_set_error(inode->i_mapping, rc);
+ rc = 0;
+
+@@ -2404,6 +2409,11 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
+ * the flush returns error?
+ */
+ rc = filemap_write_and_wait(inode->i_mapping);
++ if (is_interrupt_error(rc)) {
++ rc = -ERESTARTSYS;
++ goto cifs_setattr_exit;
++ }
++
+ mapping_set_error(inode->i_mapping, rc);
+ rc = 0;
+
+--
+2.19.1
+
--- /dev/null
+From dd9c246c8911a29333be080f39facedf9033a91d Mon Sep 17 00:00:00 2001
+From: Pavel Shilovsky <pshilov@microsoft.com>
+Date: Wed, 16 Jan 2019 11:48:42 -0800
+Subject: CIFS: Fix mounts if the client is low on credits
+
+[ Upstream commit 6a9cbdd1ceca1dc2359ddf082efe61b97c3e752b ]
+
+If the server doesn't grant us at least 3 credits during the mount
+we won't be able to complete it because query path info operation
+requires 3 credits. Use the cached file handle if possible to allow
+the mount to succeed.
+
+Signed-off-by: Pavel Shilovsky <pshilov@microsoft.com>
+Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>
+Signed-off-by: Steve French <stfrench@microsoft.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/cifs/smb2inode.c | 17 +++++++++++++++++
+ 1 file changed, 17 insertions(+)
+
+diff --git a/fs/cifs/smb2inode.c b/fs/cifs/smb2inode.c
+index a8999f930b22..057d2034209f 100644
+--- a/fs/cifs/smb2inode.c
++++ b/fs/cifs/smb2inode.c
+@@ -294,6 +294,8 @@ smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
+ int rc;
+ struct smb2_file_all_info *smb2_data;
+ __u32 create_options = 0;
++ struct cifs_fid fid;
++ bool no_cached_open = tcon->nohandlecache;
+
+ *adjust_tz = false;
+ *symlink = false;
+@@ -302,6 +304,21 @@ smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
+ GFP_KERNEL);
+ if (smb2_data == NULL)
+ return -ENOMEM;
++
++ /* If it is a root and its handle is cached then use it */
++ if (!strlen(full_path) && !no_cached_open) {
++ rc = open_shroot(xid, tcon, &fid);
++ if (rc)
++ goto out;
++ rc = SMB2_query_info(xid, tcon, fid.persistent_fid,
++ fid.volatile_fid, smb2_data);
++ close_shroot(&tcon->crfid);
++ if (rc)
++ goto out;
++ move_smb2_info_to_cifs(data, smb2_data);
++ goto out;
++ }
++
+ if (backup_cred(cifs_sb))
+ create_options |= CREATE_OPEN_BACKUP_INTENT;
+
+--
+2.19.1
+
--- /dev/null
+From 4a3f68943d3ed030db135508ea3d2539b4febfe1 Mon Sep 17 00:00:00 2001
+From: Ross Lagerwall <ross.lagerwall@citrix.com>
+Date: Tue, 8 Jan 2019 18:30:56 +0000
+Subject: cifs: Limit memory used by lock request calls to a page
+
+[ Upstream commit 92a8109e4d3a34fb6b115c9098b51767dc933444 ]
+
+The code tries to allocate a contiguous buffer with a size supplied by
+the server (maxBuf). This could fail if memory is fragmented since it
+results in high order allocations for commonly used server
+implementations. It is also wasteful since there are probably
+few locks in the usual case. Limit the buffer to be no larger than a
+page to avoid memory allocation failures due to fragmentation.
+
+Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
+Signed-off-by: Steve French <stfrench@microsoft.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/cifs/file.c | 8 ++++++++
+ fs/cifs/smb2file.c | 4 ++++
+ 2 files changed, 12 insertions(+)
+
+diff --git a/fs/cifs/file.c b/fs/cifs/file.c
+index 8431854b129f..116f8af0384f 100644
+--- a/fs/cifs/file.c
++++ b/fs/cifs/file.c
+@@ -1139,6 +1139,10 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile)
+ return -EINVAL;
+ }
+
++ BUILD_BUG_ON(sizeof(struct smb_hdr) + sizeof(LOCKING_ANDX_RANGE) >
++ PAGE_SIZE);
++ max_buf = min_t(unsigned int, max_buf - sizeof(struct smb_hdr),
++ PAGE_SIZE);
+ max_num = (max_buf - sizeof(struct smb_hdr)) /
+ sizeof(LOCKING_ANDX_RANGE);
+ buf = kcalloc(max_num, sizeof(LOCKING_ANDX_RANGE), GFP_KERNEL);
+@@ -1477,6 +1481,10 @@ cifs_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock,
+ if (max_buf < (sizeof(struct smb_hdr) + sizeof(LOCKING_ANDX_RANGE)))
+ return -EINVAL;
+
++ BUILD_BUG_ON(sizeof(struct smb_hdr) + sizeof(LOCKING_ANDX_RANGE) >
++ PAGE_SIZE);
++ max_buf = min_t(unsigned int, max_buf - sizeof(struct smb_hdr),
++ PAGE_SIZE);
+ max_num = (max_buf - sizeof(struct smb_hdr)) /
+ sizeof(LOCKING_ANDX_RANGE);
+ buf = kcalloc(max_num, sizeof(LOCKING_ANDX_RANGE), GFP_KERNEL);
+diff --git a/fs/cifs/smb2file.c b/fs/cifs/smb2file.c
+index 2fc3d31967ee..b204e84b87fb 100644
+--- a/fs/cifs/smb2file.c
++++ b/fs/cifs/smb2file.c
+@@ -128,6 +128,8 @@ smb2_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock,
+ if (max_buf < sizeof(struct smb2_lock_element))
+ return -EINVAL;
+
++ BUILD_BUG_ON(sizeof(struct smb2_lock_element) > PAGE_SIZE);
++ max_buf = min_t(unsigned int, max_buf, PAGE_SIZE);
+ max_num = max_buf / sizeof(struct smb2_lock_element);
+ buf = kcalloc(max_num, sizeof(struct smb2_lock_element), GFP_KERNEL);
+ if (!buf)
+@@ -264,6 +266,8 @@ smb2_push_mandatory_locks(struct cifsFileInfo *cfile)
+ return -EINVAL;
+ }
+
++ BUILD_BUG_ON(sizeof(struct smb2_lock_element) > PAGE_SIZE);
++ max_buf = min_t(unsigned int, max_buf, PAGE_SIZE);
+ max_num = max_buf / sizeof(struct smb2_lock_element);
+ buf = kcalloc(max_num, sizeof(struct smb2_lock_element), GFP_KERNEL);
+ if (!buf) {
+--
+2.19.1
+
--- /dev/null
+From bc1c0eb7aa17ae69ab571de0fc0e332ae45b0908 Mon Sep 17 00:00:00 2001
+From: Pavel Shilovsky <pshilov@microsoft.com>
+Date: Thu, 3 Jan 2019 15:53:10 -0800
+Subject: CIFS: Move credit processing to mid callbacks for SMB3
+
+[ Upstream commit ee258d79159afed52ca9372aeb9c1a51e89b32ee ]
+
+Currently we account for credits in the thread initiating a request
+and waiting for a response. The demultiplex thread receives the response,
+wakes up the thread and the latter collects credits from the response
+buffer and add them to the server structure on the client. This approach
+is not accurate, because it may race with reconnect events in the
+demultiplex thread which resets the number of credits.
+
+Fix this by moving credit processing to new mid callbacks that collect
+credits granted by the server from the response in the demultiplex thread.
+
+Signed-off-by: Pavel Shilovsky <pshilov@microsoft.com>
+Signed-off-by: Steve French <stfrench@microsoft.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/cifs/transport.c | 51 ++++++++++++++++++++++++++++++---------------
+ 1 file changed, 34 insertions(+), 17 deletions(-)
+
+diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
+index 4dbf62bb51b2..0dab276eced8 100644
+--- a/fs/cifs/transport.c
++++ b/fs/cifs/transport.c
+@@ -781,12 +781,7 @@ cifs_setup_request(struct cifs_ses *ses, struct smb_rqst *rqst)
+ }
+
+ static void
+-cifs_noop_callback(struct mid_q_entry *mid)
+-{
+-}
+-
+-static void
+-cifs_cancelled_callback(struct mid_q_entry *mid)
++cifs_compound_callback(struct mid_q_entry *mid)
+ {
+ struct TCP_Server_Info *server = mid->server;
+ unsigned int optype = mid->optype;
+@@ -799,10 +794,23 @@ cifs_cancelled_callback(struct mid_q_entry *mid)
+ cifs_dbg(FYI, "Bad state for cancelled MID\n");
+ }
+
+- DeleteMidQEntry(mid);
+ add_credits(server, credits_received, optype);
+ }
+
++static void
++cifs_compound_last_callback(struct mid_q_entry *mid)
++{
++ cifs_compound_callback(mid);
++ cifs_wake_up_task(mid);
++}
++
++static void
++cifs_cancelled_callback(struct mid_q_entry *mid)
++{
++ cifs_compound_callback(mid);
++ DeleteMidQEntry(mid);
++}
++
+ int
+ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
+ const int flags, const int num_rqst, struct smb_rqst *rqst,
+@@ -880,11 +888,14 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
+ midQ[i]->mid_state = MID_REQUEST_SUBMITTED;
+ midQ[i]->optype = optype;
+ /*
+- * We don't invoke the callback compounds unless it is the last
+- * request.
++ * Invoke callback for every part of the compound chain
++ * to calculate credits properly. Wake up this thread only when
++ * the last element is received.
+ */
+ if (i < num_rqst - 1)
+- midQ[i]->callback = cifs_noop_callback;
++ midQ[i]->callback = cifs_compound_callback;
++ else
++ midQ[i]->callback = cifs_compound_last_callback;
+ }
+ cifs_in_send_inc(ses->server);
+ rc = smb_send_rqst(ses->server, num_rqst, rqst, flags);
+@@ -898,8 +909,20 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
+
+ mutex_unlock(&ses->server->srv_mutex);
+
+- if (rc < 0)
++ if (rc < 0) {
++ /* Sending failed for some reason - return credits back */
++ for (i = 0; i < num_rqst; i++)
++ add_credits(ses->server, credits[i], optype);
+ goto out;
++ }
++
++ /*
++ * At this point the request is passed to the network stack - we assume
++ * that any credits taken from the server structure on the client have
++ * been spent and we can't return them back. Once we receive responses
++ * we will collect credits granted by the server in the mid callbacks
++ * and add those credits to the server structure.
++ */
+
+ /*
+ * Compounding is never used during session establish.
+@@ -932,11 +955,6 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
+ }
+ }
+
+- for (i = 0; i < num_rqst; i++)
+- if (!cancelled_mid[i] && midQ[i]->resp_buf
+- && (midQ[i]->mid_state == MID_RESPONSE_RECEIVED))
+- credits[i] = ses->server->ops->get_credits(midQ[i]);
+-
+ for (i = 0; i < num_rqst; i++) {
+ if (rc < 0)
+ goto out;
+@@ -995,7 +1013,6 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
+ for (i = 0; i < num_rqst; i++) {
+ if (!cancelled_mid[i])
+ cifs_delete_mid(midQ[i]);
+- add_credits(ses->server, credits[i], optype);
+ }
+
+ return rc;
+--
+2.19.1
+
--- /dev/null
+From 1a852659be424844db91e6ad537cd1b4f1535fe1 Mon Sep 17 00:00:00 2001
+From: Sudeep Holla <sudeep.holla@arm.com>
+Date: Mon, 7 Jan 2019 18:51:53 +0000
+Subject: cpufreq: check if policy is inactive early in __cpufreq_get()
+
+[ Upstream commit 2f66196208c98b3d1b4294edffb2c5a8197be899 ]
+
+cpuinfo_cur_freq gets current CPU frequency as detected by hardware
+while scaling_cur_freq last known CPU frequency. Some platforms may not
+allow checking the CPU frequency of an offline CPU or the associated
+resources may have been released via cpufreq_exit when the CPU gets
+offlined, in which case the policy would have been invalidated already.
+If we attempt to get current frequency from the hardware, it may result
+in hang or crash.
+
+For example on Juno, I see:
+
+Unable to handle kernel NULL pointer dereference at virtual address 0000000000000188
+[0000000000000188] pgd=0000000000000000
+Internal error: Oops: 96000004 [#1] PREEMPT SMP
+Modules linked in:
+CPU: 5 PID: 4202 Comm: cat Not tainted 4.20.0-08251-ga0f2c0318a15-dirty #87
+Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno Development Platform
+pstate: 40000005 (nZcv daif -PAN -UAO)
+pc : scmi_cpufreq_get_rate+0x34/0xb0
+lr : scmi_cpufreq_get_rate+0x34/0xb0
+Call trace:
+ scmi_cpufreq_get_rate+0x34/0xb0
+ __cpufreq_get+0x34/0xc0
+ show_cpuinfo_cur_freq+0x24/0x78
+ show+0x40/0x60
+ sysfs_kf_seq_show+0xc0/0x148
+ kernfs_seq_show+0x44/0x50
+ seq_read+0xd4/0x480
+ kernfs_fop_read+0x15c/0x208
+ __vfs_read+0x60/0x188
+ vfs_read+0x94/0x150
+ ksys_read+0x6c/0xd8
+ __arm64_sys_read+0x24/0x30
+ el0_svc_common+0x78/0x100
+ el0_svc_handler+0x38/0x78
+ el0_svc+0x8/0xc
+---[ end trace 3d1024e58f77f6b2 ]---
+
+So fix the issue by checking if the policy is invalid early in
+__cpufreq_get before attempting to get the current frequency.
+
+Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
+Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/cpufreq/cpufreq.c | 12 ++++--------
+ 1 file changed, 4 insertions(+), 8 deletions(-)
+
+diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
+index 7aa3dcad2175..df34a12a388f 100644
+--- a/drivers/cpufreq/cpufreq.c
++++ b/drivers/cpufreq/cpufreq.c
+@@ -1530,17 +1530,16 @@ static unsigned int __cpufreq_get(struct cpufreq_policy *policy)
+ {
+ unsigned int ret_freq = 0;
+
+- if (!cpufreq_driver->get)
++ if (unlikely(policy_is_inactive(policy)) || !cpufreq_driver->get)
+ return ret_freq;
+
+ ret_freq = cpufreq_driver->get(policy->cpu);
+
+ /*
+- * Updating inactive policies is invalid, so avoid doing that. Also
+- * if fast frequency switching is used with the given policy, the check
++ * If fast frequency switching is used with the given policy, the check
+ * against policy->cur is pointless, so skip it in that case too.
+ */
+- if (unlikely(policy_is_inactive(policy)) || policy->fast_switch_enabled)
++ if (policy->fast_switch_enabled)
+ return ret_freq;
+
+ if (ret_freq && policy->cur &&
+@@ -1569,10 +1568,7 @@ unsigned int cpufreq_get(unsigned int cpu)
+
+ if (policy) {
+ down_read(&policy->rwsem);
+-
+- if (!policy_is_inactive(policy))
+- ret_freq = __cpufreq_get(policy);
+-
++ ret_freq = __cpufreq_get(policy);
+ up_read(&policy->rwsem);
+
+ cpufreq_cpu_put(policy);
+--
+2.19.1
+
--- /dev/null
+From ceb481c342a0adfc6b807535a9bca4c1f9f00525 Mon Sep 17 00:00:00 2001
+From: Guo Ren <ren_guo@c-sky.com>
+Date: Tue, 8 Jan 2019 20:17:49 +0800
+Subject: csky: fixup CACHEV1 store instruction fast retire
+
+[ Upstream commit 96354ad79e2e59f9d620669c8e1ac2452440c260 ]
+
+For I/O access, 810/807 store instruction fast retire will cause wrong
+primitive. For example:
+
+ stw (clear interrupt source)
+ stw (unmask interrupt controller)
+ enable interrupt
+
+stw is fast retire instruction. When PC is run at enable interrupt
+stage, the clear interrupt source hasn't finished. It will cause another
+wrong irq-enter.
+
+So use mb() to prevent above.
+
+Signed-off-by: Guo Ren <ren_guo@c-sky.com>
+Cc: Lu Baoquan <lu.baoquan@intellif.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/csky/include/asm/io.h | 25 +++++++++++++++++++++++++
+ 1 file changed, 25 insertions(+)
+
+diff --git a/arch/csky/include/asm/io.h b/arch/csky/include/asm/io.h
+index ecae6b358f95..c1dfa9c10e36 100644
+--- a/arch/csky/include/asm/io.h
++++ b/arch/csky/include/asm/io.h
+@@ -15,6 +15,31 @@ extern void iounmap(void *addr);
+ extern int remap_area_pages(unsigned long address, phys_addr_t phys_addr,
+ size_t size, unsigned long flags);
+
++/*
++ * I/O memory access primitives. Reads are ordered relative to any
++ * following Normal memory access. Writes are ordered relative to any prior
++ * Normal memory access.
++ *
++ * For CACHEV1 (807, 810), store instruction could fast retire, so we need
++ * another mb() to prevent st fast retire.
++ *
++ * For CACHEV2 (860), store instruction with PAGE_ATTR_NO_BUFFERABLE won't
++ * fast retire.
++ */
++#define readb(c) ({ u8 __v = readb_relaxed(c); rmb(); __v; })
++#define readw(c) ({ u16 __v = readw_relaxed(c); rmb(); __v; })
++#define readl(c) ({ u32 __v = readl_relaxed(c); rmb(); __v; })
++
++#ifdef CONFIG_CPU_HAS_CACHEV2
++#define writeb(v,c) ({ wmb(); writeb_relaxed((v),(c)); })
++#define writew(v,c) ({ wmb(); writew_relaxed((v),(c)); })
++#define writel(v,c) ({ wmb(); writel_relaxed((v),(c)); })
++#else
++#define writeb(v,c) ({ wmb(); writeb_relaxed((v),(c)); mb(); })
++#define writew(v,c) ({ wmb(); writew_relaxed((v),(c)); mb(); })
++#define writel(v,c) ({ wmb(); writel_relaxed((v),(c)); mb(); })
++#endif
++
+ #define ioremap_nocache(phy, sz) ioremap(phy, sz)
+ #define ioremap_wc ioremap_nocache
+ #define ioremap_wt ioremap_nocache
+--
+2.19.1
+
--- /dev/null
+From b246cbbfb930463ecc0e20a623fa8dbc4e411aae Mon Sep 17 00:00:00 2001
+From: Guo Ren <ren_guo@c-sky.com>
+Date: Thu, 10 Jan 2019 20:28:39 +0800
+Subject: csky: fixup compile error with CPU 810.
+
+[ Upstream commit 70c25259537c073584eb906865307687275b527f ]
+
+This bug is from commit f553aa1c13cb ("csky: fixup relocation error with
+807 & 860").
+
+I forgot to compile with 810 for that patch.
+
+Signed-off-by: Guo Ren <ren_guo@c-sky.com>
+Cc: Arnd Bergmann <arnd@arndb.de>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/csky/kernel/module.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/arch/csky/kernel/module.c b/arch/csky/kernel/module.c
+index 0b028ee3c764..b5ad7d9de18c 100644
+--- a/arch/csky/kernel/module.c
++++ b/arch/csky/kernel/module.c
+@@ -28,7 +28,7 @@
+
+ static void jsri_2_lrw_jsr(uint32_t *location)
+ {
+- uint16_t location_tmp = (uint16_t *)location;
++ uint16_t *location_tmp = (uint16_t *)location;
+
+ if (IS_BSR32(*location_tmp, *(location_tmp + 1)))
+ return;
+--
+2.19.1
+
--- /dev/null
+From 3860dbedc2641348c1b6a2d7cdfd0e069d3cc01e Mon Sep 17 00:00:00 2001
+From: Guo Ren <ren_guo@c-sky.com>
+Date: Tue, 8 Jan 2019 20:31:43 +0800
+Subject: csky: fixup compile error with pte_alloc
+
+[ Upstream commit 2a60aa14a9a0333b3eef58150bc1ef654f7321ef ]
+
+Commit: 4cf58924951e remove the address argument of pte_alloc without
+modify csky related code. linux-5.0-rc1 compile failed with csky.
+
+Remove the unnecessary address testing in pte_alloc().
+
+Signed-off-by: Guo Ren <ren_guo@c-sky.com>
+Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
+Cc: Guenter Roeck <linux@roeck-us.net>
+Cc: Arnd Bergmann <arnd@arndb.de>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/csky/include/asm/pgalloc.h | 43 ++++++++++++++-------------------
+ 1 file changed, 18 insertions(+), 25 deletions(-)
+
+diff --git a/arch/csky/include/asm/pgalloc.h b/arch/csky/include/asm/pgalloc.h
+index bf4f4a0e140e..d213bb47b717 100644
+--- a/arch/csky/include/asm/pgalloc.h
++++ b/arch/csky/include/asm/pgalloc.h
+@@ -24,41 +24,34 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
+
+ extern void pgd_init(unsigned long *p);
+
+-static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
+- unsigned long address)
++static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
+ {
+ pte_t *pte;
+- unsigned long *kaddr, i;
++ unsigned long i;
+
+- pte = (pte_t *) __get_free_pages(GFP_KERNEL | __GFP_RETRY_MAYFAIL,
+- PTE_ORDER);
+- kaddr = (unsigned long *)pte;
+- if (address & 0x80000000)
+- for (i = 0; i < (PAGE_SIZE/4); i++)
+- *(kaddr + i) = 0x1;
+- else
+- clear_page(kaddr);
++ pte = (pte_t *) __get_free_page(GFP_KERNEL);
++ if (!pte)
++ return NULL;
++
++ for (i = 0; i < PAGE_SIZE/sizeof(pte_t); i++)
++ (pte + i)->pte_low = _PAGE_GLOBAL;
+
+ return pte;
+ }
+
+-static inline struct page *pte_alloc_one(struct mm_struct *mm,
+- unsigned long address)
++static inline struct page *pte_alloc_one(struct mm_struct *mm)
+ {
+ struct page *pte;
+- unsigned long *kaddr, i;
+-
+- pte = alloc_pages(GFP_KERNEL | __GFP_RETRY_MAYFAIL, PTE_ORDER);
+- if (pte) {
+- kaddr = kmap_atomic(pte);
+- if (address & 0x80000000) {
+- for (i = 0; i < (PAGE_SIZE/4); i++)
+- *(kaddr + i) = 0x1;
+- } else
+- clear_page(kaddr);
+- kunmap_atomic(kaddr);
+- pgtable_page_ctor(pte);
++
++ pte = alloc_pages(GFP_KERNEL | __GFP_ZERO, 0);
++ if (!pte)
++ return NULL;
++
++ if (!pgtable_page_ctor(pte)) {
++ __free_page(pte);
++ return NULL;
+ }
++
+ return pte;
+ }
+
+--
+2.19.1
+
--- /dev/null
+From d92439d5ae0e543ab802bcc21c377e99661b5a03 Mon Sep 17 00:00:00 2001
+From: Guo Ren <ren_guo@c-sky.com>
+Date: Tue, 8 Jan 2019 19:52:22 +0800
+Subject: csky: fixup relocation error with 807 & 860
+
+[ Upstream commit f553aa1c13cbc29aaf420349a28fc33ca98440e5 ]
+
+810 doesn't support jsri instruction and csky-as will leave
+jsri + nop for relocation. Module-probe need replace them with
+lrw + jsr.
+
+Signed-off-by: Guo Ren <ren_guo@c-sky.com>
+Cc: Hui Kai <huikai@acoinfo.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/csky/kernel/module.c | 38 ++++++++++++++++++++++----------------
+ 1 file changed, 22 insertions(+), 16 deletions(-)
+
+diff --git a/arch/csky/kernel/module.c b/arch/csky/kernel/module.c
+index 65abab0c7a47..0b028ee3c764 100644
+--- a/arch/csky/kernel/module.c
++++ b/arch/csky/kernel/module.c
+@@ -12,7 +12,7 @@
+ #include <linux/spinlock.h>
+ #include <asm/pgtable.h>
+
+-#if defined(__CSKYABIV2__)
++#ifdef CONFIG_CPU_CK810
+ #define IS_BSR32(hi16, lo16) (((hi16) & 0xFC00) == 0xE000)
+ #define IS_JSRI32(hi16, lo16) ((hi16) == 0xEAE0)
+
+@@ -25,6 +25,26 @@
+ *(uint16_t *)(addr) = 0xE8Fa; \
+ *((uint16_t *)(addr) + 1) = 0x0000; \
+ } while (0)
++
++static void jsri_2_lrw_jsr(uint32_t *location)
++{
++ uint16_t location_tmp = (uint16_t *)location;
++
++ if (IS_BSR32(*location_tmp, *(location_tmp + 1)))
++ return;
++
++ if (IS_JSRI32(*location_tmp, *(location_tmp + 1))) {
++ /* jsri 0x... --> lrw r26, 0x... */
++ CHANGE_JSRI_TO_LRW(location);
++ /* lsli r0, r0 --> jsr r26 */
++ SET_JSR32_R26(location + 1);
++ }
++}
++#else
++static void inline jsri_2_lrw_jsr(uint32_t *location)
++{
++ return;
++}
+ #endif
+
+ int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab,
+@@ -35,9 +55,6 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab,
+ Elf32_Sym *sym;
+ uint32_t *location;
+ short *temp;
+-#if defined(__CSKYABIV2__)
+- uint16_t *location_tmp;
+-#endif
+
+ for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
+ /* This is where to make the change */
+@@ -59,18 +76,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab,
+ case R_CSKY_PCRELJSR_IMM11BY2:
+ break;
+ case R_CSKY_PCRELJSR_IMM26BY2:
+-#if defined(__CSKYABIV2__)
+- location_tmp = (uint16_t *)location;
+- if (IS_BSR32(*location_tmp, *(location_tmp + 1)))
+- break;
+-
+- if (IS_JSRI32(*location_tmp, *(location_tmp + 1))) {
+- /* jsri 0x... --> lrw r26, 0x... */
+- CHANGE_JSRI_TO_LRW(location);
+- /* lsli r0, r0 --> jsr r26 */
+- SET_JSR32_R26(location + 1);
+- }
+-#endif
++ jsri_2_lrw_jsr(location);
+ break;
+ case R_CSKY_ADDR_HI16:
+ temp = ((short *)location) + 1;
+--
+2.19.1
+
--- /dev/null
+From cbf519c647a8978f646591a15f04911dc3959c25 Mon Sep 17 00:00:00 2001
+From: Evan Quan <evan.quan@amd.com>
+Date: Tue, 8 Jan 2019 10:33:35 +0800
+Subject: drm/amd/powerplay: avoid possible buffer overflow
+
+[ Upstream commit fff0d3f7686942bd544b53a48d1b76bd62c46946 ]
+
+Make sure the clock level enforced is within the allowed
+ranges.
+
+Signed-off-by: Evan Quan <evan.quan@amd.com>
+Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
+Reviewed-by: Likun Gao <Likun.Gao@amd.com>
+Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c | 14 ++++++++++++++
+ 1 file changed, 14 insertions(+)
+
+diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c
+index 3b7fce5d7258..b9e19b0eb905 100644
+--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c
++++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c
+@@ -2244,6 +2244,13 @@ static int vega20_force_clock_level(struct pp_hwmgr *hwmgr,
+ soft_min_level = mask ? (ffs(mask) - 1) : 0;
+ soft_max_level = mask ? (fls(mask) - 1) : 0;
+
++ if (soft_max_level >= data->dpm_table.gfx_table.count) {
++ pr_err("Clock level specified %d is over max allowed %d\n",
++ soft_max_level,
++ data->dpm_table.gfx_table.count - 1);
++ return -EINVAL;
++ }
++
+ data->dpm_table.gfx_table.dpm_state.soft_min_level =
+ data->dpm_table.gfx_table.dpm_levels[soft_min_level].value;
+ data->dpm_table.gfx_table.dpm_state.soft_max_level =
+@@ -2264,6 +2271,13 @@ static int vega20_force_clock_level(struct pp_hwmgr *hwmgr,
+ soft_min_level = mask ? (ffs(mask) - 1) : 0;
+ soft_max_level = mask ? (fls(mask) - 1) : 0;
+
++ if (soft_max_level >= data->dpm_table.mem_table.count) {
++ pr_err("Clock level specified %d is over max allowed %d\n",
++ soft_max_level,
++ data->dpm_table.mem_table.count - 1);
++ return -EINVAL;
++ }
++
+ data->dpm_table.mem_table.dpm_state.soft_min_level =
+ data->dpm_table.mem_table.dpm_levels[soft_min_level].value;
+ data->dpm_table.mem_table.dpm_state.soft_max_level =
+--
+2.19.1
+
--- /dev/null
+From a91a0bf8d3e47223e05faefaec96b56fecaf9cd8 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Christian=20K=C3=B6nig?= <christian.koenig@amd.com>
+Date: Mon, 7 Jan 2019 14:43:55 +0100
+Subject: drm/amdgpu: disable system memory page tables for now
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+[ Upstream commit 1c1eba86339c8517814863bc7dd21e2661a84e77 ]
+
+We hit a problem with IOMMU with that. Disable until we have time to
+debug further.
+
+Signed-off-by: Christian König <christian.koenig@amd.com>
+Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
+Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 ---
+ 1 file changed, 3 deletions(-)
+
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+index 0877ff9a9594..8c9abaa7601a 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+@@ -850,9 +850,6 @@ static void amdgpu_vm_bo_param(struct amdgpu_device *adev, struct amdgpu_vm *vm,
+ bp->size = amdgpu_vm_bo_size(adev, level);
+ bp->byte_align = AMDGPU_GPU_PAGE_SIZE;
+ bp->domain = AMDGPU_GEM_DOMAIN_VRAM;
+- if (bp->size <= PAGE_SIZE && adev->asic_type >= CHIP_VEGA10 &&
+- adev->flags & AMD_IS_APU)
+- bp->domain |= AMDGPU_GEM_DOMAIN_GTT;
+ bp->domain = amdgpu_bo_get_preferred_pin_domain(adev, bp->domain);
+ bp->flags = AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS |
+ AMDGPU_GEM_CREATE_CPU_GTT_USWC;
+--
+2.19.1
+
--- /dev/null
+From 1f0af95124c64cba6d53d5527b60d6134ca46579 Mon Sep 17 00:00:00 2001
+From: Tao Zhou <tao.zhou1@amd.com>
+Date: Tue, 8 Jan 2019 15:08:44 +0800
+Subject: drm/amdgpu: fix CPDMA hang in PRT mode for VEGA20
+
+[ Upstream commit 3e958fe67720b37d04ab8ef81b9d507a56a09bbc ]
+
+Fix CPDMA hang in PRT mode for both VEGA10 and VEGA20
+
+Signed-off-by: Tao Zhou <tao.zhou1@amd.com>
+Tested-by: Yukun.Li <yukun1.li@amd.com>
+Acked-by: Alex Deucher <alexander.deucher@amd.com>
+Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+index 21363b2b2ee5..88ed064b3585 100644
+--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
++++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+@@ -112,7 +112,10 @@ static const struct soc15_reg_golden golden_settings_gc_9_0[] =
+ SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_HI, 0xffffffff, 0x4a2c0e68),
+ SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_LO, 0xffffffff, 0xb5d3f197),
+ SOC15_REG_GOLDEN_VALUE(GC, 0, mmVGT_CACHE_INVALIDATION, 0x3fff3af3, 0x19200000),
+- SOC15_REG_GOLDEN_VALUE(GC, 0, mmVGT_GS_MAX_WAVE_ID, 0x00000fff, 0x000003ff)
++ SOC15_REG_GOLDEN_VALUE(GC, 0, mmVGT_GS_MAX_WAVE_ID, 0x00000fff, 0x000003ff),
++ SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_MEC1_F32_INT_DIS, 0x00000000, 0x00000800),
++ SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_MEC2_F32_INT_DIS, 0x00000000, 0x00000800),
++ SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_DEBUG, 0x00000000, 0x00008000)
+ };
+
+ static const struct soc15_reg_golden golden_settings_gc_9_0_vg10[] =
+@@ -134,10 +137,7 @@ static const struct soc15_reg_golden golden_settings_gc_9_0_vg10[] =
+ SOC15_REG_GOLDEN_VALUE(GC, 0, mmRMI_UTCL1_CNTL2, 0x00030000, 0x00020000),
+ SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_CONFIG_CNTL_1, 0x0000000f, 0x01000107),
+ SOC15_REG_GOLDEN_VALUE(GC, 0, mmTD_CNTL, 0x00001800, 0x00000800),
+- SOC15_REG_GOLDEN_VALUE(GC, 0, mmWD_UTCL1_CNTL, 0x08000000, 0x08000080),
+- SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_MEC1_F32_INT_DIS, 0x00000000, 0x00000800),
+- SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_MEC2_F32_INT_DIS, 0x00000000, 0x00000800),
+- SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_DEBUG, 0x00000000, 0x00008000)
++ SOC15_REG_GOLDEN_VALUE(GC, 0, mmWD_UTCL1_CNTL, 0x08000000, 0x08000080)
+ };
+
+ static const struct soc15_reg_golden golden_settings_gc_9_0_vg20[] =
+--
+2.19.1
+
--- /dev/null
+From 60721122c96e4606d0cb85c2003f519494afcb02 Mon Sep 17 00:00:00 2001
+From: Jim Qu <Jim.Qu@amd.com>
+Date: Mon, 17 Dec 2018 17:00:50 +0800
+Subject: drm/amdgpu: set WRITE_BURST_LENGTH to 64B to workaround SDMA1 hang
+
+[ Upstream commit 0c6c8125582714e1fd3544983eba3d750db0f5b8 ]
+
+effect asics: VEGA10 and VEGA12
+
+Signed-off-by: Jim Qu <Jim.Qu@amd.com>
+Acked-by: Alex Deucher <alexander.deucher@amd.com>
+Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
+index 7a8c9172d30a..86d5dc5f8887 100644
+--- a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
++++ b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
+@@ -73,7 +73,6 @@ static const struct soc15_reg_golden golden_settings_sdma_4[] = {
+ SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_RLC1_RB_WPTR_POLL_CNTL, 0x0000fff0, 0x00403000),
+ SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_UTCL1_PAGE, 0x000003ff, 0x000003c0),
+ SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_UTCL1_WATERMK, 0xfc000000, 0x00000000),
+- SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_CHICKEN_BITS, 0xfe931f07, 0x02831f07),
+ SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_CLK_CTRL, 0xffffffff, 0x3f000100),
+ SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_GFX_IB_CNTL, 0x800f0100, 0x00000100),
+ SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_GFX_RB_WPTR_POLL_CNTL, 0x0000fff0, 0x00403000),
+@@ -91,6 +90,7 @@ static const struct soc15_reg_golden golden_settings_sdma_4[] = {
+ static const struct soc15_reg_golden golden_settings_sdma_vg10[] = {
+ SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_GB_ADDR_CONFIG, 0x0018773f, 0x00104002),
+ SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_GB_ADDR_CONFIG_READ, 0x0018773f, 0x00104002),
++ SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_CHICKEN_BITS, 0xfe931f07, 0x02831d07),
+ SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_GB_ADDR_CONFIG, 0x0018773f, 0x00104002),
+ SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_GB_ADDR_CONFIG_READ, 0x0018773f, 0x00104002)
+ };
+@@ -98,6 +98,7 @@ static const struct soc15_reg_golden golden_settings_sdma_vg10[] = {
+ static const struct soc15_reg_golden golden_settings_sdma_vg12[] = {
+ SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_GB_ADDR_CONFIG, 0x0018773f, 0x00104001),
+ SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_GB_ADDR_CONFIG_READ, 0x0018773f, 0x00104001),
++ SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_CHICKEN_BITS, 0xfe931f07, 0x02831d07),
+ SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_GB_ADDR_CONFIG, 0x0018773f, 0x00104001),
+ SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_GB_ADDR_CONFIG_READ, 0x0018773f, 0x00104001)
+ };
+--
+2.19.1
+
--- /dev/null
+From d8317ce3ed77fe373b8a22db984b6ec607d537fd Mon Sep 17 00:00:00 2001
+From: Emily Deng <Emily.Deng@amd.com>
+Date: Sat, 29 Dec 2018 17:46:05 +0800
+Subject: drm/amdgpu/sriov:Correct pfvf exchange logic
+
+[ Upstream commit b8cf66182eddb22e9c7539821ed6eecdb4f86d1a ]
+
+The pfvf exchange need be in exclusive mode. And add pfvf exchange in gpu
+reset.
+
+Signed-off-by: Emily Deng <Emily.Deng@amd.com>
+Reviewed-By: Xiangliang Yu <Xiangliang.Yu@amd.com>
+Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++++----
+ drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c | 2 +-
+ 2 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+index 30bc345d6fdf..8547fdaf8273 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+@@ -1684,8 +1684,10 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
+ amdgpu_xgmi_add_device(adev);
+ amdgpu_amdkfd_device_init(adev);
+
+- if (amdgpu_sriov_vf(adev))
++ if (amdgpu_sriov_vf(adev)) {
++ amdgpu_virt_init_data_exchange(adev);
+ amdgpu_virt_release_full_gpu(adev, true);
++ }
+
+ return 0;
+ }
+@@ -2597,9 +2599,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,
+ goto failed;
+ }
+
+- if (amdgpu_sriov_vf(adev))
+- amdgpu_virt_init_data_exchange(adev);
+-
+ amdgpu_fbdev_init(adev);
+
+ r = amdgpu_pm_sysfs_init(adev);
+@@ -3271,6 +3270,7 @@ static int amdgpu_device_reset_sriov(struct amdgpu_device *adev,
+ r = amdgpu_ib_ring_tests(adev);
+
+ error:
++ amdgpu_virt_init_data_exchange(adev);
+ amdgpu_virt_release_full_gpu(adev, true);
+ if (!r && adev->virt.gim_feature & AMDGIM_FEATURE_GIM_FLR_VRAMLOST) {
+ atomic_inc(&adev->vram_lost_counter);
+diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c
+index 8cbb4655896a..b11a1c17a7f2 100644
+--- a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c
++++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c
+@@ -174,7 +174,7 @@ static int xgpu_ai_send_access_requests(struct amdgpu_device *adev,
+ return r;
+ }
+ /* Retrieve checksum from mailbox2 */
+- if (req == IDH_REQ_GPU_INIT_ACCESS) {
++ if (req == IDH_REQ_GPU_INIT_ACCESS || req == IDH_REQ_GPU_RESET_ACCESS) {
+ adev->virt.fw_reserve.checksum_key =
+ RREG32_NO_KIQ(SOC15_REG_OFFSET(NBIO, 0,
+ mmBIF_BX_PF0_MAILBOX_MSGBUF_RCV_DW2));
+--
+2.19.1
+
--- /dev/null
+From 73512c00ba41af916d7c3f817f0885f33a9a0120 Mon Sep 17 00:00:00 2001
+From: Tomi Valkeinen <tomi.valkeinen@ti.com>
+Date: Thu, 3 Jan 2019 13:59:48 +0200
+Subject: drm/bridge: tc358767: add bus flags
+
+[ Upstream commit 4842379cbe6e851de914a7132f76f4e200b9a98b ]
+
+tc358767 driver does not set DRM bus_flags, even if it does configures
+the polarity settings into its registers. This means that the DPI source
+can't configure the polarities correctly.
+
+Add sync flags accordingly.
+
+Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
+Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
+Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
+Link: https://patchwork.freedesktop.org/patch/msgid/20190103115954.12785-2-tomi.valkeinen@ti.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/gpu/drm/bridge/tc358767.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c
+index 8e28e738cb52..29a7e33e8ae0 100644
+--- a/drivers/gpu/drm/bridge/tc358767.c
++++ b/drivers/gpu/drm/bridge/tc358767.c
+@@ -1195,6 +1195,10 @@ static int tc_bridge_attach(struct drm_bridge *bridge)
+
+ drm_display_info_set_bus_formats(&tc->connector.display_info,
+ &bus_format, 1);
++ tc->connector.display_info.bus_flags =
++ DRM_BUS_FLAG_DE_HIGH |
++ DRM_BUS_FLAG_PIXDATA_NEGEDGE |
++ DRM_BUS_FLAG_SYNC_NEGEDGE;
+ drm_connector_attach_encoder(&tc->connector, tc->bridge.encoder);
+
+ return 0;
+--
+2.19.1
+
--- /dev/null
+From d2cf3ab180ee58f8c246dd6efc87896ae188004e Mon Sep 17 00:00:00 2001
+From: Tomi Valkeinen <tomi.valkeinen@ti.com>
+Date: Thu, 3 Jan 2019 13:59:49 +0200
+Subject: drm/bridge: tc358767: add defines for DP1_SRCCTRL & PHY_2LANE
+
+[ Upstream commit adf4109896bbee27fd2ac3b48d22d6a0062fe517 ]
+
+DP1_SRCCTRL register and PHY_2LANE field did not have matching defines.
+Add these.
+
+Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
+Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
+Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
+Link: https://patchwork.freedesktop.org/patch/msgid/20190103115954.12785-3-tomi.valkeinen@ti.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/gpu/drm/bridge/tc358767.c | 10 +++++++---
+ 1 file changed, 7 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c
+index 29a7e33e8ae0..5f0a666db2fd 100644
+--- a/drivers/gpu/drm/bridge/tc358767.c
++++ b/drivers/gpu/drm/bridge/tc358767.c
+@@ -142,6 +142,8 @@
+ #define DP0_LTLOOPCTRL 0x06d8
+ #define DP0_SNKLTCTRL 0x06e4
+
++#define DP1_SRCCTRL 0x07a0
++
+ /* PHY */
+ #define DP_PHY_CTRL 0x0800
+ #define DP_PHY_RST BIT(28) /* DP PHY Global Soft Reset */
+@@ -150,6 +152,7 @@
+ #define PHY_M1_RST BIT(12) /* Reset PHY1 Main Channel */
+ #define PHY_RDY BIT(16) /* PHY Main Channels Ready */
+ #define PHY_M0_RST BIT(8) /* Reset PHY0 Main Channel */
++#define PHY_2LANE BIT(2) /* PHY Enable 2 lanes */
+ #define PHY_A0_EN BIT(1) /* PHY Aux Channel0 Enable */
+ #define PHY_M0_EN BIT(0) /* PHY Main Channel0 Enable */
+
+@@ -564,7 +567,7 @@ static int tc_aux_link_setup(struct tc_data *tc)
+ value |= SYSCLK_SEL_LSCLK | LSCLK_DIV_2;
+ tc_write(SYS_PLLPARAM, value);
+
+- tc_write(DP_PHY_CTRL, BGREN | PWR_SW_EN | BIT(2) | PHY_A0_EN);
++ tc_write(DP_PHY_CTRL, BGREN | PWR_SW_EN | PHY_2LANE | PHY_A0_EN);
+
+ /*
+ * Initially PLLs are in bypass. Force PLL parameter update,
+@@ -834,7 +837,7 @@ static int tc_main_link_setup(struct tc_data *tc)
+ DP0_SRCCTRL_LANESKEW | DP0_SRCCTRL_LANES_2 |
+ DP0_SRCCTRL_BW27 | DP0_SRCCTRL_AUTOCORRECT);
+ /* from excel file - DP1_SrcCtrl */
+- tc_write(0x07a0, 0x00003083);
++ tc_write(DP1_SRCCTRL, 0x00003083);
+
+ rate = clk_get_rate(tc->refclk);
+ switch (rate) {
+@@ -855,8 +858,9 @@ static int tc_main_link_setup(struct tc_data *tc)
+ }
+ value |= SYSCLK_SEL_LSCLK | LSCLK_DIV_2;
+ tc_write(SYS_PLLPARAM, value);
++
+ /* Setup Main Link */
+- dp_phy_ctrl = BGREN | PWR_SW_EN | BIT(2) | PHY_A0_EN | PHY_M0_EN;
++ dp_phy_ctrl = BGREN | PWR_SW_EN | PHY_2LANE | PHY_A0_EN | PHY_M0_EN;
+ tc_write(DP_PHY_CTRL, dp_phy_ctrl);
+ msleep(100);
+
+--
+2.19.1
+
--- /dev/null
+From 81c20d0d71155603b2528cceda7ca58221e84f44 Mon Sep 17 00:00:00 2001
+From: Tomi Valkeinen <tomi.valkeinen@ti.com>
+Date: Thu, 3 Jan 2019 13:59:51 +0200
+Subject: drm/bridge: tc358767: fix initial DP0/1_SRCCTRL value
+
+[ Upstream commit 9a63bd6fe1b5590ffa42ae2ed22ee21363293e31 ]
+
+Initially DP0_SRCCTRL is set to a static value which includes
+DP0_SRCCTRL_LANES_2 and DP0_SRCCTRL_BW27, even when only 1 lane of
+1.62Gbps speed is used. DP1_SRCCTRL is configured to a magic number.
+
+This patch changes the configuration as follows:
+
+Configure DP0_SRCCTRL by using tc_srcctrl() which provides the correct
+value.
+
+DP1_SRCCTRL needs two bits to be set to the same value as DP0_SRCCTRL:
+SSCG and BW27. All other bits can be zero.
+
+Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
+Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
+Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
+Link: https://patchwork.freedesktop.org/patch/msgid/20190103115954.12785-5-tomi.valkeinen@ti.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/gpu/drm/bridge/tc358767.c | 11 +++++------
+ 1 file changed, 5 insertions(+), 6 deletions(-)
+
+diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c
+index fee53422c31f..ab299f4debfa 100644
+--- a/drivers/gpu/drm/bridge/tc358767.c
++++ b/drivers/gpu/drm/bridge/tc358767.c
+@@ -836,12 +836,11 @@ static int tc_main_link_setup(struct tc_data *tc)
+ if (!tc->mode)
+ return -EINVAL;
+
+- /* from excel file - DP0_SrcCtrl */
+- tc_write(DP0_SRCCTRL, DP0_SRCCTRL_SCRMBLDIS | DP0_SRCCTRL_EN810B |
+- DP0_SRCCTRL_LANESKEW | DP0_SRCCTRL_LANES_2 |
+- DP0_SRCCTRL_BW27 | DP0_SRCCTRL_AUTOCORRECT);
+- /* from excel file - DP1_SrcCtrl */
+- tc_write(DP1_SRCCTRL, 0x00003083);
++ tc_write(DP0_SRCCTRL, tc_srcctrl(tc));
++ /* SSCG and BW27 on DP1 must be set to the same as on DP0 */
++ tc_write(DP1_SRCCTRL,
++ (tc->link.spread ? DP0_SRCCTRL_SSCG : 0) |
++ ((tc->link.base.rate != 162000) ? DP0_SRCCTRL_BW27 : 0));
+
+ rate = clk_get_rate(tc->refclk);
+ switch (rate) {
+--
+2.19.1
+
--- /dev/null
+From a61ee3cda7244036f1015bac8b6cb7b16e1475ac Mon Sep 17 00:00:00 2001
+From: Tomi Valkeinen <tomi.valkeinen@ti.com>
+Date: Thu, 3 Jan 2019 13:59:53 +0200
+Subject: drm/bridge: tc358767: fix output H/V syncs
+
+[ Upstream commit 7923e09c7a766e2d58de7fc395bb84c18e5bc625 ]
+
+The H and V syncs of the DP output are always set to active high. This
+patch fixes the syncs by configuring them according to the videomode.
+
+Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
+Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
+Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
+Link: https://patchwork.freedesktop.org/patch/msgid/20190103115954.12785-7-tomi.valkeinen@ti.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/gpu/drm/bridge/tc358767.c | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c
+index a1f3dd2afbb1..391547358756 100644
+--- a/drivers/gpu/drm/bridge/tc358767.c
++++ b/drivers/gpu/drm/bridge/tc358767.c
+@@ -98,6 +98,8 @@
+ #define DP0_STARTVAL 0x064c
+ #define DP0_ACTIVEVAL 0x0650
+ #define DP0_SYNCVAL 0x0654
++#define SYNCVAL_HS_POL_ACTIVE_LOW (1 << 15)
++#define SYNCVAL_VS_POL_ACTIVE_LOW (1 << 31)
+ #define DP0_MISC 0x0658
+ #define TU_SIZE_RECOMMENDED (63) /* LSCLK cycles per TU */
+ #define BPC_6 (0 << 5)
+@@ -726,7 +728,9 @@ static int tc_set_video_mode(struct tc_data *tc, struct drm_display_mode *mode)
+
+ tc_write(DP0_ACTIVEVAL, (mode->vdisplay << 16) | (mode->hdisplay));
+
+- tc_write(DP0_SYNCVAL, (vsync_len << 16) | (hsync_len << 0));
++ tc_write(DP0_SYNCVAL, (vsync_len << 16) | (hsync_len << 0) |
++ ((mode->flags & DRM_MODE_FLAG_NHSYNC) ? SYNCVAL_HS_POL_ACTIVE_LOW : 0) |
++ ((mode->flags & DRM_MODE_FLAG_NVSYNC) ? SYNCVAL_VS_POL_ACTIVE_LOW : 0));
+
+ tc_write(DPIPXLFMT, VS_POL_ACTIVE_LOW | HS_POL_ACTIVE_LOW |
+ DE_POL_ACTIVE_HIGH | SUB_CFG_TYPE_CONFIG1 | DPI_BPP_RGB888);
+--
+2.19.1
+
--- /dev/null
+From 3ceab495906815dae3cbfea9da087884ecaa917f Mon Sep 17 00:00:00 2001
+From: Tomi Valkeinen <tomi.valkeinen@ti.com>
+Date: Thu, 3 Jan 2019 13:59:50 +0200
+Subject: drm/bridge: tc358767: fix single lane configuration
+
+[ Upstream commit 4d9d54a730434cc068dd3515ba6116697196f77b ]
+
+PHY_2LANE bit is always set in DP_PHY_CTRL, breaking 1 lane use.
+
+Set PHY_2LANE only when 2 lanes are used.
+
+Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
+Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
+Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
+Link: https://patchwork.freedesktop.org/patch/msgid/20190103115954.12785-4-tomi.valkeinen@ti.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/gpu/drm/bridge/tc358767.c | 10 ++++++++--
+ 1 file changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c
+index 5f0a666db2fd..fee53422c31f 100644
+--- a/drivers/gpu/drm/bridge/tc358767.c
++++ b/drivers/gpu/drm/bridge/tc358767.c
+@@ -543,6 +543,7 @@ static int tc_aux_link_setup(struct tc_data *tc)
+ unsigned long rate;
+ u32 value;
+ int ret;
++ u32 dp_phy_ctrl;
+
+ rate = clk_get_rate(tc->refclk);
+ switch (rate) {
+@@ -567,7 +568,10 @@ static int tc_aux_link_setup(struct tc_data *tc)
+ value |= SYSCLK_SEL_LSCLK | LSCLK_DIV_2;
+ tc_write(SYS_PLLPARAM, value);
+
+- tc_write(DP_PHY_CTRL, BGREN | PWR_SW_EN | PHY_2LANE | PHY_A0_EN);
++ dp_phy_ctrl = BGREN | PWR_SW_EN | PHY_A0_EN;
++ if (tc->link.base.num_lanes == 2)
++ dp_phy_ctrl |= PHY_2LANE;
++ tc_write(DP_PHY_CTRL, dp_phy_ctrl);
+
+ /*
+ * Initially PLLs are in bypass. Force PLL parameter update,
+@@ -860,7 +864,9 @@ static int tc_main_link_setup(struct tc_data *tc)
+ tc_write(SYS_PLLPARAM, value);
+
+ /* Setup Main Link */
+- dp_phy_ctrl = BGREN | PWR_SW_EN | PHY_2LANE | PHY_A0_EN | PHY_M0_EN;
++ dp_phy_ctrl = BGREN | PWR_SW_EN | PHY_A0_EN | PHY_M0_EN;
++ if (tc->link.base.num_lanes == 2)
++ dp_phy_ctrl |= PHY_2LANE;
+ tc_write(DP_PHY_CTRL, dp_phy_ctrl);
+ msleep(100);
+
+--
+2.19.1
+
--- /dev/null
+From caa0cccc1c703171837adc14a5c9a8281d0a1623 Mon Sep 17 00:00:00 2001
+From: Tomi Valkeinen <tomi.valkeinen@ti.com>
+Date: Thu, 3 Jan 2019 13:59:52 +0200
+Subject: drm/bridge: tc358767: reject modes which require too much BW
+
+[ Upstream commit 51b9e62eb6950c762162ab7eb8390990179be067 ]
+
+The current driver accepts any videomode with pclk < 154MHz. This is not
+correct, as with 1 lane and/or 1.62Mbps speed not all videomodes can be
+supported.
+
+Add code to reject modes that require more bandwidth that is available.
+
+Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
+Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
+Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
+Link: https://patchwork.freedesktop.org/patch/msgid/20190103115954.12785-6-tomi.valkeinen@ti.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/gpu/drm/bridge/tc358767.c | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c
+index ab299f4debfa..a1f3dd2afbb1 100644
+--- a/drivers/gpu/drm/bridge/tc358767.c
++++ b/drivers/gpu/drm/bridge/tc358767.c
+@@ -1114,10 +1114,20 @@ static bool tc_bridge_mode_fixup(struct drm_bridge *bridge,
+ static enum drm_mode_status tc_connector_mode_valid(struct drm_connector *connector,
+ struct drm_display_mode *mode)
+ {
++ struct tc_data *tc = connector_to_tc(connector);
++ u32 req, avail;
++ u32 bits_per_pixel = 24;
++
+ /* DPI interface clock limitation: upto 154 MHz */
+ if (mode->clock > 154000)
+ return MODE_CLOCK_HIGH;
+
++ req = mode->clock * bits_per_pixel / 8;
++ avail = tc->link.base.num_lanes * tc->link.base.rate;
++
++ if (req > avail)
++ return MODE_BAD;
++
+ return MODE_OK;
+ }
+
+--
+2.19.1
+
--- /dev/null
+From d8a165d54147c81b6ac69f0611d69d9690de0509 Mon Sep 17 00:00:00 2001
+From: Takashi Iwai <tiwai@suse.de>
+Date: Wed, 12 Sep 2018 12:58:43 +0200
+Subject: drm/nouveau: Don't disable polling in fallback mode
+
+[ Upstream commit 118780066e30c34de3d9349710b51780bfa0ba83 ]
+
+When a fan is controlled via linear fallback without cstate, we
+shouldn't stop polling. Otherwise it won't be adjusted again and
+keeps running at an initial crazy pace.
+
+Fixes: 800efb4c2857 ("drm/nouveau/drm/therm/fan: add a fallback if no fan control is specified in the vbios")
+Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1103356
+Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107447
+Reported-by: Thomas Blume <thomas.blume@suse.com>
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+Reviewed-by: Martin Peres <martin.peres@free.fr>
+Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/gpu/drm/nouveau/nvkm/subdev/therm/base.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/base.c
+index 3695cde669f8..07914e36939e 100644
+--- a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/base.c
++++ b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/base.c
+@@ -132,11 +132,12 @@ nvkm_therm_update(struct nvkm_therm *therm, int mode)
+ duty = nvkm_therm_update_linear(therm);
+ break;
+ case NVBIOS_THERM_FAN_OTHER:
+- if (therm->cstate)
++ if (therm->cstate) {
+ duty = therm->cstate;
+- else
++ poll = false;
++ } else {
+ duty = nvkm_therm_update_linear_fallback(therm);
+- poll = false;
++ }
+ break;
+ }
+ immd = false;
+--
+2.19.1
+
--- /dev/null
+From 386e9680b130c1b247e7a5d26b7054cf425de3dc Mon Sep 17 00:00:00 2001
+From: Ilia Mirkin <imirkin@alum.mit.edu>
+Date: Thu, 13 Dec 2018 22:44:08 -0500
+Subject: drm/nouveau/falcon: avoid touching registers if engine is off
+
+[ Upstream commit a5176a4cb85bb6213daadf691097cf411da35df2 ]
+
+Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108980
+Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
+Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/gpu/drm/nouveau/nvkm/engine/falcon.c | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/falcon.c b/drivers/gpu/drm/nouveau/nvkm/engine/falcon.c
+index 816ccaedfc73..8675613e142b 100644
+--- a/drivers/gpu/drm/nouveau/nvkm/engine/falcon.c
++++ b/drivers/gpu/drm/nouveau/nvkm/engine/falcon.c
+@@ -22,6 +22,7 @@
+ #include <engine/falcon.h>
+
+ #include <core/gpuobj.h>
++#include <subdev/mc.h>
+ #include <subdev/timer.h>
+ #include <engine/fifo.h>
+
+@@ -107,8 +108,10 @@ nvkm_falcon_fini(struct nvkm_engine *engine, bool suspend)
+ }
+ }
+
+- nvkm_mask(device, base + 0x048, 0x00000003, 0x00000000);
+- nvkm_wr32(device, base + 0x014, 0xffffffff);
++ if (nvkm_mc_enabled(device, engine->subdev.index)) {
++ nvkm_mask(device, base + 0x048, 0x00000003, 0x00000000);
++ nvkm_wr32(device, base + 0x014, 0xffffffff);
++ }
+ return 0;
+ }
+
+--
+2.19.1
+
--- /dev/null
+From 71f4210722f5fe1217c00be40b7e5d0c8f6968d2 Mon Sep 17 00:00:00 2001
+From: Adrian Bunk <bunk@kernel.org>
+Date: Thu, 29 Nov 2018 21:58:57 +0200
+Subject: dt-bindings: eeprom: at24: add "atmel,24c2048" compatible string
+
+[ Upstream commit 6c0c5dc33ff42af49243e94842d0ebdb153189ea ]
+
+Add new compatible to the device tree bindings.
+
+Signed-off-by: Adrian Bunk <bunk@kernel.org>
+Acked-by: Rob Herring <robh@kernel.org>
+Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ Documentation/devicetree/bindings/eeprom/at24.txt | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/Documentation/devicetree/bindings/eeprom/at24.txt b/Documentation/devicetree/bindings/eeprom/at24.txt
+index aededdbc262b..f9a7c984274c 100644
+--- a/Documentation/devicetree/bindings/eeprom/at24.txt
++++ b/Documentation/devicetree/bindings/eeprom/at24.txt
+@@ -27,6 +27,7 @@ Required properties:
+ "atmel,24c256",
+ "atmel,24c512",
+ "atmel,24c1024",
++ "atmel,24c2048",
+
+ If <manufacturer> is not "atmel", then a fallback must be used
+ with the same <model> and "atmel" as manufacturer.
+--
+2.19.1
+
--- /dev/null
+From 8bd61c79039ab281d7e589dee659db5ae8ce9f1e Mon Sep 17 00:00:00 2001
+From: Adrian Bunk <bunk@kernel.org>
+Date: Thu, 29 Nov 2018 21:58:58 +0200
+Subject: eeprom: at24: add support for 24c2048
+
+[ Upstream commit 37cf28d3b5bca1b532a0b6aac722e7f2788a9294 ]
+
+Works with ST M24M02.
+
+Signed-off-by: Adrian Bunk <bunk@kernel.org>
+Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/misc/eeprom/Kconfig | 2 +-
+ drivers/misc/eeprom/at24.c | 3 +++
+ 2 files changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/misc/eeprom/Kconfig b/drivers/misc/eeprom/Kconfig
+index fe7a1d27a017..a846faefa210 100644
+--- a/drivers/misc/eeprom/Kconfig
++++ b/drivers/misc/eeprom/Kconfig
+@@ -13,7 +13,7 @@ config EEPROM_AT24
+ ones like at24c64, 24lc02 or fm24c04:
+
+ 24c00, 24c01, 24c02, spd (readonly 24c02), 24c04, 24c08,
+- 24c16, 24c32, 24c64, 24c128, 24c256, 24c512, 24c1024
++ 24c16, 24c32, 24c64, 24c128, 24c256, 24c512, 24c1024, 24c2048
+
+ Unless you like data loss puzzles, always be sure that any chip
+ you configure as a 24c32 (32 kbit) or larger is NOT really a
+diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
+index 636ed7149793..ddfcf4ade7bf 100644
+--- a/drivers/misc/eeprom/at24.c
++++ b/drivers/misc/eeprom/at24.c
+@@ -156,6 +156,7 @@ AT24_CHIP_DATA(at24_data_24c128, 131072 / 8, AT24_FLAG_ADDR16);
+ AT24_CHIP_DATA(at24_data_24c256, 262144 / 8, AT24_FLAG_ADDR16);
+ AT24_CHIP_DATA(at24_data_24c512, 524288 / 8, AT24_FLAG_ADDR16);
+ AT24_CHIP_DATA(at24_data_24c1024, 1048576 / 8, AT24_FLAG_ADDR16);
++AT24_CHIP_DATA(at24_data_24c2048, 2097152 / 8, AT24_FLAG_ADDR16);
+ /* identical to 24c08 ? */
+ AT24_CHIP_DATA(at24_data_INT3499, 8192 / 8, 0);
+
+@@ -182,6 +183,7 @@ static const struct i2c_device_id at24_ids[] = {
+ { "24c256", (kernel_ulong_t)&at24_data_24c256 },
+ { "24c512", (kernel_ulong_t)&at24_data_24c512 },
+ { "24c1024", (kernel_ulong_t)&at24_data_24c1024 },
++ { "24c2048", (kernel_ulong_t)&at24_data_24c2048 },
+ { "at24", 0 },
+ { /* END OF LIST */ }
+ };
+@@ -210,6 +212,7 @@ static const struct of_device_id at24_of_match[] = {
+ { .compatible = "atmel,24c256", .data = &at24_data_24c256 },
+ { .compatible = "atmel,24c512", .data = &at24_data_24c512 },
+ { .compatible = "atmel,24c1024", .data = &at24_data_24c1024 },
++ { .compatible = "atmel,24c2048", .data = &at24_data_24c2048 },
+ { /* END OF LIST */ },
+ };
+ MODULE_DEVICE_TABLE(of, at24_of_match);
+--
+2.19.1
+
--- /dev/null
+From 705106908ef69d6e259500cc59d75bf76409713b Mon Sep 17 00:00:00 2001
+From: Nicholas Mc Guire <hofrat@osadl.org>
+Date: Sat, 1 Dec 2018 12:57:18 +0100
+Subject: gpio: pl061: handle failed allocations
+
+[ Upstream commit df209c43a0e8258e096fb722dfbdae4f0dd13fde ]
+
+devm_kzalloc(), devm_kstrdup() and devm_kasprintf() all can
+fail internal allocation and return NULL. Using any of the assigned
+objects without checking is not safe. As this is early in the boot
+phase and these allocations really should not fail, any failure here
+is probably an indication of a more serious issue so it makes little
+sense to try and rollback the previous allocated resources or try to
+continue; but rather the probe function is simply exited with -ENOMEM.
+
+Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
+Fixes: 684284b64aae ("ARM: integrator: add MMCI device to IM-PD1")
+Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm/mach-integrator/impd1.c | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/arch/arm/mach-integrator/impd1.c b/arch/arm/mach-integrator/impd1.c
+index a109f6482413..0f916c245a2e 100644
+--- a/arch/arm/mach-integrator/impd1.c
++++ b/arch/arm/mach-integrator/impd1.c
+@@ -393,7 +393,11 @@ static int __ref impd1_probe(struct lm_device *dev)
+ sizeof(*lookup) + 3 * sizeof(struct gpiod_lookup),
+ GFP_KERNEL);
+ chipname = devm_kstrdup(&dev->dev, devname, GFP_KERNEL);
+- mmciname = kasprintf(GFP_KERNEL, "lm%x:00700", dev->id);
++ mmciname = devm_kasprintf(&dev->dev, GFP_KERNEL,
++ "lm%x:00700", dev->id);
++ if (!lookup || !chipname || !mmciname)
++ return -ENOMEM;
++
+ lookup->dev_id = mmciname;
+ /*
+ * Offsets on GPIO block 1:
+--
+2.19.1
+
--- /dev/null
+From d8edfa9edb2b0d9534d31a6189acde3393a09745 Mon Sep 17 00:00:00 2001
+From: Guo Ren <ren_guo@c-sky.com>
+Date: Tue, 8 Jan 2019 20:49:24 +0800
+Subject: irqchip/csky: fixup handle_irq_perbit break irq
+
+[ Upstream commit 56752b21755aef598709d143684cb363db98a7d2 ]
+
+The handle_irq_perbit function loop every bit in hwirq local variable.
+
+handle_irq_perbit(hwirq) {
+ for_everyt_bit_in(hwirq) {
+ handle_domain_irq()
+ ->irq_exit()
+ ->invoke_softirq()
+ ->__do_softirq()
+ ->local_irq_enable() // Here will cause new interrupt.
+ }
+}
+
+When new interrupt coming at local_irq_enable, it will finish another
+interrupt handler and pull down the interrupt source. But hwirq is the
+local variable for handle_irq_perbit(), it can't get new interrupt
+controller pending reg status. So we need update hwirq with pending reg
+in every loop.
+
+Also change write_relax to writel could prevent stw from fast retire.
+When local_irq is enabled, intc regs is really set-in.
+
+Signed-off-by: Guo Ren <ren_guo@c-sky.com>
+Cc: Lu Baoquan <lu.baoquan@intellif.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/irqchip/irq-csky-apb-intc.c | 77 ++++++++++++++++-------------
+ 1 file changed, 42 insertions(+), 35 deletions(-)
+
+diff --git a/drivers/irqchip/irq-csky-apb-intc.c b/drivers/irqchip/irq-csky-apb-intc.c
+index 2543baba8b1f..5a2ec43b7ddd 100644
+--- a/drivers/irqchip/irq-csky-apb-intc.c
++++ b/drivers/irqchip/irq-csky-apb-intc.c
+@@ -95,7 +95,7 @@ static inline void setup_irq_channel(u32 magic, void __iomem *reg_addr)
+
+ /* Setup 64 channel slots */
+ for (i = 0; i < INTC_IRQS; i += 4)
+- writel_relaxed(build_channel_val(i, magic), reg_addr + i);
++ writel(build_channel_val(i, magic), reg_addr + i);
+ }
+
+ static int __init
+@@ -135,16 +135,10 @@ ck_intc_init_comm(struct device_node *node, struct device_node *parent)
+ static inline bool handle_irq_perbit(struct pt_regs *regs, u32 hwirq,
+ u32 irq_base)
+ {
+- u32 irq;
+-
+ if (hwirq == 0)
+ return 0;
+
+- while (hwirq) {
+- irq = __ffs(hwirq);
+- hwirq &= ~BIT(irq);
+- handle_domain_irq(root_domain, irq_base + irq, regs);
+- }
++ handle_domain_irq(root_domain, irq_base + __fls(hwirq), regs);
+
+ return 1;
+ }
+@@ -154,12 +148,16 @@ static void gx_irq_handler(struct pt_regs *regs)
+ {
+ bool ret;
+
+- do {
+- ret = handle_irq_perbit(regs,
+- readl_relaxed(reg_base + GX_INTC_PEN31_00), 0);
+- ret |= handle_irq_perbit(regs,
+- readl_relaxed(reg_base + GX_INTC_PEN63_32), 32);
+- } while (ret);
++retry:
++ ret = handle_irq_perbit(regs,
++ readl(reg_base + GX_INTC_PEN63_32), 32);
++ if (ret)
++ goto retry;
++
++ ret = handle_irq_perbit(regs,
++ readl(reg_base + GX_INTC_PEN31_00), 0);
++ if (ret)
++ goto retry;
+ }
+
+ static int __init
+@@ -174,14 +172,14 @@ gx_intc_init(struct device_node *node, struct device_node *parent)
+ /*
+ * Initial enable reg to disable all interrupts
+ */
+- writel_relaxed(0x0, reg_base + GX_INTC_NEN31_00);
+- writel_relaxed(0x0, reg_base + GX_INTC_NEN63_32);
++ writel(0x0, reg_base + GX_INTC_NEN31_00);
++ writel(0x0, reg_base + GX_INTC_NEN63_32);
+
+ /*
+ * Initial mask reg with all unmasked, because we only use enalbe reg
+ */
+- writel_relaxed(0x0, reg_base + GX_INTC_NMASK31_00);
+- writel_relaxed(0x0, reg_base + GX_INTC_NMASK63_32);
++ writel(0x0, reg_base + GX_INTC_NMASK31_00);
++ writel(0x0, reg_base + GX_INTC_NMASK63_32);
+
+ setup_irq_channel(0x03020100, reg_base + GX_INTC_SOURCE);
+
+@@ -204,20 +202,29 @@ static void ck_irq_handler(struct pt_regs *regs)
+ void __iomem *reg_pen_lo = reg_base + CK_INTC_PEN31_00;
+ void __iomem *reg_pen_hi = reg_base + CK_INTC_PEN63_32;
+
+- do {
+- /* handle 0 - 31 irqs */
+- ret = handle_irq_perbit(regs, readl_relaxed(reg_pen_lo), 0);
+- ret |= handle_irq_perbit(regs, readl_relaxed(reg_pen_hi), 32);
++retry:
++ /* handle 0 - 63 irqs */
++ ret = handle_irq_perbit(regs, readl(reg_pen_hi), 32);
++ if (ret)
++ goto retry;
+
+- if (nr_irq == INTC_IRQS)
+- continue;
++ ret = handle_irq_perbit(regs, readl(reg_pen_lo), 0);
++ if (ret)
++ goto retry;
++
++ if (nr_irq == INTC_IRQS)
++ return;
+
+- /* handle 64 - 127 irqs */
+- ret |= handle_irq_perbit(regs,
+- readl_relaxed(reg_pen_lo + CK_INTC_DUAL_BASE), 64);
+- ret |= handle_irq_perbit(regs,
+- readl_relaxed(reg_pen_hi + CK_INTC_DUAL_BASE), 96);
+- } while (ret);
++ /* handle 64 - 127 irqs */
++ ret = handle_irq_perbit(regs,
++ readl(reg_pen_hi + CK_INTC_DUAL_BASE), 96);
++ if (ret)
++ goto retry;
++
++ ret = handle_irq_perbit(regs,
++ readl(reg_pen_lo + CK_INTC_DUAL_BASE), 64);
++ if (ret)
++ goto retry;
+ }
+
+ static int __init
+@@ -230,11 +237,11 @@ ck_intc_init(struct device_node *node, struct device_node *parent)
+ return ret;
+
+ /* Initial enable reg to disable all interrupts */
+- writel_relaxed(0, reg_base + CK_INTC_NEN31_00);
+- writel_relaxed(0, reg_base + CK_INTC_NEN63_32);
++ writel(0, reg_base + CK_INTC_NEN31_00);
++ writel(0, reg_base + CK_INTC_NEN63_32);
+
+ /* Enable irq intc */
+- writel_relaxed(BIT(31), reg_base + CK_INTC_ICR);
++ writel(BIT(31), reg_base + CK_INTC_ICR);
+
+ ck_set_gc(node, reg_base, CK_INTC_NEN31_00, 0);
+ ck_set_gc(node, reg_base, CK_INTC_NEN63_32, 32);
+@@ -260,8 +267,8 @@ ck_dual_intc_init(struct device_node *node, struct device_node *parent)
+ return ret;
+
+ /* Initial enable reg to disable all interrupts */
+- writel_relaxed(0, reg_base + CK_INTC_NEN31_00 + CK_INTC_DUAL_BASE);
+- writel_relaxed(0, reg_base + CK_INTC_NEN63_32 + CK_INTC_DUAL_BASE);
++ writel(0, reg_base + CK_INTC_NEN31_00 + CK_INTC_DUAL_BASE);
++ writel(0, reg_base + CK_INTC_NEN63_32 + CK_INTC_DUAL_BASE);
+
+ ck_set_gc(node, reg_base + CK_INTC_DUAL_BASE, CK_INTC_NEN31_00, 64);
+ ck_set_gc(node, reg_base + CK_INTC_DUAL_BASE, CK_INTC_NEN63_32, 96);
+--
+2.19.1
+
--- /dev/null
+From 5f7a199af9cfd0e213060b479829e0f3e34a5d8f Mon Sep 17 00:00:00 2001
+From: David Rientjes <rientjes@google.com>
+Date: Wed, 2 Jan 2019 12:56:33 -0800
+Subject: kvm: sev: Fail KVM_SEV_INIT if already initialized
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+[ Upstream commit 3f14a89d1132dcae3c8ce6721c6ef51f6e6d9b5f ]
+
+By code inspection, it was found that multiple calls to KVM_SEV_INIT
+could deplete asid bits and overwrite kvm_sev_info's regions_list.
+
+Multiple calls to KVM_SVM_INIT is not likely to occur with QEMU, but this
+should likely be fixed anyway.
+
+This code is serialized by kvm->lock.
+
+Fixes: 1654efcbc431 ("KVM: SVM: Add KVM_SEV_INIT command")
+Reported-by: Cfir Cohen <cfir@google.com>
+Signed-off-by: David Rientjes <rientjes@google.com>
+Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/x86/kvm/svm.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
+index 11641d9e7f6f..13baba9d1cc1 100644
+--- a/arch/x86/kvm/svm.c
++++ b/arch/x86/kvm/svm.c
+@@ -6255,6 +6255,9 @@ static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp)
+ int asid, ret;
+
+ ret = -EBUSY;
++ if (unlikely(sev->active))
++ return ret;
++
+ asid = sev_asid_new();
+ if (asid < 0)
+ return ret;
+--
+2.19.1
+
--- /dev/null
+From df64b67f715a94893f3fa752c9cd7cb8f19e7456 Mon Sep 17 00:00:00 2001
+From: James Dingwall <james@dingwall.me.uk>
+Date: Tue, 8 Jan 2019 10:20:51 -0700
+Subject: nvme: introduce NVME_QUIRK_IGNORE_DEV_SUBNQN
+
+[ Upstream commit 6299358d198a0635da2dd3c4b3ec37789e811e44 ]
+
+If a device provides an NQN it is expected to be globally unique.
+Unfortunately some firmware revisions for Intel 760p/Pro 7600p devices did
+not satisfy this requirement. In these circumstances if a system has >1
+affected device then only one device is enabled. If this quirk is enabled
+then the device supplied subnqn is ignored and we fallback to generating
+one as if the field was empty. In this case we also suppress the version
+check so we don't print a warning when the quirk is enabled.
+
+Reviewed-by: Keith Busch <keith.busch@intel.com>
+Signed-off-by: James Dingwall <james@dingwall.me.uk>
+Signed-off-by: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/nvme/host/core.c | 16 +++++++++-------
+ drivers/nvme/host/nvme.h | 5 +++++
+ drivers/nvme/host/pci.c | 2 ++
+ 3 files changed, 16 insertions(+), 7 deletions(-)
+
+diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
+index 971ca6754959..5f9a5ef93969 100644
+--- a/drivers/nvme/host/core.c
++++ b/drivers/nvme/host/core.c
+@@ -2084,14 +2084,16 @@ static void nvme_init_subnqn(struct nvme_subsystem *subsys, struct nvme_ctrl *ct
+ size_t nqnlen;
+ int off;
+
+- nqnlen = strnlen(id->subnqn, NVMF_NQN_SIZE);
+- if (nqnlen > 0 && nqnlen < NVMF_NQN_SIZE) {
+- strlcpy(subsys->subnqn, id->subnqn, NVMF_NQN_SIZE);
+- return;
+- }
++ if(!(ctrl->quirks & NVME_QUIRK_IGNORE_DEV_SUBNQN)) {
++ nqnlen = strnlen(id->subnqn, NVMF_NQN_SIZE);
++ if (nqnlen > 0 && nqnlen < NVMF_NQN_SIZE) {
++ strlcpy(subsys->subnqn, id->subnqn, NVMF_NQN_SIZE);
++ return;
++ }
+
+- if (ctrl->vs >= NVME_VS(1, 2, 1))
+- dev_warn(ctrl->device, "missing or invalid SUBNQN field.\n");
++ if (ctrl->vs >= NVME_VS(1, 2, 1))
++ dev_warn(ctrl->device, "missing or invalid SUBNQN field.\n");
++ }
+
+ /* Generate a "fake" NQN per Figure 254 in NVMe 1.3 + ECN 001 */
+ off = snprintf(subsys->subnqn, NVMF_NQN_SIZE,
+diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
+index 081cbdcce880..6ffa99a10a60 100644
+--- a/drivers/nvme/host/nvme.h
++++ b/drivers/nvme/host/nvme.h
+@@ -90,6 +90,11 @@ enum nvme_quirks {
+ * Set MEDIUM priority on SQ creation
+ */
+ NVME_QUIRK_MEDIUM_PRIO_SQ = (1 << 7),
++
++ /*
++ * Ignore device provided subnqn.
++ */
++ NVME_QUIRK_IGNORE_DEV_SUBNQN = (1 << 8),
+ };
+
+ /*
+diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
+index 47597046c14f..c0d01048ce4d 100644
+--- a/drivers/nvme/host/pci.c
++++ b/drivers/nvme/host/pci.c
+@@ -2700,6 +2700,8 @@ static const struct pci_device_id nvme_id_table[] = {
+ { PCI_VDEVICE(INTEL, 0xf1a5), /* Intel 600P/P3100 */
+ .driver_data = NVME_QUIRK_NO_DEEPEST_PS |
+ NVME_QUIRK_MEDIUM_PRIO_SQ },
++ { PCI_VDEVICE(INTEL, 0xf1a6), /* Intel 760p/Pro 7600p */
++ .driver_data = NVME_QUIRK_IGNORE_DEV_SUBNQN, },
+ { PCI_VDEVICE(INTEL, 0x5845), /* Qemu emulated controller */
+ .driver_data = NVME_QUIRK_IDENTIFY_CNS, },
+ { PCI_DEVICE(0x1bb1, 0x0100), /* Seagate Nytro Flash Storage */
+--
+2.19.1
+
--- /dev/null
+From 6bdef5ea8cc33739273cd9ca0a93cc4c8fc8fc13 Mon Sep 17 00:00:00 2001
+From: Hannes Reinecke <hare@suse.de>
+Date: Tue, 8 Jan 2019 12:46:58 +0100
+Subject: nvme-multipath: zero out ANA log buffer
+
+[ Upstream commit c7055fd15ff46d92eb0dd1c16a4fe010d58224c8 ]
+
+When nvme_init_identify() fails the ANA log buffer is deallocated
+but _not_ set to NULL. This can cause double free oops when this
+controller is deleted without ever being reconnected.
+
+Signed-off-by: Hannes Reinecke <hare@suse.com>
+Signed-off-by: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/nvme/host/multipath.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
+index 9901afd804ce..2b1d1f066efa 100644
+--- a/drivers/nvme/host/multipath.c
++++ b/drivers/nvme/host/multipath.c
+@@ -586,6 +586,7 @@ int nvme_mpath_init(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
+ return 0;
+ out_free_ana_log_buf:
+ kfree(ctrl->ana_log_buf);
++ ctrl->ana_log_buf = NULL;
+ out:
+ return error;
+ }
+@@ -593,5 +594,6 @@ int nvme_mpath_init(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
+ void nvme_mpath_uninit(struct nvme_ctrl *ctrl)
+ {
+ kfree(ctrl->ana_log_buf);
++ ctrl->ana_log_buf = NULL;
+ }
+
+--
+2.19.1
+
--- /dev/null
+From e5830cc81e67d23f656c13b6e9037e719c1bc294 Mon Sep 17 00:00:00 2001
+From: Keith Busch <keith.busch@intel.com>
+Date: Tue, 8 Jan 2019 09:37:43 -0700
+Subject: nvme: pad fake subsys NQN vid and ssvid with zeros
+
+[ Upstream commit 3da584f57133e51aeb84aaefae5e3d69531a1e4f ]
+
+We need to preserve the leading zeros in the vid and ssvid when generating
+a unique NQN. Truncating these may lead to naming collisions.
+
+Signed-off-by: Keith Busch <keith.busch@intel.com>
+Signed-off-by: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/nvme/host/core.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
+index 962012135b62..971ca6754959 100644
+--- a/drivers/nvme/host/core.c
++++ b/drivers/nvme/host/core.c
+@@ -2095,7 +2095,7 @@ static void nvme_init_subnqn(struct nvme_subsystem *subsys, struct nvme_ctrl *ct
+
+ /* Generate a "fake" NQN per Figure 254 in NVMe 1.3 + ECN 001 */
+ off = snprintf(subsys->subnqn, NVMF_NQN_SIZE,
+- "nqn.2014.08.org.nvmexpress:%4x%4x",
++ "nqn.2014.08.org.nvmexpress:%04x%04x",
+ le16_to_cpu(id->vid), le16_to_cpu(id->ssvid));
+ memcpy(subsys->subnqn + off, id->sn, sizeof(id->sn));
+ off += sizeof(id->sn);
+--
+2.19.1
+
--- /dev/null
+From 7166d72c27cd5228374fe6e488d23385de0c183a Mon Sep 17 00:00:00 2001
+From: Hongbo Yao <yaohongbo@huawei.com>
+Date: Mon, 7 Jan 2019 10:22:07 +0800
+Subject: nvme-pci: fix out of bounds access in nvme_cqe_pending
+
+[ Upstream commit dcca1662727220d18fa351097ddff33f95f516c5 ]
+
+There is an out of bounds array access in nvme_cqe_peding().
+
+When enable irq_thread for nvme interrupt, there is racing between the
+nvmeq->cq_head updating and reading.
+
+nvmeq->cq_head is updated in nvme_update_cq_head(), if nvmeq->cq_head
+equals nvmeq->q_depth and before its value set to zero, nvme_cqe_pending()
+uses its value as an array index, the index will be out of bounds.
+
+Signed-off-by: Hongbo Yao <yaohongbo@huawei.com>
+[hch: slight coding style update]
+Signed-off-by: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/nvme/host/pci.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
+index 0f45868e8af9..47597046c14f 100644
+--- a/drivers/nvme/host/pci.c
++++ b/drivers/nvme/host/pci.c
+@@ -913,9 +913,11 @@ static void nvme_complete_cqes(struct nvme_queue *nvmeq, u16 start, u16 end)
+
+ static inline void nvme_update_cq_head(struct nvme_queue *nvmeq)
+ {
+- if (++nvmeq->cq_head == nvmeq->q_depth) {
++ if (nvmeq->cq_head == nvmeq->q_depth - 1) {
+ nvmeq->cq_head = 0;
+ nvmeq->cq_phase = !nvmeq->cq_phase;
++ } else {
++ nvmeq->cq_head++;
+ }
+ }
+
+--
+2.19.1
+
--- /dev/null
+From 17eb4d785c8ec8a543fe98c1364fff004a579ae6 Mon Sep 17 00:00:00 2001
+From: Liviu Dudau <liviu@dudau.co.uk>
+Date: Sat, 29 Dec 2018 17:23:43 +0000
+Subject: nvme-pci: use the same attributes when freeing host_mem_desc_bufs.
+
+[ Upstream commit cc667f6d5de023ee131e96bb88e5cddca23272bd ]
+
+When using HMB the PCIe host driver allocates host_mem_desc_bufs using
+dma_alloc_attrs() but frees them using dma_free_coherent(). Use the
+correct dma_free_attrs() function to free the buffers.
+
+Signed-off-by: Liviu Dudau <liviu@dudau.co.uk>
+Signed-off-by: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/nvme/host/pci.c | 10 ++++++----
+ 1 file changed, 6 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
+index c33bb201b884..0f45868e8af9 100644
+--- a/drivers/nvme/host/pci.c
++++ b/drivers/nvme/host/pci.c
+@@ -1748,8 +1748,9 @@ static void nvme_free_host_mem(struct nvme_dev *dev)
+ struct nvme_host_mem_buf_desc *desc = &dev->host_mem_descs[i];
+ size_t size = le32_to_cpu(desc->size) * dev->ctrl.page_size;
+
+- dma_free_coherent(dev->dev, size, dev->host_mem_desc_bufs[i],
+- le64_to_cpu(desc->addr));
++ dma_free_attrs(dev->dev, size, dev->host_mem_desc_bufs[i],
++ le64_to_cpu(desc->addr),
++ DMA_ATTR_NO_KERNEL_MAPPING | DMA_ATTR_NO_WARN);
+ }
+
+ kfree(dev->host_mem_desc_bufs);
+@@ -1815,8 +1816,9 @@ static int __nvme_alloc_host_mem(struct nvme_dev *dev, u64 preferred,
+ while (--i >= 0) {
+ size_t size = le32_to_cpu(descs[i].size) * dev->ctrl.page_size;
+
+- dma_free_coherent(dev->dev, size, bufs[i],
+- le64_to_cpu(descs[i].addr));
++ dma_free_attrs(dev->dev, size, bufs[i],
++ le64_to_cpu(descs[i].addr),
++ DMA_ATTR_NO_KERNEL_MAPPING | DMA_ATTR_NO_WARN);
+ }
+
+ kfree(bufs);
+--
+2.19.1
+
--- /dev/null
+From bb26cf13298c0024341d3ce2d7f94d791f13f903 Mon Sep 17 00:00:00 2001
+From: Jin Yao <yao.jin@linux.intel.com>
+Date: Fri, 4 Jan 2019 14:10:30 +0800
+Subject: perf report: Fix wrong iteration count in --branch-history
+
+[ Upstream commit a3366db06bb656cef2e03f30f780d93059bcc594 ]
+
+By calculating the removed loops, we can get the iteration count.
+
+But the iteration count could be reported incorrectly, reporting
+impossibly high counts.
+
+That's because previous code uses the number of removed LBR entries for
+the iteration count. That's not good. Fix this by increasing the
+iteration count when a loop is detected.
+
+When matching the chain, the iteration count would be added up, finally we need
+to compute the average value when printing out.
+
+For example,
+
+ $ perf report --branch-history --stdio --no-children
+
+Before:
+
+ ---f2 +0
+ |
+ |--33.62%--f1 +9 (cycles:1)
+ | f1 +0
+ | main +22 (cycles:1)
+ | main +17
+ | main +38 (cycles:1)
+ | main +27
+ | f1 +26 (cycles:1)
+ | f1 +24
+ | f2 +27 (cycles:7)
+ | f2 +0
+ | f1 +19 (cycles:1)
+ | f1 +14
+ | f2 +27 (cycles:11)
+ | f2 +0
+ | f1 +9 (cycles:1 iter:2968 avg_cycles:3)
+ | f1 +0
+ | main +22 (cycles:1 iter:2968 avg_cycles:3)
+ | main +17
+ | main +38 (cycles:1 iter:2968 avg_cycles:3)
+
+2968 is an impossible high iteration count and avg_cycles is too small.
+
+After:
+
+ ---f2 +0
+ |
+ |--33.62%--f1 +9 (cycles:1)
+ | f1 +0
+ | main +22 (cycles:1)
+ | main +17
+ | main +38 (cycles:1)
+ | main +27
+ | f1 +26 (cycles:1)
+ | f1 +24
+ | f2 +27 (cycles:7)
+ | f2 +0
+ | f1 +19 (cycles:1)
+ | f1 +14
+ | f2 +27 (cycles:11)
+ | f2 +0
+ | f1 +9 (cycles:1 iter:1 avg_cycles:23)
+ | f1 +0
+ | main +22 (cycles:1 iter:1 avg_cycles:23)
+ | main +17
+ | main +38 (cycles:1 iter:1 avg_cycles:23)
+
+avg_cycles:23 is the average cycles of this iteration.
+
+Fixes: c4ee06251d42 ("perf report: Calculate the average cycles of iterations")
+
+Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
+Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
+Cc: Andi Kleen <ak@linux.intel.com>
+Cc: Jiri Olsa <jolsa@kernel.org>
+Cc: Kan Liang <kan.liang@linux.intel.com>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Link: http://lkml.kernel.org/r/1546582230-17507-1-git-send-email-yao.jin@linux.intel.com
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/perf/util/callchain.c | 32 ++++++++++++++++++++------------
+ tools/perf/util/callchain.h | 1 +
+ tools/perf/util/machine.c | 2 +-
+ 3 files changed, 22 insertions(+), 13 deletions(-)
+
+diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
+index 32ef7bdca1cf..dc2212e12184 100644
+--- a/tools/perf/util/callchain.c
++++ b/tools/perf/util/callchain.c
+@@ -766,6 +766,7 @@ static enum match_result match_chain(struct callchain_cursor_node *node,
+ cnode->cycles_count += node->branch_flags.cycles;
+ cnode->iter_count += node->nr_loop_iter;
+ cnode->iter_cycles += node->iter_cycles;
++ cnode->from_count++;
+ }
+ }
+
+@@ -1345,10 +1346,10 @@ static int branch_to_str(char *bf, int bfsize,
+ static int branch_from_str(char *bf, int bfsize,
+ u64 branch_count,
+ u64 cycles_count, u64 iter_count,
+- u64 iter_cycles)
++ u64 iter_cycles, u64 from_count)
+ {
+ int printed = 0, i = 0;
+- u64 cycles;
++ u64 cycles, v = 0;
+
+ cycles = cycles_count / branch_count;
+ if (cycles) {
+@@ -1357,14 +1358,16 @@ static int branch_from_str(char *bf, int bfsize,
+ bf + printed, bfsize - printed);
+ }
+
+- if (iter_count) {
+- printed += count_pri64_printf(i++, "iter",
+- iter_count,
+- bf + printed, bfsize - printed);
++ if (iter_count && from_count) {
++ v = iter_count / from_count;
++ if (v) {
++ printed += count_pri64_printf(i++, "iter",
++ v, bf + printed, bfsize - printed);
+
+- printed += count_pri64_printf(i++, "avg_cycles",
+- iter_cycles / iter_count,
+- bf + printed, bfsize - printed);
++ printed += count_pri64_printf(i++, "avg_cycles",
++ iter_cycles / iter_count,
++ bf + printed, bfsize - printed);
++ }
+ }
+
+ if (i)
+@@ -1377,6 +1380,7 @@ static int counts_str_build(char *bf, int bfsize,
+ u64 branch_count, u64 predicted_count,
+ u64 abort_count, u64 cycles_count,
+ u64 iter_count, u64 iter_cycles,
++ u64 from_count,
+ struct branch_type_stat *brtype_stat)
+ {
+ int printed;
+@@ -1389,7 +1393,8 @@ static int counts_str_build(char *bf, int bfsize,
+ predicted_count, abort_count, brtype_stat);
+ } else {
+ printed = branch_from_str(bf, bfsize, branch_count,
+- cycles_count, iter_count, iter_cycles);
++ cycles_count, iter_count, iter_cycles,
++ from_count);
+ }
+
+ if (!printed)
+@@ -1402,13 +1407,14 @@ static int callchain_counts_printf(FILE *fp, char *bf, int bfsize,
+ u64 branch_count, u64 predicted_count,
+ u64 abort_count, u64 cycles_count,
+ u64 iter_count, u64 iter_cycles,
++ u64 from_count,
+ struct branch_type_stat *brtype_stat)
+ {
+ char str[256];
+
+ counts_str_build(str, sizeof(str), branch_count,
+ predicted_count, abort_count, cycles_count,
+- iter_count, iter_cycles, brtype_stat);
++ iter_count, iter_cycles, from_count, brtype_stat);
+
+ if (fp)
+ return fprintf(fp, "%s", str);
+@@ -1422,6 +1428,7 @@ int callchain_list_counts__printf_value(struct callchain_list *clist,
+ u64 branch_count, predicted_count;
+ u64 abort_count, cycles_count;
+ u64 iter_count, iter_cycles;
++ u64 from_count;
+
+ branch_count = clist->branch_count;
+ predicted_count = clist->predicted_count;
+@@ -1429,11 +1436,12 @@ int callchain_list_counts__printf_value(struct callchain_list *clist,
+ cycles_count = clist->cycles_count;
+ iter_count = clist->iter_count;
+ iter_cycles = clist->iter_cycles;
++ from_count = clist->from_count;
+
+ return callchain_counts_printf(fp, bf, bfsize, branch_count,
+ predicted_count, abort_count,
+ cycles_count, iter_count, iter_cycles,
+- &clist->brtype_stat);
++ from_count, &clist->brtype_stat);
+ }
+
+ static void free_callchain_node(struct callchain_node *node)
+diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
+index 154560b1eb65..99d38ac019b8 100644
+--- a/tools/perf/util/callchain.h
++++ b/tools/perf/util/callchain.h
+@@ -118,6 +118,7 @@ struct callchain_list {
+ bool has_children;
+ };
+ u64 branch_count;
++ u64 from_count;
+ u64 predicted_count;
+ u64 abort_count;
+ u64 cycles_count;
+diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
+index 9397e3f2444d..ea228dd0a187 100644
+--- a/tools/perf/util/machine.c
++++ b/tools/perf/util/machine.c
+@@ -2005,7 +2005,7 @@ static void save_iterations(struct iterations *iter,
+ {
+ int i;
+
+- iter->nr_loop_iter = nr;
++ iter->nr_loop_iter++;
+ iter->cycles = 0;
+
+ for (i = 0; i < nr; i++)
+--
+2.19.1
+
--- /dev/null
+From 7033f9df036faae782221528c8240cb8b0525904 Mon Sep 17 00:00:00 2001
+From: Jin Yao <yao.jin@linux.intel.com>
+Date: Thu, 3 Jan 2019 15:40:45 +0800
+Subject: perf stat: Fix endless wait for child process
+
+[ Upstream commit 8a99255a50c0b4c2a449b96fd8d45fcc8d72c701 ]
+
+We hit a 'perf stat' issue by using following script:
+
+ #!/bin/bash
+
+ sleep 1000 &
+ exec perf stat -a -e cycles -I1000 -- sleep 5
+
+Since "perf stat" is launched by exec, the "sleep 1000" would be the
+child process of "perf stat". The wait4() call will not return because
+it's waiting for the child process "sleep 1000" to end. So 'perf stat'
+doesn't return even after 5s passes.
+
+This patch lets 'perf stat' return when the specified child process ends
+(in this case, the specified child process is "sleep 5").
+
+Committer testing:
+
+ # cat test.sh
+ #!/bin/bash
+
+ sleep 10 &
+ exec perf stat -a -e cycles -I1000 -- sleep 5
+ #
+
+Before:
+
+ # time ./test.sh
+ # time counts unit events
+ 1.001113090 108,453,351 cycles
+ 2.002062196 142,075,435 cycles
+ 3.002896194 164,801,068 cycles
+ 4.003731666 107,062,140 cycles
+ 5.002068867 112,241,832 cycles
+
+ real 0m10.066s
+ user 0m0.016s
+ sys 0m0.101s
+ #
+
+After:
+
+ # time ./test.sh
+ # time counts unit events
+ 1.001016096 91,412,027 cycles
+ 2.002014963 124,063,708 cycles
+ 3.002883964 125,993,929 cycles
+ 4.003706470 120,465,734 cycles
+ 5.002006778 163,560,355 cycles
+
+ real 0m5.123s
+ user 0m0.014s
+ sys 0m0.105s
+ #
+
+Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
+Reviewed-by: Jiri Olsa <jolsa@kernel.org>
+Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
+Cc: Andi Kleen <ak@linux.intel.com>
+Cc: Kan Liang <kan.liang@linux.intel.com>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Link: http://lkml.kernel.org/r/1546501245-4512-1-git-send-email-yao.jin@linux.intel.com
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/perf/builtin-stat.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
+index 1410d66192f7..63a3afc7f32b 100644
+--- a/tools/perf/builtin-stat.c
++++ b/tools/perf/builtin-stat.c
+@@ -561,7 +561,8 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
+ break;
+ }
+ }
+- wait4(child_pid, &status, 0, &stat_config.ru_data);
++ if (child_pid != -1)
++ wait4(child_pid, &status, 0, &stat_config.ru_data);
+
+ if (workload_exec_errno) {
+ const char *emsg = str_error_r(workload_exec_errno, msg, sizeof(msg));
+--
+2.19.1
+
--- /dev/null
+From 56f3675d5839e54c3255f2c5f1fced3115790b32 Mon Sep 17 00:00:00 2001
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+Date: Fri, 4 Jan 2019 15:10:00 -0300
+Subject: perf test shell: Use a fallback to get the pathname in vfs_getname
+
+[ Upstream commit 03fa483821c0b4db7c2b1453d3332f397d82313f ]
+
+Some kernels, like 4.19.13-300.fc29.x86_64 in fedora 29, fail with the
+existing probe definition asking for the contents of result->name,
+working when we ask for the 'filename' variable instead, so add a
+fallback to that.
+
+Now those tests are back working on fedora 29 systems with that kernel:
+
+ # perf test vfs_getname
+ 65: Use vfs_getname probe to get syscall args filenames : Ok
+ 66: Add vfs_getname probe to get syscall args filenames : Ok
+ 67: Check open filename arg using perf trace + vfs_getname: Ok
+ #
+
+Cc: Adrian Hunter <adrian.hunter@intel.com>
+Cc: Jiri Olsa <jolsa@kernel.org>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Link: https://lkml.kernel.org/n/tip-klt3n0i58dfqttveti09q3fi@git.kernel.org
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/perf/tests/shell/lib/probe_vfs_getname.sh | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/tools/perf/tests/shell/lib/probe_vfs_getname.sh b/tools/perf/tests/shell/lib/probe_vfs_getname.sh
+index 1c16e56cd93e..7cb99b433888 100644
+--- a/tools/perf/tests/shell/lib/probe_vfs_getname.sh
++++ b/tools/perf/tests/shell/lib/probe_vfs_getname.sh
+@@ -13,7 +13,8 @@ add_probe_vfs_getname() {
+ local verbose=$1
+ if [ $had_vfs_getname -eq 1 ] ; then
+ line=$(perf probe -L getname_flags 2>&1 | egrep 'result.*=.*filename;' | sed -r 's/[[:space:]]+([[:digit:]]+)[[:space:]]+result->uptr.*/\1/')
+- perf probe $verbose "vfs_getname=getname_flags:${line} pathname=result->name:string"
++ perf probe -q "vfs_getname=getname_flags:${line} pathname=result->name:string" || \
++ perf probe $verbose "vfs_getname=getname_flags:${line} pathname=filename:string"
+ fi
+ }
+
+--
+2.19.1
+
--- /dev/null
+From 0dc77647caaec2001b5421c081851f3d13145e30 Mon Sep 17 00:00:00 2001
+From: David Abdurachmanov <david.abdurachmanov@gmail.com>
+Date: Thu, 6 Dec 2018 16:26:34 +0100
+Subject: riscv: fix trace_sys_exit hook
+
+[ Upstream commit 775800b0f1d7303d4fd8ce0e0d9eca4ff2f338f2 ]
+
+Fix compilation error.
+
+Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
+Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/riscv/kernel/ptrace.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/arch/riscv/kernel/ptrace.c b/arch/riscv/kernel/ptrace.c
+index 60f1e02eed36..6c898d540d9d 100644
+--- a/arch/riscv/kernel/ptrace.c
++++ b/arch/riscv/kernel/ptrace.c
+@@ -172,6 +172,6 @@ void do_syscall_trace_exit(struct pt_regs *regs)
+
+ #ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
+ if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
+- trace_sys_exit(regs, regs->regs[0]);
++ trace_sys_exit(regs, regs_return_value(regs));
+ #endif
+ }
+--
+2.19.1
+
--- /dev/null
+dt-bindings-eeprom-at24-add-atmel-24c2048-compatible.patch
+eeprom-at24-add-support-for-24c2048.patch
+blk-mq-fix-a-hung-issue-when-fsync.patch
+drm-amdgpu-sriov-correct-pfvf-exchange-logic.patch
+acpi-numa-use-correct-type-for-printing-addresses-on.patch
+perf-stat-fix-endless-wait-for-child-process.patch
+perf-report-fix-wrong-iteration-count-in-branch-hist.patch
+perf-test-shell-use-a-fallback-to-get-the-pathname-i.patch
+soc-renesas-r8a774c0-sysc-fix-initialization-order-o.patch
+tools-uapi-fix-risc-v-64-bit-support.patch
+riscv-fix-trace_sys_exit-hook.patch
+cpufreq-check-if-policy-is-inactive-early-in-__cpufr.patch
+csky-fixup-relocation-error-with-807-860.patch
+csky-fixup-cachev1-store-instruction-fast-retire.patch
+csky-fixup-compile-error-with-pte_alloc.patch
+irqchip-csky-fixup-handle_irq_perbit-break-irq.patch
+drm-amd-powerplay-avoid-possible-buffer-overflow.patch
+drm-bridge-tc358767-add-bus-flags.patch
+drm-bridge-tc358767-add-defines-for-dp1_srcctrl-phy_.patch
+drm-bridge-tc358767-fix-single-lane-configuration.patch
+drm-bridge-tc358767-fix-initial-dp0-1_srcctrl-value.patch
+drm-bridge-tc358767-reject-modes-which-require-too-m.patch
+drm-bridge-tc358767-fix-output-h-v-syncs.patch
+nvme-pci-use-the-same-attributes-when-freeing-host_m.patch
+nvme-pci-fix-out-of-bounds-access-in-nvme_cqe_pendin.patch
+nvme-multipath-zero-out-ana-log-buffer.patch
+nvme-pad-fake-subsys-nqn-vid-and-ssvid-with-zeros.patch
+nvme-introduce-nvme_quirk_ignore_dev_subnqn.patch
+drm-amdgpu-fix-cpdma-hang-in-prt-mode-for-vega20.patch
+drm-amdgpu-set-write_burst_length-to-64b-to-workarou.patch
+drm-amdgpu-disable-system-memory-page-tables-for-now.patch
+arm-dts-da850-evm-correct-the-audio-codec-regulators.patch
+arm-dts-da850-evm-correct-the-sound-card-name.patch
+arm-dts-da850-lcdk-correct-the-audio-codec-regulator.patch
+arm-dts-da850-lcdk-correct-the-sound-card-name.patch
+arm-dts-kirkwood-fix-polarity-of-gpio-fan-lines.patch
+csky-fixup-compile-error-with-cpu-810.patch
+gpio-pl061-handle-failed-allocations.patch
+drm-nouveau-don-t-disable-polling-in-fallback-mode.patch
+drm-nouveau-falcon-avoid-touching-registers-if-engin.patch
+cifs-limit-memory-used-by-lock-request-calls-to-a-pa.patch
+cifs-fix-credits-calculation-for-cancelled-requests.patch
+cifs-move-credit-processing-to-mid-callbacks-for-smb.patch
+cifs-fix-error-paths-in-writeback-code.patch
+kvm-sev-fail-kvm_sev_init-if-already-initialized.patch
+cifs-fix-credit-calculations-in-compound-mid-callbac.patch
+cifs-do-not-assume-one-credit-for-async-responses.patch
+cifs-fix-mounts-if-the-client-is-low-on-credits.patch
--- /dev/null
+From fe5e9829ced379bd97d960900916d43ca8f42c77 Mon Sep 17 00:00:00 2001
+From: Biju Das <biju.das@bp.renesas.com>
+Date: Wed, 12 Dec 2018 12:17:11 +0000
+Subject: soc: renesas: r8a774c0-sysc: Fix initialization order of 3DG-{A,B}
+
+[ Upstream commit a64597227d0de5610407fcc95dc835745a53f5d0 ]
+
+The workaround for the wrong hierarchy of the 3DG-{A,B} power domains on
+RZ/G2E ES1.0 corrected the parent domains. However, the 3DG-{A,B} power
+domains were still initialized and powered in the wrong order, causing
+3DG operation to fail.
+
+Fix this by changing the order in the table at runtime, when running on
+an affected SoC.
+
+This work is based on the work done by Geert for R-Car E3.
+
+Fixes: f37d211c687588328 ("soc: renesas: rcar-sysc: Add r8a774c0 support")
+
+Signed-off-by: Biju Das <biju.das@bp.renesas.com>
+Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
+Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/soc/renesas/r8a774c0-sysc.c | 23 ++++-------------------
+ 1 file changed, 4 insertions(+), 19 deletions(-)
+
+diff --git a/drivers/soc/renesas/r8a774c0-sysc.c b/drivers/soc/renesas/r8a774c0-sysc.c
+index e1ac4c0f6640..11050e17ea81 100644
+--- a/drivers/soc/renesas/r8a774c0-sysc.c
++++ b/drivers/soc/renesas/r8a774c0-sysc.c
+@@ -28,19 +28,6 @@ static struct rcar_sysc_area r8a774c0_areas[] __initdata = {
+ { "3dg-b", 0x100, 1, R8A774C0_PD_3DG_B, R8A774C0_PD_3DG_A },
+ };
+
+-static void __init rcar_sysc_fix_parent(struct rcar_sysc_area *areas,
+- unsigned int num_areas, u8 id,
+- int new_parent)
+-{
+- unsigned int i;
+-
+- for (i = 0; i < num_areas; i++)
+- if (areas[i].isr_bit == id) {
+- areas[i].parent = new_parent;
+- return;
+- }
+-}
+-
+ /* Fixups for RZ/G2E ES1.0 revision */
+ static const struct soc_device_attribute r8a774c0[] __initconst = {
+ { .soc_id = "r8a774c0", .revision = "ES1.0" },
+@@ -50,12 +37,10 @@ static const struct soc_device_attribute r8a774c0[] __initconst = {
+ static int __init r8a774c0_sysc_init(void)
+ {
+ if (soc_device_match(r8a774c0)) {
+- rcar_sysc_fix_parent(r8a774c0_areas,
+- ARRAY_SIZE(r8a774c0_areas),
+- R8A774C0_PD_3DG_A, R8A774C0_PD_3DG_B);
+- rcar_sysc_fix_parent(r8a774c0_areas,
+- ARRAY_SIZE(r8a774c0_areas),
+- R8A774C0_PD_3DG_B, R8A774C0_PD_ALWAYS_ON);
++ /* Fix incorrect 3DG hierarchy */
++ swap(r8a774c0_areas[6], r8a774c0_areas[7]);
++ r8a774c0_areas[6].parent = R8A774C0_PD_ALWAYS_ON;
++ r8a774c0_areas[7].parent = R8A774C0_PD_3DG_B;
+ }
+
+ return 0;
+--
+2.19.1
+
--- /dev/null
+From c4157ff1444df1eaaacc291b138d3712fa2ed8f8 Mon Sep 17 00:00:00 2001
+From: Aurelien Jarno <aurelien@aurel32.net>
+Date: Tue, 25 Dec 2018 15:46:24 +0100
+Subject: tools uapi: fix RISC-V 64-bit support
+
+[ Upstream commit d0df00e30e4bf9bc27ddbd092ad683ff6121b360 ]
+
+The BPF library is not built on 64-bit RISC-V, as the BPF feature is
+not detected. Looking more in details, feature/test-bpf.c fails to build
+with the following error:
+
+| In file included from /tmp/linux-4.19.12/tools/include/uapi/asm/bitsperlong.h:17,
+| from /tmp/linux-4.19.12/tools/include/uapi/asm-generic/unistd.h:2,
+| from /usr/include/riscv64-linux-gnu/asm/unistd.h:1,
+| from test-bpf.c:2:
+| /tmp/linux-4.19.12/tools/include/asm-generic/bitsperlong.h:14:2: error: #error Inconsistent word size. Check asm/bitsperlong.h
+| #error Inconsistent word size. Check asm/bitsperlong.h
+| ^~~~~
+
+The UAPI from the tools directory is missing RISC-V support, therefore
+bitsperlong.h from asm-generic is used, defaulting to 32 bits.
+
+Fix that by adding tools/arch/riscv/include/uapi/asm/bitsperlong.h as
+a copy of arch/riscv/include/uapi/asm/bitsperlong.h and by updating
+tools/include/uapi/asm/bitsperlong.h.
+
+Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
+Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ .../arch/riscv/include/uapi/asm/bitsperlong.h | 25 +++++++++++++++++++
+ tools/include/uapi/asm/bitsperlong.h | 2 ++
+ 2 files changed, 27 insertions(+)
+ create mode 100644 tools/arch/riscv/include/uapi/asm/bitsperlong.h
+
+diff --git a/tools/arch/riscv/include/uapi/asm/bitsperlong.h b/tools/arch/riscv/include/uapi/asm/bitsperlong.h
+new file mode 100644
+index 000000000000..0b3cb52fd29d
+--- /dev/null
++++ b/tools/arch/riscv/include/uapi/asm/bitsperlong.h
+@@ -0,0 +1,25 @@
++/*
++ * Copyright (C) 2012 ARM Ltd.
++ * Copyright (C) 2015 Regents of the University of California
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License version 2 as
++ * published by the Free Software Foundation.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program. If not, see <http://www.gnu.org/licenses/>.
++ */
++
++#ifndef _UAPI_ASM_RISCV_BITSPERLONG_H
++#define _UAPI_ASM_RISCV_BITSPERLONG_H
++
++#define __BITS_PER_LONG (__SIZEOF_POINTER__ * 8)
++
++#include <asm-generic/bitsperlong.h>
++
++#endif /* _UAPI_ASM_RISCV_BITSPERLONG_H */
+diff --git a/tools/include/uapi/asm/bitsperlong.h b/tools/include/uapi/asm/bitsperlong.h
+index 8dd6aefdafa4..fd92ce8388fc 100644
+--- a/tools/include/uapi/asm/bitsperlong.h
++++ b/tools/include/uapi/asm/bitsperlong.h
+@@ -13,6 +13,8 @@
+ #include "../../arch/mips/include/uapi/asm/bitsperlong.h"
+ #elif defined(__ia64__)
+ #include "../../arch/ia64/include/uapi/asm/bitsperlong.h"
++#elif defined(__riscv)
++#include "../../arch/riscv/include/uapi/asm/bitsperlong.h"
+ #else
+ #include <asm-generic/bitsperlong.h>
+ #endif
+--
+2.19.1
+