Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3922048ybi; Mon, 10 Jun 2019 20:29:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqybVs/yD/cSfahSRVq8s960h4kB5HGdl1BwtaqY0V1p+S69qvotemOKjq+Jc9/QzaVllNoG X-Received: by 2002:a63:a36f:: with SMTP id v47mr15876388pgn.117.1560223799148; Mon, 10 Jun 2019 20:29:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560223799; cv=none; d=google.com; s=arc-20160816; b=FqS135GwMpxoM7Iu7pCPT8HJ0LQAeWoecXtE0TypbVRY8JQM2uzbIRgJPLc781f3m9 pGLbxi4F2Jz7FBE0w+9SPkvpdUEOC1A7mfuJPRl87Ki6GXr0L+BobpnP3YXhQxnkoFKg m3c75lmGZD/RQqo1mhsi9glSlvp2dj6ZD7zQrs/m2eLYfyUZqdzEMft77Eji1IpkPAre prRgwuETvXu90SUuAzfBLXW7Z625HcRi3Oqj6dttcJhDRM9I3j1I0bOXrRTYg+Vnsx2Q DXIybe7xkUBuPhHneJtaGjsw2JRQGxG7UEKqdL82Hz5dCQPJpkagqRo/Ni3r0eAqQXYw HFmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:from:message-id:cc:to; bh=j6u/oR1qv9AfhN0NECRBZhqInQ3w6jg3m/8w4sACzzY=; b=jrUiCtBR35CPc85qDVS/kguov564KD654aNfsW8gDBKVpo4vAKADyeCF4Pum0fNuIc yljlw8ZzrtjsmR2VgP60KFnSRCs3fDYskgHLxcx3y6h1+TLfX1A5v0YDh7afN0r/B0K7 8r+0CF9yHfeZR2UKbuR2eDWnB61e/ZgYKieScwd7Qhw2A5bmUBomhZ9fHLpZASPSXQVb 85azHOtJFA4J3uxDb96frTKtYYAr8l/+OoQfgEaKTaJGFAx6rUz6ZJiUFt1XPtxra783 NChr04vROaKlvHbNUg2qkMvmTLqKSmwcPhLxDq/lE5eqElj3I+bz8ZbjpstEuGY1Z1+B mjzg== 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 r200si5826086pfc.281.2019.06.10.20.29.42; Mon, 10 Jun 2019 20:29:59 -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 S2390985AbfFKD12 (ORCPT + 99 others); Mon, 10 Jun 2019 23:27:28 -0400 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:60900 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390856AbfFKD12 (ORCPT ); Mon, 10 Jun 2019 23:27:28 -0400 Received: by kvm5.telegraphics.com.au (Postfix, from userid 502) id 7094822994; Mon, 10 Jun 2019 23:27:27 -0400 (EDT) To: "James E.J. Bottomley" , "Martin K. Petersen" Cc: "Michael Schmitz" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Message-Id: <739c214bafcb9af3f6d5037cc03f57f692966675.1560223509.git.fthain@telegraphics.com.au> From: Finn Thain Subject: [PATCH] NCR5380: Support chained sg lists Date: Tue, 11 Jun 2019 13:25:09 +1000 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org My understanding is that support for chained scatterlists is to become mandatory for LLDs. Cc: Michael Schmitz Signed-off-by: Finn Thain --- drivers/scsi/NCR5380.c | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c index d9fa9cf2fd8b..536426f25e86 100644 --- a/drivers/scsi/NCR5380.c +++ b/drivers/scsi/NCR5380.c @@ -149,12 +149,10 @@ static inline void initialize_SCp(struct scsi_cmnd *cmd) if (scsi_bufflen(cmd)) { cmd->SCp.buffer = scsi_sglist(cmd); - cmd->SCp.buffers_residual = scsi_sg_count(cmd) - 1; cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); cmd->SCp.this_residual = cmd->SCp.buffer->length; } else { cmd->SCp.buffer = NULL; - cmd->SCp.buffers_residual = 0; cmd->SCp.ptr = NULL; cmd->SCp.this_residual = 0; } @@ -163,6 +161,17 @@ static inline void initialize_SCp(struct scsi_cmnd *cmd) cmd->SCp.Message = 0; } +static inline void advance_sg_buffer(struct scsi_cmnd *cmd) +{ + struct scatterlist *s = cmd->SCp.buffer; + + if (!cmd->SCp.this_residual && s && !sg_is_last(s)) { + cmd->SCp.buffer = sg_next(s); + cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); + cmd->SCp.this_residual = cmd->SCp.buffer->length; + } +} + /** * NCR5380_poll_politely2 - wait for two chip register values * @hostdata: host private data @@ -1670,12 +1679,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) sun3_dma_setup_done != cmd) { int count; - if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) { - ++cmd->SCp.buffer; - --cmd->SCp.buffers_residual; - cmd->SCp.this_residual = cmd->SCp.buffer->length; - cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); - } + advance_sg_buffer(cmd); count = sun3scsi_dma_xfer_len(hostdata, cmd); @@ -1725,15 +1729,11 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) * scatter-gather list, move onto the next one. */ - if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) { - ++cmd->SCp.buffer; - --cmd->SCp.buffers_residual; - cmd->SCp.this_residual = cmd->SCp.buffer->length; - cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); - dsprintk(NDEBUG_INFORMATION, instance, "%d bytes and %d buffers left\n", - cmd->SCp.this_residual, - cmd->SCp.buffers_residual); - } + advance_sg_buffer(cmd); + dsprintk(NDEBUG_INFORMATION, instance, + "this residual %d, sg ents %d\n", + cmd->SCp.this_residual, + sg_nents(cmd->SCp.buffer)); /* * The preferred transfer method is going to be @@ -2126,12 +2126,7 @@ static void NCR5380_reselect(struct Scsi_Host *instance) if (sun3_dma_setup_done != tmp) { int count; - if (!tmp->SCp.this_residual && tmp->SCp.buffers_residual) { - ++tmp->SCp.buffer; - --tmp->SCp.buffers_residual; - tmp->SCp.this_residual = tmp->SCp.buffer->length; - tmp->SCp.ptr = sg_virt(tmp->SCp.buffer); - } + advance_sg_buffer(tmp); count = sun3scsi_dma_xfer_len(hostdata, tmp); -- 2.21.0