Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1113449imm; Wed, 1 Aug 2018 10:24:01 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdSvzlLXQyRoaPzZ8va8i69oMGEiuWbO3WlfwqtK4uBPx08TwZ3qdAwHFtNJWrprngGSqeH X-Received: by 2002:a65:5205:: with SMTP id o5-v6mr25422750pgp.108.1533144241177; Wed, 01 Aug 2018 10:24:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533144241; cv=none; d=google.com; s=arc-20160816; b=Dm38g6OXolLxOlj5EJya19r+R8tB9YWpbchd22ZeB+tJYlOlDlOa3Pn2MY9oyZgP24 KvIjp6leQvfYtPgmOsVwCEP7iz3y+VkoHM6ujLzRrInPlSr8q7Bh3x1QXKZ/o/IbmeOY NJc9DZudqtI+uvOMSVZ0gwwg1A/kRz2v119nfbzqVvJrmtTOR28krc0WuFpk0EWEd+AD Z3MY1pGfYhNCtvwMsKFEppDTgLsQjKwV7GVyTp9eW8OO+mHZkyn0Yctnfs0Da5r49Kst 8hBLxA/G0sjBLUGq6wb19RUg/CaA3+cE2Tc6OPAni863rak/G83OZjvReZMm03hPWlYT Y7Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=LX/e6LgC0KWbGeMbV/LB0NHcNbDv6CtUGT/NYlK1yNE=; b=KrTrM29pL/svFp2EHo+jvGvgCD2Bd1kbkOse3G+pU38e1T7bPRgpL+S8LqIoZ7htMV Jc6IHFDY0tRvMwAUm131CjvANhj9HxkI0IBV77B0BjCZnzi1jT699WjKSJCabSCpWYDa 83Yi6zwlz/iCI44jq2eYVUSP0+MmRaPE2rOm4LU5NrvnmNyL3BPsl0bSdMuz1p88zzAw /Q/1ZDe14qOczpYY9P+O1blPZLf0M/eQPj+0R8nmNCBZrp586KjrvZ2rrv68llwDS32d w4DoPYGOxnFPpbFiRghAFST4FhyGZJBPXJWXE3n5/vEeh0frhe8sSYa6UnyY8RoGAg2m 972A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e14-v6si16527488pgj.413.2018.08.01.10.23.46; Wed, 01 Aug 2018 10:24:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406184AbeHATIu (ORCPT + 99 others); Wed, 1 Aug 2018 15:08:50 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50630 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405036AbeHATIu (ORCPT ); Wed, 1 Aug 2018 15:08:50 -0400 Received: from localhost (D57E6652.static.ziggozakelijk.nl [213.126.102.82]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 336CBD27; Wed, 1 Aug 2018 17:22:08 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Matthew R. Ochs" , Uma Krishnan , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.14 207/246] scsi: cxlflash: Avoid clobbering context control register value Date: Wed, 1 Aug 2018 18:51:57 +0200 Message-Id: <20180801165021.615011170@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180801165011.700991984@linuxfoundation.org> References: <20180801165011.700991984@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: "Matthew R. Ochs" [ Upstream commit 465891fe9237b02f8d0fd26448f733fae7236f4a ] The SISLite specification originally defined the context control register with a single field of bits to represent the LISN and also stipulated that the register reset value be 0. The cxlflash driver took advantage of this when programming the LISN for the master contexts via an unconditional write - no other bits were preserved. When unmap support was added, SISLite was updated to define bit 0 of the context control register as a way for the AFU to notify the context owner that unmap operations were supported. Thus the assumptions under which the register is setup changed and the existing unconditional write is clobbering the unmap state for master contexts. This is presently not an issue due to the order in which the context control register is programmed in relation to the unmap bit being queried but should be addressed to avoid a future regression in the event this code is moved elsewhere. To remedy this issue, preserve the bits when programming the LISN field in the context control register. Since the LISN will now be programmed using a read value, assert that the initial state of the LISN field is as described in SISLite (0). Signed-off-by: Matthew R. Ochs Signed-off-by: Uma Krishnan Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/cxlflash/main.c | 5 ++++- drivers/scsi/cxlflash/sislite.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -1303,7 +1303,10 @@ static void afu_err_intr_init(struct afu for (i = 0; i < afu->num_hwqs; i++) { hwq = get_hwq(afu, i); - writeq_be(SISL_MSI_SYNC_ERROR, &hwq->host_map->ctx_ctrl); + reg = readq_be(&hwq->host_map->ctx_ctrl); + WARN_ON((reg & SISL_CTX_CTRL_LISN_MASK) != 0); + reg |= SISL_MSI_SYNC_ERROR; + writeq_be(reg, &hwq->host_map->ctx_ctrl); writeq_be(SISL_ISTATUS_MASK, &hwq->host_map->intr_mask); } } --- a/drivers/scsi/cxlflash/sislite.h +++ b/drivers/scsi/cxlflash/sislite.h @@ -284,6 +284,7 @@ struct sisl_host_map { __be64 cmd_room; __be64 ctx_ctrl; /* least significant byte or b56:63 is LISN# */ #define SISL_CTX_CTRL_UNMAP_SECTOR 0x8000000000000000ULL /* b0 */ +#define SISL_CTX_CTRL_LISN_MASK (0xFFULL) __be64 mbox_w; /* restricted use */ __be64 sq_start; /* Submission Queue (R/W): write sequence and */ __be64 sq_end; /* inclusion semantics are the same as RRQ */