Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3436601imu; Sun, 11 Nov 2018 15:04:22 -0800 (PST) X-Google-Smtp-Source: AJdET5deUUnMGwQ6nhqDoVi8mUoB+IXGqNdCCCk26kw2gXpaYdkBJ+vL5yA0qch7K/jQafrzZtgL X-Received: by 2002:a63:6c4a:: with SMTP id h71-v6mr15381031pgc.326.1541977462907; Sun, 11 Nov 2018 15:04:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541977462; cv=none; d=google.com; s=arc-20160816; b=M9o8YZ78cGbuq/hhn7PRBq+Z85eOpAm4EQ/+g5utRhYW0PY3cxumYldB+brzS3kBf6 XSxcApPpsYorY67jZIVlCvlag501cTmjS6Tn7mIkYOlxKXcxm26Wr38eAhxXkevSLxMt m84gD/F0UbNvSRUXhAhgX9HajKU0cqkiBU2dqnkIcRu4nvGyy435B0LV4/3zpXYsqR5m G8SYOcSXlY+YghpDNOdDx3NWqYkDIVAR0Pm+VjWZcha/RdglIaWaG1qvYnK3GiHdK4ID aCGSgEWBdm2ZKBVx7FSMjCmjMc7a9QeSpAacZTs5GgQdEFBRSvIPaceqM3aeUSFoCgEy eAFw== 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=2FvvFtZbF5oaCg4DWTflRfB+NKDTfvfKNDB8y/TkZdo=; b=u1Xx8B/x9qL7etzJF7eFRLlxA+7oSSkvU3RRrRwQCYPCi9MsGTFMDcndLSKWueJznf UJZCbudjTCLfWI3ts5TPg8kYVSDJ7eJtSWhXsYpCeOG0Av6wTL+rD9MY01C8vp/lYgwK QB26d2SQo89dtPpW7qyDzJnffrw047U2G7Op1kOHLpm6+030Elo5TYxiJf2AR96H1pId GWoCeXQPXlj+7owCY1gMCq/5I1Mqf61pYyFP/Ma92u29GONny7dmlGAnqRtcx+b0pak7 EoxW+qPnPKTjSPd6jb+LVINoiDaIJqrdH2YYpbB2yZQpwXx5zzdIgTbh2z6Wq734ZONh AlOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=q8eHf1YF; 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 206si14178881pga.240.2018.11.11.15.04.07; Sun, 11 Nov 2018 15:04:22 -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=q8eHf1YF; 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 S2390551AbeKLIWX (ORCPT + 99 others); Mon, 12 Nov 2018 03:22:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:51836 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389302AbeKLIWW (ORCPT ); Mon, 12 Nov 2018 03:22:22 -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 7B8C02175B; Sun, 11 Nov 2018 22:32:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975545; bh=WPz9YpiPHxdSF32zLQl2/oNGLV9c8X/wVO+Yu3pOR70=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q8eHf1YFZBvqCI5oXf866YUyEFDKl+L46kepmzaXQMum6RlNtXB7vepQFcnUwpCPO tjskiERMU3iTh6wiQSF0YlruqcJ7WynO16ugVrMoptFuDCS3IALRlPCwVgeeOlCoiY JvHErlDA46V7H/rtURv9rmhs1U2V4liUs9l4jw8Q= 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.14 077/222] scsi: esp_scsi: Track residual for PIO transfers Date: Sun, 11 Nov 2018 14:22:54 -0800 Message-Id: <20181111221654.972056004@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221647.665769131@linuxfoundation.org> References: <20181111221647.665769131@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.14-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)