From patchwork Sat Nov 16 03:36:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Finn Thain X-Patchwork-Id: 11247449 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4324014ED for ; Sat, 16 Nov 2019 03:47:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 243892073B for ; Sat, 16 Nov 2019 03:47:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727472AbfKPDrk (ORCPT ); Fri, 15 Nov 2019 22:47:40 -0500 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:35240 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727290AbfKPDrk (ORCPT ); Fri, 15 Nov 2019 22:47:40 -0500 Received: by kvm5.telegraphics.com.au (Postfix, from userid 502) id 749262A71A; Fri, 15 Nov 2019 22:47:39 -0500 (EST) To: "James E.J. Bottomley" , "Martin K. Petersen" Cc: "Michael Schmitz" , "Ondrej Zary" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Message-Id: <1f26ead9dd0dc053fcd27979d69a7ca74b6589b4.1573875417.git.fthain@telegraphics.com.au> From: Finn Thain Subject: [PATCH] NCR5380: Call scsi_set_resid() on command completion Date: Sat, 16 Nov 2019 14:36:57 +1100 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Most NCR5380 drivers calculate the residual for every data transfer. (A few drivers just set it to zero.) Pass this quantity back to the scsi mid-layer on command completion. Cc: Michael Schmitz Cc: Ondrej Zary Reviewed-and-tested-by: Michael Schmitz Tested-by: Ondrej Zary Signed-off-by: Finn Thain --- drivers/scsi/NCR5380.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c index d4401c768a0c..3ea2557e7938 100644 --- a/drivers/scsi/NCR5380.c +++ b/drivers/scsi/NCR5380.c @@ -175,6 +175,19 @@ static inline void advance_sg_buffer(struct scsi_cmnd *cmd) } } +static inline void set_resid_from_SCp(struct scsi_cmnd *cmd) +{ + int resid = cmd->SCp.this_residual; + struct scatterlist *s = cmd->SCp.buffer; + + if (s) + while (!sg_is_last(s)) { + s = sg_next(s); + resid += s->length; + } + scsi_set_resid(cmd, resid); +} + /** * NCR5380_poll_politely2 - wait for two chip register values * @hostdata: host private data @@ -1807,6 +1820,8 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) cmd->result |= cmd->SCp.Status; cmd->result |= cmd->SCp.Message << 8; + set_resid_from_SCp(cmd); + if (cmd->cmnd[0] == REQUEST_SENSE) complete_cmd(instance, cmd); else {