]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.17.12/scsi-cxlflash-avoid-clobbering-context-control-register-value.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.17.12 / scsi-cxlflash-avoid-clobbering-context-control-register-value.patch
CommitLineData
722b7c48
GKH
1From foo@baz Sat Jul 28 10:14:31 CEST 2018
2From: "Matthew R. Ochs" <mrochs@linux.vnet.ibm.com>
3Date: Mon, 26 Mar 2018 11:30:22 -0500
4Subject: scsi: cxlflash: Avoid clobbering context control register value
5
6From: "Matthew R. Ochs" <mrochs@linux.vnet.ibm.com>
7
8[ Upstream commit 465891fe9237b02f8d0fd26448f733fae7236f4a ]
9
10The SISLite specification originally defined the context control register with
11a single field of bits to represent the LISN and also stipulated that the
12register reset value be 0. The cxlflash driver took advantage of this when
13programming the LISN for the master contexts via an unconditional write - no
14other bits were preserved.
15
16When unmap support was added, SISLite was updated to define bit 0 of the
17context control register as a way for the AFU to notify the context owner that
18unmap operations were supported. Thus the assumptions under which the register
19is setup changed and the existing unconditional write is clobbering the unmap
20state for master contexts. This is presently not an issue due to the order in
21which the context control register is programmed in relation to the unmap bit
22being queried but should be addressed to avoid a future regression in the
23event this code is moved elsewhere.
24
25To remedy this issue, preserve the bits when programming the LISN field in the
26context control register. Since the LISN will now be programmed using a read
27value, assert that the initial state of the LISN field is as described in
28SISLite (0).
29
30Signed-off-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
31Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
32Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
33Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
34Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
35---
36 drivers/scsi/cxlflash/main.c | 5 ++++-
37 drivers/scsi/cxlflash/sislite.h | 1 +
38 2 files changed, 5 insertions(+), 1 deletion(-)
39
40--- a/drivers/scsi/cxlflash/main.c
41+++ b/drivers/scsi/cxlflash/main.c
42@@ -1303,7 +1303,10 @@ static void afu_err_intr_init(struct afu
43 for (i = 0; i < afu->num_hwqs; i++) {
44 hwq = get_hwq(afu, i);
45
46- writeq_be(SISL_MSI_SYNC_ERROR, &hwq->host_map->ctx_ctrl);
47+ reg = readq_be(&hwq->host_map->ctx_ctrl);
48+ WARN_ON((reg & SISL_CTX_CTRL_LISN_MASK) != 0);
49+ reg |= SISL_MSI_SYNC_ERROR;
50+ writeq_be(reg, &hwq->host_map->ctx_ctrl);
51 writeq_be(SISL_ISTATUS_MASK, &hwq->host_map->intr_mask);
52 }
53 }
54--- a/drivers/scsi/cxlflash/sislite.h
55+++ b/drivers/scsi/cxlflash/sislite.h
56@@ -284,6 +284,7 @@ struct sisl_host_map {
57 __be64 cmd_room;
58 __be64 ctx_ctrl; /* least significant byte or b56:63 is LISN# */
59 #define SISL_CTX_CTRL_UNMAP_SECTOR 0x8000000000000000ULL /* b0 */
60+#define SISL_CTX_CTRL_LISN_MASK (0xFFULL)
61 __be64 mbox_w; /* restricted use */
62 __be64 sq_start; /* Submission Queue (R/W): write sequence and */
63 __be64 sq_end; /* inclusion semantics are the same as RRQ */