Received: by 10.213.65.68 with SMTP id h4csp242975imn; Fri, 23 Mar 2018 03:45:22 -0700 (PDT) X-Google-Smtp-Source: AG47ELuuODkoKwTAgQexJDtz2eDTMeLCusycMxw8qhFp69vCUhuohEB8FOOnx9cVt7BntYQgynjM X-Received: by 2002:a17:902:aa83:: with SMTP id d3-v6mr28429270plr.36.1521801922633; Fri, 23 Mar 2018 03:45:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521801922; cv=none; d=google.com; s=arc-20160816; b=XbHg41zqItOTRQycyNURtrGBLcrIiEZ62kZKUlonlnzR0ZXNESMMtGabvnHH/pw0MN cSu6BPwyMEX3P4Bka7/xhT03NwvM8R/sc5vZosMw/pQ7gv+Nz8Lufx9FbgNBYco5mmcY PCZtN//3+u7YYBOmiNvcPJdcCpFemhiNWNXIJqHUpCJecGErva0Mjco2b7dwbvuEEnIv gjX1BaiDEA/aX8a9HDRyLMQhaMhajOj6jmOkXKF7k5q2Z+wKaTHDeJuxXDQzXwyMWUfk 5N67lcfZ46q3HIYlJfPqDymBDXqzGK+vLMVXRahKgzxN/WPqB5vmnYZETmgKvMw+ZQRS IDYA== 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=mHh2LeJ9gzgieMaMcD2Q7u3NdJk/6vHe0j42BCQuawY=; b=nRBMpIT51KRt2U1s/U+1tJ3Gn/iA3zO2bUM/XBxLDoVs6kt5LfnuBe0ZSW6I0L/Wqx zjjxekugQCIghcqZahCLLI618CvNy+2rEY1A2A2AuHAPcjWDaPSgygTjiQDmFBtO0GNL p660ErpyPSCMwkqURAaN5TIkImNSdIH3CrpdraOy9vPUAaG2QK9ZopjRmtEj+DqVJhc6 ydk0El9XXysxGWhsx0GbRq2y6QCwcKemIacQzLAaboZBXgU9Eea4daFSi6ezQhdjJwOs us1V0PzN+MSLrQsVX+jE4unW96jITWtaKKmzmmlJijVE/MYkb8fKthg7GYnoYZJwcZ30 DH1A== 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 p20-v6si8085939plo.643.2018.03.23.03.45.07; Fri, 23 Mar 2018 03:45:22 -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 S933551AbeCWKPx (ORCPT + 99 others); Fri, 23 Mar 2018 06:15:53 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46434 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933234AbeCWKPs (ORCPT ); Fri, 23 Mar 2018 06:15:48 -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 E3C7BD01; Fri, 23 Mar 2018 10:15:45 +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.4 52/97] mtip32xx: use runtime tag to initialize command header Date: Fri, 23 Mar 2018 10:54:39 +0100 Message-Id: <20180323094200.569562172@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094157.535925724@linuxfoundation.org> References: <20180323094157.535925724@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.4-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); } @@ -3818,6 +3840,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; @@ -3849,7 +3873,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 @@ -3866,17 +3889,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; }