Received: by 10.213.65.68 with SMTP id h4csp271158imn; Fri, 23 Mar 2018 04:24:51 -0700 (PDT) X-Google-Smtp-Source: AG47ELs1Z4L4UhI6tIicOxB1BPD6zyuVTAhJp4zDeQn6Im1oWLQ+4k67QQIvibEsso/5raDGj+KK X-Received: by 2002:a17:902:309:: with SMTP id 9-v6mr29636373pld.63.1521804291294; Fri, 23 Mar 2018 04:24:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521804291; cv=none; d=google.com; s=arc-20160816; b=PS5I/VYndRSfFiZssOL9TuA3lqZ5oiiovnMrUZNWBevcXyimnEasxewYA9lcma4wWX cgQtQqI6AvQOzbvOHQUot0ZTMCuVF5ukZnP9Co6SNLykTFMrUtNddp3Cvs14gRGqsy+I 5PT9Zy2PMUGTwbIgb445usJd9LOMrhsD+XH/R64mEiTjq8swWkZaujljNuIK0O1ygp6t PGNoFWtbCycE9cHjZDL8eWbxInZbJ+uACk6qVfLtqBm/4fNIBOMpmcHkxofy0RaJhpf3 +NECgRHu7fkTAeWifP3RPRZitEcALesgFPXzMD3diDI7wh8Hmw8KtM9u0uGnYh9u2VyM /itg== 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=6/NbvEXgfHtIJGUSqHRit+P1XknySUgUNCOXrtMnyHQ=; b=Vk0A8o5qeotPc7aPRmyGEtpaMkxa1hkfEsgQr7VmJnW4THsQOIMWC9OpRJ1yyRxOIa E4Bzu+gGzCjLIeRfUUc5MUxuuiuGCD37It/yP+yaUkwjxXWJTBeVe6lI6lBuAEsRE/n0 z3FEq0+ISnWYNkyYRbrBxKN6IlwwcTdnwkkolOcqPWbzyz0cC/T5ioVB8+n2/XCr/jzS suYR2KR8x7LpN2Xeyrb3m+Kd63bpuxP5hUNR6Lc6go/ziegFvwP02hXP10PJZLXOdwaO 3joJdhK495yHTdNBxFuwtg3+UHzASU2eDmsO/wHHzmCsBTRKO/AUpOBFULYvAHfqTRoB o4Ag== 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 h2-v6si8128793plr.1.2018.03.23.04.24.36; Fri, 23 Mar 2018 04:24:51 -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 S1755418AbeCWKH4 (ORCPT + 99 others); Fri, 23 Mar 2018 06:07:56 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:41412 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755403AbeCWKHx (ORCPT ); Fri, 23 Mar 2018 06:07:53 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 55796907; Fri, 23 Mar 2018 10:07:52 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ming Lei , Jens Axboe , Sasha Levin Subject: [PATCH 4.9 085/177] mtip32xx: use runtime tag to initialize command header Date: Fri, 23 Mar 2018 10:53:33 +0100 Message-Id: <20180323094209.046257243@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094205.090519271@linuxfoundation.org> References: <20180323094205.090519271@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.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ming Lei [ Upstream commit a4e84aae8139aca9fbfbced1f45c51ca81b57488 ] mtip32xx supposes that 'request_idx' passed to .init_request() is tag of the request, and use that as request's tag to initialize command header. After MQ IO scheduler is in, request tag assigned isn't same with the request index anymore, so cause strange hardware failure on mtip32xx, even whole system panic is triggered. This patch fixes the issue by initializing command header via request's real tag. Signed-off-by: Ming Lei Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/block/mtip32xx/mtip32xx.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) --- a/drivers/block/mtip32xx/mtip32xx.c +++ b/drivers/block/mtip32xx/mtip32xx.c @@ -169,6 +169,25 @@ static bool mtip_check_surprise_removal( return false; /* device present */ } +/* we have to use runtime tag to setup command header */ +static void mtip_init_cmd_header(struct request *rq) +{ + struct driver_data *dd = rq->q->queuedata; + struct mtip_cmd *cmd = blk_mq_rq_to_pdu(rq); + u32 host_cap_64 = readl(dd->mmio + HOST_CAP) & HOST_CAP_64; + + /* Point the command headers at the command tables. */ + cmd->command_header = dd->port->command_list + + (sizeof(struct mtip_cmd_hdr) * rq->tag); + cmd->command_header_dma = dd->port->command_list_dma + + (sizeof(struct mtip_cmd_hdr) * rq->tag); + + if (host_cap_64) + cmd->command_header->ctbau = __force_bit2int cpu_to_le32((cmd->command_dma >> 16) >> 16); + + cmd->command_header->ctba = __force_bit2int cpu_to_le32(cmd->command_dma & 0xFFFFFFFF); +} + static struct mtip_cmd *mtip_get_int_command(struct driver_data *dd) { struct request *rq; @@ -180,6 +199,9 @@ static struct mtip_cmd *mtip_get_int_com if (IS_ERR(rq)) return NULL; + /* Internal cmd isn't submitted via .queue_rq */ + mtip_init_cmd_header(rq); + return blk_mq_rq_to_pdu(rq); } @@ -3811,6 +3833,8 @@ static int mtip_queue_rq(struct blk_mq_h struct request *rq = bd->rq; int ret; + mtip_init_cmd_header(rq); + if (unlikely(mtip_check_unal_depth(hctx, rq))) return BLK_MQ_RQ_QUEUE_BUSY; @@ -3842,7 +3866,6 @@ static int mtip_init_cmd(void *data, str { struct driver_data *dd = data; struct mtip_cmd *cmd = blk_mq_rq_to_pdu(rq); - u32 host_cap_64 = readl(dd->mmio + HOST_CAP) & HOST_CAP_64; /* * For flush requests, request_idx starts at the end of the @@ -3859,17 +3882,6 @@ static int mtip_init_cmd(void *data, str memset(cmd->command, 0, CMD_DMA_ALLOC_SZ); - /* Point the command headers at the command tables. */ - cmd->command_header = dd->port->command_list + - (sizeof(struct mtip_cmd_hdr) * request_idx); - cmd->command_header_dma = dd->port->command_list_dma + - (sizeof(struct mtip_cmd_hdr) * request_idx); - - if (host_cap_64) - cmd->command_header->ctbau = __force_bit2int cpu_to_le32((cmd->command_dma >> 16) >> 16); - - cmd->command_header->ctba = __force_bit2int cpu_to_le32(cmd->command_dma & 0xFFFFFFFF); - sg_init_table(cmd->sg, MTIP_MAX_SG); return 0; }