Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3483537imu; Sun, 11 Nov 2018 16:08:03 -0800 (PST) X-Google-Smtp-Source: AJdET5c4LwAl/Fm32W1aY+dvZhxTjnq/u0NyDhAKK/TFJJ3pFTR/YyZ/rVX0kE+7qnwOi6DelJEK X-Received: by 2002:a65:6542:: with SMTP id a2mr15410038pgw.389.1541981283589; Sun, 11 Nov 2018 16:08:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541981283; cv=none; d=google.com; s=arc-20160816; b=nPeMJeoEZZZrbKk4A1t4mJISY6upMAIgcqiKyZuZIsjmIbK37oMpwDzLzL/LUQSctT qfBHErnJtOlxf4PBrgC0hGz/Z6PkMvPwezjdGcxu0vExDkhW0ypdDXfrI03apBioTEsb 1RA1JznbKw+vjgzJWlieuLuR66SmsJz9YD5bU/LwCBt/bHKQYyOvnnY2oEwpXWWRneOO r9RB1t5Ugz72hMp9Pi2DX7EyqyrMtypPLKfIgB3ZStV7/Jlc6RSYsG2nNbd5hjNPmbod IJCcAHZekVlTaAscJkLDamp+/4KUatjyslL+vDWqJjL1po+qJEzLdOozAZWO8ShzteVU HpkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NQ9VCxAkmR6xX7+uwnO6DNKKjQ2CKeVYmRfnq1RJTIY=; b=B7SYt5Y4LuWkecwniR4UkrSHjKvpmY96oQNvWISO5QWPRxWjOPDdemYVnDHeT9fKeu jfBc6xPxoWYJlO0ffrP7iN71k64/SgvSA5/+9X4BHXMq7Rcy/CBkGM7IeueD0eub7ru1 BZzJLdzP08pv0v5GS3jIY9gzlowmIe2iWvtTWUS96WqiHrUCZ2ymLhzfIr7GgSQC351e e2ex50x6lfNxdymBMj7TZqTyMt2NSLiHDYB4cdxm7sv3TZ1LBPvti4t5R1ReA4L9Sro9 Y0r4UKrLhtugGyUT3U+R3rq/OYIRGcfJwGYQ1UA7Qi3Bl9jGzsX5CB/dHr622J6u2pHj ByWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bocisN7V; 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 u8-v6si14699877pgl.59.2018.11.11.16.07.48; Sun, 11 Nov 2018 16:08:03 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=bocisN7V; 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 S1732046AbeKLJ5s (ORCPT + 99 others); Mon, 12 Nov 2018 04:57:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:33864 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731707AbeKLIRg (ORCPT ); Mon, 12 Nov 2018 03:17:36 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 32ABA214DB; Sun, 11 Nov 2018 22:27:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975261; bh=BR2J8tkPwgagi2NbXSylo1P3SV6JupNZLebgAtefgVI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bocisN7V709ppoauZtaaKM7okNr9qOmtMnvi8an67sSD3D3nyc5IhdFFPhmBBueYi mNBcMYtqW+BLn9Riomk7NPw0tuDBmis/aC/WCCSMS9/T2z/Ml16PRjCdCRSduEkOx9 nWvY2eGEJOa2CcAqVVn2PAcCc5IFtVjanHZcPHc0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stan Johnson , Finn Thain , Michael Schmitz , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.19 137/361] scsi: esp_scsi: Track residual for PIO transfers Date: Sun, 11 Nov 2018 14:18:04 -0800 Message-Id: <20181111221639.662534268@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Finn Thain [ Upstream commit fd47d919d0c336e7c22862b51ee94927ffea227a ] If a target disconnects during a PIO data transfer the command may fail when the target reconnects: scsi host1: DMA length is zero! scsi host1: cur adr[04380000] len[00000000] The scsi bus is then reset. This happens because the residual reached zero before the transfer was completed. The usual residual calculation relies on the Transfer Count registers. That works for DMA transfers but not for PIO transfers. Fix the problem by storing the PIO transfer residual and using that to correctly calculate bytes_sent. Fixes: 6fe07aaffbf0 ("[SCSI] m68k: new mac_esp scsi driver") Tested-by: Stan Johnson Signed-off-by: Finn Thain Tested-by: Michael Schmitz Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/esp_scsi.c | 1 + drivers/scsi/esp_scsi.h | 2 ++ drivers/scsi/mac_esp.c | 2 ++ 3 files changed, 5 insertions(+) --- a/drivers/scsi/esp_scsi.c +++ b/drivers/scsi/esp_scsi.c @@ -1338,6 +1338,7 @@ static int esp_data_bytes_sent(struct es bytes_sent = esp->data_dma_len; bytes_sent -= ecount; + bytes_sent -= esp->send_cmd_residual; /* * The am53c974 has a DMA 'pecularity'. The doc states: --- a/drivers/scsi/esp_scsi.h +++ b/drivers/scsi/esp_scsi.h @@ -540,6 +540,8 @@ struct esp { void *dma; int dmarev; + + u32 send_cmd_residual; }; /* A front-end driver for the ESP chip should do the following in --- a/drivers/scsi/mac_esp.c +++ b/drivers/scsi/mac_esp.c @@ -427,6 +427,8 @@ static void mac_esp_send_pio_cmd(struct scsi_esp_cmd(esp, ESP_CMD_TI); } } + + esp->send_cmd_residual = esp_count; } static int mac_esp_irq_pending(struct esp *esp)