]>
Commit | Line | Data |
---|---|---|
722b7c48 GKH |
1 | From foo@baz Sat Jul 28 10:14:31 CEST 2018 |
2 | From: "Matthew R. Ochs" <mrochs@linux.vnet.ibm.com> | |
3 | Date: Mon, 26 Mar 2018 11:30:22 -0500 | |
4 | Subject: scsi: cxlflash: Avoid clobbering context control register value | |
5 | ||
6 | From: "Matthew R. Ochs" <mrochs@linux.vnet.ibm.com> | |
7 | ||
8 | [ Upstream commit 465891fe9237b02f8d0fd26448f733fae7236f4a ] | |
9 | ||
10 | The SISLite specification originally defined the context control register with | |
11 | a single field of bits to represent the LISN and also stipulated that the | |
12 | register reset value be 0. The cxlflash driver took advantage of this when | |
13 | programming the LISN for the master contexts via an unconditional write - no | |
14 | other bits were preserved. | |
15 | ||
16 | When unmap support was added, SISLite was updated to define bit 0 of the | |
17 | context control register as a way for the AFU to notify the context owner that | |
18 | unmap operations were supported. Thus the assumptions under which the register | |
19 | is setup changed and the existing unconditional write is clobbering the unmap | |
20 | state for master contexts. This is presently not an issue due to the order in | |
21 | which the context control register is programmed in relation to the unmap bit | |
22 | being queried but should be addressed to avoid a future regression in the | |
23 | event this code is moved elsewhere. | |
24 | ||
25 | To remedy this issue, preserve the bits when programming the LISN field in the | |
26 | context control register. Since the LISN will now be programmed using a read | |
27 | value, assert that the initial state of the LISN field is as described in | |
28 | SISLite (0). | |
29 | ||
30 | Signed-off-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com> | |
31 | Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com> | |
32 | Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> | |
33 | Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> | |
34 | Signed-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 */ |