]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
3.2-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 16 Mar 2012 17:40:38 +0000 (10:40 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 16 Mar 2012 17:40:38 +0000 (10:40 -0700)
added patches:
hwmon-w83627ehf-fix-memory-leak-in-probe-function.patch
hwmon-w83627ehf-fix-temp2-source-for-w83627uhg.patch
hwmon-w83627ehf-fix-writing-into-fan_stop_time-for-nct6775f-nct6776f.patch
i2c-algo-bit-fix-spurious-scl-timeouts-under-heavy-load.patch
iscsi-target-fix-reservation-conflict-ebusy-response-handling-bug.patch
rapidio-tsi721-fix-bug-in-register-offset-definitions.patch
target-fix-compatible-reservation-handling-crh-1-with-legacy-reserve-release.patch

queue-3.2/hwmon-w83627ehf-fix-memory-leak-in-probe-function.patch [new file with mode: 0644]
queue-3.2/hwmon-w83627ehf-fix-temp2-source-for-w83627uhg.patch [new file with mode: 0644]
queue-3.2/hwmon-w83627ehf-fix-writing-into-fan_stop_time-for-nct6775f-nct6776f.patch [new file with mode: 0644]
queue-3.2/i2c-algo-bit-fix-spurious-scl-timeouts-under-heavy-load.patch [new file with mode: 0644]
queue-3.2/iscsi-target-fix-reservation-conflict-ebusy-response-handling-bug.patch [new file with mode: 0644]
queue-3.2/rapidio-tsi721-fix-bug-in-register-offset-definitions.patch [new file with mode: 0644]
queue-3.2/series
queue-3.2/target-fix-compatible-reservation-handling-crh-1-with-legacy-reserve-release.patch [new file with mode: 0644]

diff --git a/queue-3.2/hwmon-w83627ehf-fix-memory-leak-in-probe-function.patch b/queue-3.2/hwmon-w83627ehf-fix-memory-leak-in-probe-function.patch
new file mode 100644 (file)
index 0000000..484546e
--- /dev/null
@@ -0,0 +1,51 @@
+From 32260d94408c553dca4ce54104edf79941a27536 Mon Sep 17 00:00:00 2001
+From: Guenter Roeck <linux@roeck-us.net>
+Date: Mon, 12 Mar 2012 08:33:10 -0700
+Subject: hwmon: (w83627ehf) Fix memory leak in probe function
+
+From: Guenter Roeck <linux@roeck-us.net>
+
+commit 32260d94408c553dca4ce54104edf79941a27536 upstream.
+
+The driver probe function leaked memory if creating the cpu0_vid attribute file
+failed. Fix by converting the driver to use devm_kzalloc.
+
+Signed-off-by: Guenter Roeck <linux@roeck-us.net>
+Acked-by: Jean Delvare <khali@linux-fr.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/hwmon/w83627ehf.c |    7 +++----
+ 1 file changed, 3 insertions(+), 4 deletions(-)
+
+--- a/drivers/hwmon/w83627ehf.c
++++ b/drivers/hwmon/w83627ehf.c
+@@ -2004,7 +2004,8 @@ static int __devinit w83627ehf_probe(str
+               goto exit;
+       }
+-      data = kzalloc(sizeof(struct w83627ehf_data), GFP_KERNEL);
++      data = devm_kzalloc(&pdev->dev, sizeof(struct w83627ehf_data),
++                          GFP_KERNEL);
+       if (!data) {
+               err = -ENOMEM;
+               goto exit_release;
+@@ -2498,9 +2499,8 @@ static int __devinit w83627ehf_probe(str
+ exit_remove:
+       w83627ehf_device_remove_files(dev);
+-      kfree(data);
+-      platform_set_drvdata(pdev, NULL);
+ exit_release:
++      platform_set_drvdata(pdev, NULL);
+       release_region(res->start, IOREGION_LENGTH);
+ exit:
+       return err;
+@@ -2514,7 +2514,6 @@ static int __devexit w83627ehf_remove(st
+       w83627ehf_device_remove_files(&pdev->dev);
+       release_region(data->addr, IOREGION_LENGTH);
+       platform_set_drvdata(pdev, NULL);
+-      kfree(data);
+       return 0;
+ }
diff --git a/queue-3.2/hwmon-w83627ehf-fix-temp2-source-for-w83627uhg.patch b/queue-3.2/hwmon-w83627ehf-fix-temp2-source-for-w83627uhg.patch
new file mode 100644 (file)
index 0000000..4632569
--- /dev/null
@@ -0,0 +1,65 @@
+From aacb6b0052692c72fe0cb94c6b547202def6ef46 Mon Sep 17 00:00:00 2001
+From: Jean Delvare <khali@linux-fr.org>
+Date: Tue, 13 Mar 2012 04:03:27 -0400
+Subject: hwmon: (w83627ehf) Fix temp2 source for W83627UHG
+
+From: Jean Delvare <khali@linux-fr.org>
+
+commit aacb6b0052692c72fe0cb94c6b547202def6ef46 upstream.
+
+Properly set the source of temp2 for the W83627UHG. Also fix a
+comment right before that, and document the W83627UHG as reporting up
+to 3 temperatures.
+
+Signed-off-by: Jean Delvare <khali@linux-fr.org>
+Cc: Guenter Roeck <guenter.roeck@ericsson.com>
+Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ Documentation/hwmon/w83627ehf |    2 +-
+ drivers/hwmon/w83627ehf.c     |    8 ++++----
+ 2 files changed, 5 insertions(+), 5 deletions(-)
+
+--- a/Documentation/hwmon/w83627ehf
++++ b/Documentation/hwmon/w83627ehf
+@@ -50,7 +50,7 @@ W83627DHG, W83627DHG-P, W83627UHG, W8366
+ (NCT6775F), and NCT6776F super I/O chips. We will refer to them collectively
+ as Winbond chips.
+-The chips implement 2 to 4 temperature sensors (9 for NCT6775F and NCT6776F),
++The chips implement 3 to 4 temperature sensors (9 for NCT6775F and NCT6776F),
+ 2 to 5 fan rotation speed sensors, 8 to 10 analog voltage sensors, one VID
+ (except for 627UHG), alarms with beep warnings (control unimplemented),
+ and some automatic fan regulation strategies (plus manual fan control mode).
+--- a/drivers/hwmon/w83627ehf.c
++++ b/drivers/hwmon/w83627ehf.c
+@@ -39,7 +39,7 @@
+                                              0x8860 0xa1
+     w83627dhg    9      5       4       3      0xa020 0xc1    0x5ca3
+     w83627dhg-p  9      5       4       3      0xb070 0xc1    0x5ca3
+-    w83627uhg    8      2       2       2      0xa230 0xc1    0x5ca3
++    w83627uhg    8      2       2       3      0xa230 0xc1    0x5ca3
+     w83667hg     9      5       3       3      0xa510 0xc1    0x5ca3
+     w83667hg-b   9      5       3       4      0xb350 0xc1    0x5ca3
+     nct6775f     9      4       3       9      0xb470 0xc1    0x5ca3
+@@ -2158,16 +2158,16 @@ static int __devinit w83627ehf_probe(str
+               w83627ehf_set_temp_reg_ehf(data, 3);
+               /*
+-               * Temperature sources for temp1 and temp2 are selected with
++               * Temperature sources for temp2 and temp3 are selected with
+                * bank 0, registers 0x49 and 0x4a.
+                */
+               data->temp_src[0] = 0;  /* SYSTIN */
+               reg = w83627ehf_read_value(data, 0x49) & 0x07;
+               /* Adjust to have the same mapping as other source registers */
+               if (reg == 0)
+-                      data->temp_src[1]++;
++                      data->temp_src[1] = 1;
+               else if (reg >= 2 && reg <= 5)
+-                      data->temp_src[1] += 2;
++                      data->temp_src[1] = reg + 2;
+               else    /* should never happen */
+                       data->have_temp &= ~(1 << 1);
+               reg = w83627ehf_read_value(data, 0x4a);
diff --git a/queue-3.2/hwmon-w83627ehf-fix-writing-into-fan_stop_time-for-nct6775f-nct6776f.patch b/queue-3.2/hwmon-w83627ehf-fix-writing-into-fan_stop_time-for-nct6775f-nct6776f.patch
new file mode 100644 (file)
index 0000000..5ef7739
--- /dev/null
@@ -0,0 +1,32 @@
+From 33fa9b620409edfc71aa6cf01a51f990fbe46ab8 Mon Sep 17 00:00:00 2001
+From: Guenter Roeck <linux@roeck-us.net>
+Date: Mon, 12 Mar 2012 08:21:16 -0700
+Subject: hwmon: (w83627ehf) Fix writing into fan_stop_time for NCT6775F/NCT6776F
+
+From: Guenter Roeck <linux@roeck-us.net>
+
+commit 33fa9b620409edfc71aa6cf01a51f990fbe46ab8 upstream.
+
+NCT6775F and NCT6776F have their own set of registers for FAN_STOP_TIME. The
+correct registers were used to read FAN_STOP_TIME, but writes used the wrong
+registers. Fix it.
+
+Signed-off-by: Guenter Roeck <linux@roeck-us.net>
+Acked-by: Jean Delvare <khali@linux-fr.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/hwmon/w83627ehf.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/hwmon/w83627ehf.c
++++ b/drivers/hwmon/w83627ehf.c
+@@ -1607,7 +1607,7 @@ store_##reg(struct device *dev, struct d
+       val = step_time_to_reg(val, data->pwm_mode[nr]); \
+       mutex_lock(&data->update_lock); \
+       data->reg[nr] = val; \
+-      w83627ehf_write_value(data, W83627EHF_REG_##REG[nr], val); \
++      w83627ehf_write_value(data, data->REG_##REG[nr], val); \
+       mutex_unlock(&data->update_lock); \
+       return count; \
+ } \
diff --git a/queue-3.2/i2c-algo-bit-fix-spurious-scl-timeouts-under-heavy-load.patch b/queue-3.2/i2c-algo-bit-fix-spurious-scl-timeouts-under-heavy-load.patch
new file mode 100644 (file)
index 0000000..f457529
--- /dev/null
@@ -0,0 +1,43 @@
+From 8ee161ce5e0cfc689eb677f227a6248191165fac Mon Sep 17 00:00:00 2001
+From: Ville Syrjala <syrjala@sci.fi>
+Date: Thu, 15 Mar 2012 18:11:05 +0100
+Subject: i2c-algo-bit: Fix spurious SCL timeouts under heavy load
+
+From: Ville Syrjala <syrjala@sci.fi>
+
+commit 8ee161ce5e0cfc689eb677f227a6248191165fac upstream.
+
+When the system is under heavy load, there can be a significant delay
+between the getscl() and time_after() calls inside sclhi(). That delay
+may cause the time_after() check to trigger after SCL has gone high,
+causing sclhi() to return -ETIMEDOUT.
+
+To fix the problem, double check that SCL is still low after the
+timeout has been reached, before deciding to return -ETIMEDOUT.
+
+Signed-off-by: Ville Syrjala <syrjala@sci.fi>
+Signed-off-by: Jean Delvare <khali@linux-fr.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/i2c/algos/i2c-algo-bit.c |    8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+--- a/drivers/i2c/algos/i2c-algo-bit.c
++++ b/drivers/i2c/algos/i2c-algo-bit.c
+@@ -103,8 +103,14 @@ static int sclhi(struct i2c_algo_bit_dat
+                * chips may hold it low ("clock stretching") while they
+                * are processing data internally.
+                */
+-              if (time_after(jiffies, start + adap->timeout))
++              if (time_after(jiffies, start + adap->timeout)) {
++                      /* Test one last time, as we may have been preempted
++                       * between last check and timeout test.
++                       */
++                      if (getscl(adap))
++                              break;
+                       return -ETIMEDOUT;
++              }
+               cond_resched();
+       }
+ #ifdef DEBUG
diff --git a/queue-3.2/iscsi-target-fix-reservation-conflict-ebusy-response-handling-bug.patch b/queue-3.2/iscsi-target-fix-reservation-conflict-ebusy-response-handling-bug.patch
new file mode 100644 (file)
index 0000000..0a570bc
--- /dev/null
@@ -0,0 +1,48 @@
+From 00fdc6bbef77844ce397a7de7acfaf25e8e2e4eb Mon Sep 17 00:00:00 2001
+From: Nicholas Bellinger <nab@linux-iscsi.org>
+Date: Tue, 13 Mar 2012 18:20:11 -0700
+Subject: iscsi-target: Fix reservation conflict -EBUSY response handling bug
+
+From: Nicholas Bellinger <nab@linux-iscsi.org>
+
+commit 00fdc6bbef77844ce397a7de7acfaf25e8e2e4eb upstream.
+
+This patch addresses a iscsi-target specific bug related to reservation conflict
+handling in iscsit_handle_scsi_cmd() that has been causing reservation conflicts
+to complete and not fail as expected due to incorrect errno checking.  The problem
+occured with the change to return -EBUSY from transport_generic_cmd_sequencer() ->
+transport_generic_allocate_tasks() failures, that broke iscsit_handle_scsi_cmd()
+checking for -EINVAL in order to invoke a non GOOD status response.
+
+This was manifesting itself as data corruption with legacy SPC-2 reservations,
+but also effects iscsi-target LUNs with SPC-3 persistent reservations.
+
+This bug was originally introduced in lio-core commit:
+
+commit 03e98c9eb916f3f0868c1dc344dde2a60287ff72
+Author: Nicholas Bellinger <nab@linux-iscsi.org>
+Date:   Fri Nov 4 02:36:16 2011 -0700
+
+    target: Address legacy PYX_TRANSPORT_* return code breakage
+
+Reported-by: Martin Svec <martin.svec@zoner.cz>
+Cc: Martin Svec <martin.svec@zoner.cz>
+Cc: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/target/iscsi/iscsi_target.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/target/iscsi/iscsi_target.c
++++ b/drivers/target/iscsi/iscsi_target.c
+@@ -1029,7 +1029,7 @@ done:
+               return iscsit_add_reject_from_cmd(
+                               ISCSI_REASON_BOOKMARK_NO_RESOURCES,
+                               1, 1, buf, cmd);
+-      } else if (transport_ret == -EINVAL) {
++      } else if (transport_ret < 0) {
+               /*
+                * Unsupported SAM Opcode.  CHECK_CONDITION will be sent
+                * in iscsit_execute_cmd() during the CmdSN OOO Execution
diff --git a/queue-3.2/rapidio-tsi721-fix-bug-in-register-offset-definitions.patch b/queue-3.2/rapidio-tsi721-fix-bug-in-register-offset-definitions.patch
new file mode 100644 (file)
index 0000000..131f711
--- /dev/null
@@ -0,0 +1,101 @@
+From 9bbad7da76b3dd578fb55c862624366a8c9ccd22 Mon Sep 17 00:00:00 2001
+From: Alexandre Bounine <alexandre.bounine@idt.com>
+Date: Thu, 15 Mar 2012 15:17:09 -0700
+Subject: rapidio/tsi721: fix bug in register offset definitions
+
+From: Alexandre Bounine <alexandre.bounine@idt.com>
+
+commit 9bbad7da76b3dd578fb55c862624366a8c9ccd22 upstream.
+
+Fix indexed register offset definitions that use decimal (wrong) instead
+of hexadecimal (correct) notation for indexing multipliers.
+
+Incorrect definitions do not affect Tsi721 driver in its current default
+configuration because it uses only IDB queue 0.  Loss of inbound
+doorbell functionality should be observed if queue other than 0 is used.
+
+Signed-off-by: Alexandre Bounine <alexandre.bounine@idt.com>
+Cc: Matt Porter <mporter@kernel.crashing.org>
+Cc: Chul Kim <chul.kim@idt.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/rapidio/devices/tsi721.h |   30 +++++++++++++++---------------
+ 1 file changed, 15 insertions(+), 15 deletions(-)
+
+--- a/drivers/rapidio/devices/tsi721.h
++++ b/drivers/rapidio/devices/tsi721.h
+@@ -118,34 +118,34 @@
+ #define TSI721_IDB_ENTRY_SIZE 64
+-#define TSI721_IDQ_CTL(x)     (0x20000 + (x) * 1000)
++#define TSI721_IDQ_CTL(x)     (0x20000 + (x) * 0x1000)
+ #define TSI721_IDQ_SUSPEND    0x00000002
+ #define TSI721_IDQ_INIT               0x00000001
+-#define TSI721_IDQ_STS(x)     (0x20004 + (x) * 1000)
++#define TSI721_IDQ_STS(x)     (0x20004 + (x) * 0x1000)
+ #define TSI721_IDQ_RUN                0x00200000
+-#define TSI721_IDQ_MASK(x)    (0x20008 + (x) * 1000)
++#define TSI721_IDQ_MASK(x)    (0x20008 + (x) * 0x1000)
+ #define TSI721_IDQ_MASK_MASK  0xffff0000
+ #define TSI721_IDQ_MASK_PATT  0x0000ffff
+-#define TSI721_IDQ_RP(x)      (0x2000c + (x) * 1000)
++#define TSI721_IDQ_RP(x)      (0x2000c + (x) * 0x1000)
+ #define TSI721_IDQ_RP_PTR     0x0007ffff
+-#define TSI721_IDQ_WP(x)      (0x20010 + (x) * 1000)
++#define TSI721_IDQ_WP(x)      (0x20010 + (x) * 0x1000)
+ #define TSI721_IDQ_WP_PTR     0x0007ffff
+-#define TSI721_IDQ_BASEL(x)   (0x20014 + (x) * 1000)
++#define TSI721_IDQ_BASEL(x)   (0x20014 + (x) * 0x1000)
+ #define TSI721_IDQ_BASEL_ADDR 0xffffffc0
+-#define TSI721_IDQ_BASEU(x)   (0x20018 + (x) * 1000)
+-#define TSI721_IDQ_SIZE(x)    (0x2001c + (x) * 1000)
++#define TSI721_IDQ_BASEU(x)   (0x20018 + (x) * 0x1000)
++#define TSI721_IDQ_SIZE(x)    (0x2001c + (x) * 0x1000)
+ #define TSI721_IDQ_SIZE_VAL(size)     (__fls(size) - 4)
+ #define TSI721_IDQ_SIZE_MIN   512
+ #define TSI721_IDQ_SIZE_MAX   (512 * 1024)
+-#define TSI721_SR_CHINT(x)    (0x20040 + (x) * 1000)
+-#define TSI721_SR_CHINTE(x)   (0x20044 + (x) * 1000)
+-#define TSI721_SR_CHINTSET(x) (0x20048 + (x) * 1000)
++#define TSI721_SR_CHINT(x)    (0x20040 + (x) * 0x1000)
++#define TSI721_SR_CHINTE(x)   (0x20044 + (x) * 0x1000)
++#define TSI721_SR_CHINTSET(x) (0x20048 + (x) * 0x1000)
+ #define TSI721_SR_CHINT_ODBOK 0x00000020
+ #define TSI721_SR_CHINT_IDBQRCV       0x00000010
+ #define TSI721_SR_CHINT_SUSP  0x00000008
+@@ -156,7 +156,7 @@
+ #define TSI721_IBWIN_NUM      8
+-#define TSI721_IBWINLB(x)     (0x29000 + (x) * 20)
++#define TSI721_IBWINLB(x)     (0x29000 + (x) * 0x20)
+ #define TSI721_IBWINLB_BA     0xfffff000
+ #define TSI721_IBWINLB_WEN    0x00000001
+@@ -187,13 +187,13 @@
+  */
+ #define TSI721_OBWIN_NUM      TSI721_PC2SR_WINS
+-#define TSI721_OBWINLB(x)     (0x40000 + (x) * 20)
++#define TSI721_OBWINLB(x)     (0x40000 + (x) * 0x20)
+ #define TSI721_OBWINLB_BA     0xffff8000
+ #define TSI721_OBWINLB_WEN    0x00000001
+-#define TSI721_OBWINUB(x)     (0x40004 + (x) * 20)
++#define TSI721_OBWINUB(x)     (0x40004 + (x) * 0x20)
+-#define TSI721_OBWINSZ(x)     (0x40008 + (x) * 20)
++#define TSI721_OBWINSZ(x)     (0x40008 + (x) * 0x20)
+ #define TSI721_OBWINSZ_SIZE   0x00001f00
+ #define TSI721_OBWIN_SIZE(size)       (__fls(size) - 15)
index e7ebf8807c2f382da8f727ac1aadb46060e377f2..b96fe7536f275967d72fb67fa2d6d04c03001809 100644 (file)
@@ -31,3 +31,10 @@ block-sx8-fix-pointer-math-issue-getting-fw-version.patch
 block-fix-__blkdev_get-and-add_disk-race-condition.patch
 block-use-a-freezable-workqueue-for-disk-event-polling.patch
 sparc32-add-av8-to-assembler-command-line.patch
+hwmon-w83627ehf-fix-writing-into-fan_stop_time-for-nct6775f-nct6776f.patch
+hwmon-w83627ehf-fix-memory-leak-in-probe-function.patch
+hwmon-w83627ehf-fix-temp2-source-for-w83627uhg.patch
+rapidio-tsi721-fix-bug-in-register-offset-definitions.patch
+i2c-algo-bit-fix-spurious-scl-timeouts-under-heavy-load.patch
+iscsi-target-fix-reservation-conflict-ebusy-response-handling-bug.patch
+target-fix-compatible-reservation-handling-crh-1-with-legacy-reserve-release.patch
diff --git a/queue-3.2/target-fix-compatible-reservation-handling-crh-1-with-legacy-reserve-release.patch b/queue-3.2/target-fix-compatible-reservation-handling-crh-1-with-legacy-reserve-release.patch
new file mode 100644 (file)
index 0000000..cf8b7ed
--- /dev/null
@@ -0,0 +1,147 @@
+From 087a03b3ea1c8d6e2d5743a8d1c6d571058caa04 Mon Sep 17 00:00:00 2001
+From: Nicholas Bellinger <nab@linux-iscsi.org>
+Date: Tue, 13 Mar 2012 21:29:06 -0700
+Subject: target: Fix compatible reservation handling (CRH=1) with legacy RESERVE/RELEASE
+
+From: Nicholas Bellinger <nab@linux-iscsi.org>
+
+commit 087a03b3ea1c8d6e2d5743a8d1c6d571058caa04 upstream.
+
+This patch addresses a bug with target_check_scsi2_reservation_conflict()
+return checking in target_scsi2_reservation_[reserve,release]() that was
+preventing CRH=1 operation from silently succeeding in the two special
+cases defined by SPC-3, and not failing with reservation conflict status
+when dealing with legacy RESERVE/RELEASE + active SPC-3 PR logic.
+
+Also explictly set cmd->scsi_status = SAM_STAT_RESERVATION_CONFLICT during
+the early non reservation holder failure from pr_ops->t10_seq_non_holder()
+check in transport_generic_cmd_sequencer() for fabrics that already expect
+it to be set.
+
+This bug was originally introduced in mainline commit:
+
+commit eacac00ce5bfde8086cd0615fb53c986f7f970fe
+Author: Christoph Hellwig <hch@infradead.org>
+Date:   Thu Nov 3 17:50:40 2011 -0400
+
+    target: split core_scsi2_emulate_crh
+
+Reported-by: Martin Svec <martin.svec@zoner.cz>
+Cc: Martin Svec <martin.svec@zoner.cz>
+Cc: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/target/target_core_pr.c        |   34 +++++++++++++++++++++------------
+ drivers/target/target_core_transport.c |    1 
+ 2 files changed, 23 insertions(+), 12 deletions(-)
+
+--- a/drivers/target/target_core_pr.c
++++ b/drivers/target/target_core_pr.c
+@@ -120,7 +120,7 @@ static struct t10_pr_registration *core_
+                                       struct se_node_acl *, struct se_session *);
+ static void core_scsi3_put_pr_reg(struct t10_pr_registration *);
+-static int target_check_scsi2_reservation_conflict(struct se_cmd *cmd, int *ret)
++static int target_check_scsi2_reservation_conflict(struct se_cmd *cmd)
+ {
+       struct se_session *se_sess = cmd->se_sess;
+       struct se_subsystem_dev *su_dev = cmd->se_dev->se_sub_dev;
+@@ -130,7 +130,7 @@ static int target_check_scsi2_reservatio
+       int conflict = 0;
+       if (!crh)
+-              return false;
++              return -EINVAL;
+       pr_reg = core_scsi3_locate_pr_reg(cmd->se_dev, se_sess->se_node_acl,
+                       se_sess);
+@@ -158,16 +158,14 @@ static int target_check_scsi2_reservatio
+                */
+               if (pr_reg->pr_res_holder) {
+                       core_scsi3_put_pr_reg(pr_reg);
+-                      *ret = 0;
+-                      return false;
++                      return 1;
+               }
+               if ((pr_reg->pr_res_type == PR_TYPE_WRITE_EXCLUSIVE_REGONLY) ||
+                   (pr_reg->pr_res_type == PR_TYPE_EXCLUSIVE_ACCESS_REGONLY) ||
+                   (pr_reg->pr_res_type == PR_TYPE_WRITE_EXCLUSIVE_ALLREG) ||
+                   (pr_reg->pr_res_type == PR_TYPE_EXCLUSIVE_ACCESS_ALLREG)) {
+                       core_scsi3_put_pr_reg(pr_reg);
+-                      *ret = 0;
+-                      return true;
++                      return 1;
+               }
+               core_scsi3_put_pr_reg(pr_reg);
+               conflict = 1;
+@@ -192,10 +190,10 @@ static int target_check_scsi2_reservatio
+                       " while active SPC-3 registrations exist,"
+                       " returning RESERVATION_CONFLICT\n");
+               cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT;
+-              return true;
++              return -EBUSY;
+       }
+-      return false;
++      return 0;
+ }
+ int target_scsi2_reservation_release(struct se_task *task)
+@@ -204,12 +202,18 @@ int target_scsi2_reservation_release(str
+       struct se_device *dev = cmd->se_dev;
+       struct se_session *sess = cmd->se_sess;
+       struct se_portal_group *tpg = sess->se_tpg;
+-      int ret = 0;
++      int ret = 0, rc;
+       if (!sess || !tpg)
+               goto out;
+-      if (target_check_scsi2_reservation_conflict(cmd, &ret))
++      rc = target_check_scsi2_reservation_conflict(cmd);
++      if (rc == 1)
+               goto out;
++      else if (rc < 0) {
++              cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT;
++              ret = -EINVAL;
++              goto out;
++      }
+       ret = 0;
+       spin_lock(&dev->dev_reservation_lock);
+@@ -246,7 +250,7 @@ int target_scsi2_reservation_reserve(str
+       struct se_device *dev = cmd->se_dev;
+       struct se_session *sess = cmd->se_sess;
+       struct se_portal_group *tpg = sess->se_tpg;
+-      int ret = 0;
++      int ret = 0, rc;
+       if ((cmd->t_task_cdb[1] & 0x01) &&
+           (cmd->t_task_cdb[1] & 0x02)) {
+@@ -262,8 +266,14 @@ int target_scsi2_reservation_reserve(str
+        */
+       if (!sess || !tpg)
+               goto out;
+-      if (target_check_scsi2_reservation_conflict(cmd, &ret))
++      rc = target_check_scsi2_reservation_conflict(cmd);
++      if (rc == 1)
+               goto out;
++      else if (rc < 0) {
++              cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT;
++              ret = -EINVAL;
++              goto out;
++      }
+       ret = 0;
+       spin_lock(&dev->dev_reservation_lock);
+--- a/drivers/target/target_core_transport.c
++++ b/drivers/target/target_core_transport.c
+@@ -2507,6 +2507,7 @@ static int transport_generic_cmd_sequenc
+                                       cmd, cdb, pr_reg_type) != 0) {
+                       cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
+                       cmd->se_cmd_flags |= SCF_SCSI_RESERVATION_CONFLICT;
++                      cmd->scsi_status = SAM_STAT_RESERVATION_CONFLICT;
+                       cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT;
+                       return -EBUSY;
+               }