Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp172764imd; Wed, 31 Oct 2018 16:47:10 -0700 (PDT) X-Google-Smtp-Source: AJdET5eNmxcbgHRyFVX0cc4Qpm0P+wyqhYqj/4bMlLYfBSQKg09y1yUvbiOXH9og+tOWDGltVPEq X-Received: by 2002:a62:de84:: with SMTP id h126-v6mr5327634pfg.129.1541029630461; Wed, 31 Oct 2018 16:47:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541029630; cv=none; d=google.com; s=arc-20160816; b=CdCbllcanj+qEzBSf2k3fvmm+w36tAtmJ9J25zC+/FZ8HfG/2HMmlP558b3sqQ0jcF B7Of4SvYtEhwFe/zQgWtc/4AQ8lbBiRqVj+KAhVbNysJskq6mda26n4tfbXh2tA6gymB L+heHAZz8DJ1mKSyna6DvpJuzrExSJdGsmKywnHpz+7oLZ40WkB3aYpgC/RhtlakHj3R qEXJ06oSEkU5TAEeI1xl6KBfo9exRYdN+k/dgKNu9dNet0LUfG87VhZfzdzaYmg4uQWJ 4GCfWFzEQ/i3Uya4Bui4RncMBtQC1rDuKAHWE599P2Pje9nKQqJkWu2BuwUCGWMHpugl IiHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=UWGf6WmcOJvbrXWJOdInUAzFxCCfNJAkXHgSKgo5mc0=; b=j4OPeJeZfoxvztKY/KFAKagEE41pRQKWKRaYve0xM3lwTFujpz1BwO5RjYLziNdtIb nr0HEwWlBMJZWYaLoYSN/H77uhIAsfgBCWP/elGUfNwN+t93mgJ6nrZia+7VF0StqS1q 8xRDo+hMh9enEAWn52TmwJeL0A8Yg26lq9T23zOy7ophPw1qk5qE6i2cudFIaZUAJsVl tId680mag7Bk5d/8tmToWIEX9f8KNhYvErrRkcj5G27deQIj7B0d22MuiqJpRhSDF4W4 DRQVpQe8mqnI4BeVgXNFtT+p+jvEBpgG+RSP9lac5g9w8dkl5D9KQ0Q2tfE4OypoIcda xbnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OKWs37k1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bj11-v6si21248065plb.181.2018.10.31.16.46.55; Wed, 31 Oct 2018 16:47:10 -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; dkim=pass header.i=@kernel.org header.s=default header.b=OKWs37k1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728723AbeKAIHS (ORCPT + 99 others); Thu, 1 Nov 2018 04:07:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:54918 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728704AbeKAIHQ (ORCPT ); Thu, 1 Nov 2018 04:07:16 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8F2E820848; Wed, 31 Oct 2018 23:07:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027226; bh=34y4eytW8REGCP0YpMIKjpVLx2aLXV0OepI83a3odA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OKWs37k1Njr8U2OYjmbUB/mJDHBACB8M+V6YcdRCPBy1yvEqqaYK6EfmhJ8g9OGjC CE2XObdYT5dzU/Rhawk1fAxcCerVc1UHxBQUiiaZVNbXr9c7YjY/rFnASUKve1Ikw1 NkftIqwklzcO2i3sWT+ORoqz3+q4z6rL2De/9LFU= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Finn Thain , "Martin K . Petersen" , Sasha Levin Subject: [PATCH AUTOSEL 4.19 092/146] scsi: esp_scsi: Track residual for PIO transfers Date: Wed, 31 Oct 2018 19:04:47 -0400 Message-Id: <20181031230541.28822-92-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/scsi/esp_scsi.c | 1 + drivers/scsi/esp_scsi.h | 2 ++ drivers/scsi/mac_esp.c | 2 ++ 3 files changed, 5 insertions(+) diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c index c3fc34b9964d..9e5d3f7d29ae 100644 --- a/drivers/scsi/esp_scsi.c +++ b/drivers/scsi/esp_scsi.c @@ -1338,6 +1338,7 @@ static int esp_data_bytes_sent(struct esp *esp, struct esp_cmd_entry *ent, bytes_sent = esp->data_dma_len; bytes_sent -= ecount; + bytes_sent -= esp->send_cmd_residual; /* * The am53c974 has a DMA 'pecularity'. The doc states: diff --git a/drivers/scsi/esp_scsi.h b/drivers/scsi/esp_scsi.h index 8163dca2071b..a77772777a30 100644 --- 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 diff --git a/drivers/scsi/mac_esp.c b/drivers/scsi/mac_esp.c index eb551f3cc471..71879f2207e0 100644 --- a/drivers/scsi/mac_esp.c +++ b/drivers/scsi/mac_esp.c @@ -427,6 +427,8 @@ static void mac_esp_send_pio_cmd(struct esp *esp, u32 addr, u32 esp_count, scsi_esp_cmd(esp, ESP_CMD_TI); } } + + esp->send_cmd_residual = esp_count; } static int mac_esp_irq_pending(struct esp *esp) -- 2.17.1