Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5321980ybi; Wed, 12 Jun 2019 00:10:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqyTU3rMyOTtzcmflFdjfRqoGG1/RyF+G9zA9Uu4Hv/ppWkijXeqpn6Cx8izUwIAdIHB8wnZ X-Received: by 2002:aa7:818b:: with SMTP id g11mr832910pfi.122.1560323457625; Wed, 12 Jun 2019 00:10:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560323457; cv=none; d=google.com; s=arc-20160816; b=nYR9p5KZkNl6bnNV7ko7aWJZFM9gENYvfsH+gXcJB6v8a0m8vfukwGFkw3c+Ua5dMd x9k33TYxhJKPqMP43tcgL6QWRzCpVX9nWKVhHIovvsWm3mSUY/neWT0UvWIGfyjKMLcs 91whoN58x4v2aMFpOF7ZKDboAD/0dKqKol0lHc7WfMWJf51FrqqbZIA/CO87UZTTECSU zwgbZjLiFjFY7wOOAhWc5+ecG3ixRZh1SCj9vkMWAEoEkR8vvX2lYfjoEaIgStPbGV6e PKBl1metKoY1ZZu+ISQmK+4c2tK5goSk6W2/V0pDBU6PdL7jWG492CAkkIaEscWx38Os kwtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=rQZeUVQ6RxiqAEW7WsFNWPKzRIxBC2e622V0NwiVfj8=; b=oxzVtLhIEJVN2Sf74sbF9/St2vj9C5Z2yP8jeNSS0fxLzPotV+Zc+xSpViCe4CKPij s4AsVxfNhiTSvGpMwjxPq4ZUhCbAzt1EAzDFhQXn9mW/ytBLV+EsirLcqfm/OUDERiwj r45uYrl7hAVtJotDPsBVhYrUe6cn/ahdjzQlMX9S0UZSzQWobN/U1LC7MIDRpUhjRDyY knxtCuSk2bJSc8CY/1bNP9GZHqvfaI7Z+0Z/4GUT43ir72SkSvvVShHT+M7hdGTZkF0g IFESAxPFbr8zfFzmo8okNwIe0mO2NIucRctRIiMoAw21+QI7mKobJE1HO/FN0MIjSXpK 8uqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JhOuZSIw; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v11si14585660plp.304.2019.06.12.00.10.38; Wed, 12 Jun 2019 00:10:57 -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=@gmail.com header.s=20161025 header.b=JhOuZSIw; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407141AbfFKXsH (ORCPT + 99 others); Tue, 11 Jun 2019 19:48:07 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:32826 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387864AbfFKXsG (ORCPT ); Tue, 11 Jun 2019 19:48:06 -0400 Received: by mail-pg1-f194.google.com with SMTP id k187so7338312pga.0; Tue, 11 Jun 2019 16:48:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=rQZeUVQ6RxiqAEW7WsFNWPKzRIxBC2e622V0NwiVfj8=; b=JhOuZSIwFe0oFF53PYSrxKAUzLnKxYXF3enN5K3WkjEWNf5o+aXe08SIYrulbIEm6p 2LnH4OE/iXxG8SSqIT3JTjm8mUhsly1+F2TM+80en7Tu27EufyPEku/INQgwkNsGLAS8 L52ox5SXXIWN35Cnv41YbI/v0AKFWXmBzgJIu9D4bvdd4jOc7fw0OAhj4maK9UhmXi6G xpbKcP4jF7f6eWuzyD4kbeoOPEOd/dMrgEryHTDwFtMrDGUhdPOCTIqzG239oezkIpPO +RS5ERit+Kc+g5b26QU+lM8DKzSFvWKdiW72LNu1ii7xoBHTrKVkJHTIq71j93XyHAEZ hV5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=rQZeUVQ6RxiqAEW7WsFNWPKzRIxBC2e622V0NwiVfj8=; b=KPMH2cBNrXPhr/gSnNq3CZ09wWA/LrAjOoXV2hbYb6uehGWvFugJaMYMILRUXOC9aj o+gkDEKE9d83ecXIwvA2ZO9/QHBhLpMPc30CpX4TZa94IOgQZnis/4noMpCK8TssT0oI Fv/cGYFWjOC8sOHVou76/tWK+joxJgEbau96Q9AB8hyWqfsZK1KxRKxIq5IS6SAaTs3o PEyr1UoCdlx71+B/cfxZCayDy8ckNuLCyZrDgirbBUNgtpnTfS5TjNyOCjohT+XqnujI haCVtSsFsZGN4nVK21R/LquLdYYe2YCNeyTcCC72F8AOB5LYyXX86FCkvFXGtZHe6TOn eyhw== X-Gm-Message-State: APjAAAWp7CYKtBucQBMLP6q9HM7nZfkzvIJJUDDdNC+Ffq0WHRLCM+ut FueOdU0uLlSI/oU7vew3HnNrDbjq X-Received: by 2002:a63:e250:: with SMTP id y16mr21858926pgj.392.1560296886103; Tue, 11 Jun 2019 16:48:06 -0700 (PDT) Received: from ?IPv6:2001:df0:0:200c:cd5b:7c57:228c:7f0a? ([2001:df0:0:200c:cd5b:7c57:228c:7f0a]) by smtp.gmail.com with ESMTPSA id i3sm15448121pfa.175.2019.06.11.16.47.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Jun 2019 16:48:05 -0700 (PDT) Subject: Re: [PATCH] NCR5380: Support chained sg lists To: Finn Thain , "James E.J. Bottomley" , "Martin K. Petersen" Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org References: <739c214bafcb9af3f6d5037cc03f57f692966675.1560223509.git.fthain@telegraphics.com.au> From: Michael Schmitz Message-ID: Date: Wed, 12 Jun 2019 11:47:56 +1200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <739c214bafcb9af3f6d5037cc03f57f692966675.1560223509.git.fthain@telegraphics.com.au> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/06/19 3:25 PM, Finn Thain wrote: > My understanding is that support for chained scatterlists is to > become mandatory for LLDs. > > Cc: Michael Schmitz > Signed-off-by: Finn Thain Reviewed-by: Michael Schmitz > --- > 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); >