Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4206488ybi; Tue, 11 Jun 2019 02:47:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMGJfDm3oxd0QxV/4HChwAKz9K3BmHmuxmKnatj4fXjuofg+h+TIEnbwhrJFK5K//flAxx X-Received: by 2002:a17:902:1e9:: with SMTP id b96mr28520932plb.277.1560246434169; Tue, 11 Jun 2019 02:47:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560246434; cv=none; d=google.com; s=arc-20160816; b=amPd66BRAM0TXIBxeUSD6/5btuzMzOKN2jmpk0JoVMq2NXq9FFs3c29qsQwZ4lvbaA lR6EwKVlgp42GTjFkmQNOzME03lCzSCF6MWeIZipwVpdPLhHcOsgpeFrrHurdFI2HPZc Zwue1uFrZ6YuIL+9ESwxNRMnuqLSNPjl1GUwxc8wj7ovhvyh1+M92aQTftAjx6ZryCH2 2FXst1O7mtplCh6WffjBmb2pK0JpXvxBdNZbYiRed7Sqfv2BVsNCIZ+JENyxatj2vGT8 Oyziodmzw3CuberNPVI5Od+V4XMffCbJUR9mqfJlTylKZwzVHIwltG9jOq8t03+VgVgk jQAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:message-id :in-reply-to:subject:cc:to:from:date; bh=x72IkuwCEImIg0AjYSBsA5pOp3rCE4zcOXNt9kNPWxw=; b=n1UD3/jqaJOXAbRzoEEBQ534+EK5uEkdlR529m8Eu90AwjEGxPlmoz0JYPbydPah4e MobevP9txFQ33FW1PCF+ScFEsj2p0mNSka4nK8TH08bg3gVi8e9nPfyUcExF+vWF/twK cPCDnA6cGlnO4Kaj1FO3fr065m4f0QbEQnjZiQvZc9tXS1XFRSoDK4Fg2jQEmGEm7OGA GnuL2g2UEOBrdExiYE+lST9TdhmtvQEtlj4dtaKncI4/V7DX9pubrZdJ5WduxenGoau4 LJqcGsYLNVanYYho/HayLCoOXOnu71mPf7BbPHq5vj/PyJfHNQ0G8Fz534FTsjmDPkUh qgwA== 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 s7si4947820plq.246.2019.06.11.02.46.26; Tue, 11 Jun 2019 02:47:14 -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 S2404770AbfFKJTe (ORCPT + 99 others); Tue, 11 Jun 2019 05:19:34 -0400 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:35556 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404428AbfFKJTe (ORCPT ); Tue, 11 Jun 2019 05:19:34 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by kvm5.telegraphics.com.au (Postfix) with ESMTP id 263822952E; Tue, 11 Jun 2019 05:19:30 -0400 (EDT) Date: Tue, 11 Jun 2019 19:19:10 +1000 (AEST) From: Finn Thain To: Michael Schmitz cc: "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] NCR5380: Support chained sg lists In-Reply-To: Message-ID: References: <739c214bafcb9af3f6d5037cc03f57f692966675.1560223509.git.fthain@telegraphics.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 11 Jun 2019, Michael Schmitz wrote: > Hi Finn, > > Thanks - can't test this on my hardware but looks good to me. > Thanks for looking it over. Would you be willing to send a "reviewed-by" tag? I tested this successfully on my PowerBook 180 using the parameters mac_scsi.setup_sg_tablesize=128 mac_scsi.setup_use_pdma=0 (Only because PDMA doesn't work with sg_tablesize > 1 with this particular drive.) -- > Cheers, > > Michael > > Am 11.06.2019 um 15:25 schrieb Finn Thain: > > 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); > > > > >