From patchwork Sat Jul 1 21:49:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 9821007 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C24A86035F for ; Sat, 1 Jul 2017 21:49:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFE1228346 for ; Sat, 1 Jul 2017 21:49:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A11C2283BE; Sat, 1 Jul 2017 21:49:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BABC628346 for ; Sat, 1 Jul 2017 21:49:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751659AbdGAVt1 (ORCPT ); Sat, 1 Jul 2017 17:49:27 -0400 Received: from smtp-1b.atlantis.sk ([80.94.52.26]:36630 "EHLO smtp-1b.atlantis.sk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751611AbdGAVt0 (ORCPT ); Sat, 1 Jul 2017 17:49:26 -0400 Received: from [192.168.0.2] (188-167-69-119.dynamic.chello.sk [188.167.69.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp-1b.atlantis.sk (Postfix) with ESMTPSA id 05C63826519F; Sat, 1 Jul 2017 23:49:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rainbow-software.org; s=atlsmtp; t=1498945754; bh=r685uQH8gsSboZ7HoF4ln7O6Hw3XeD443cMPMNf2DU4=; h=From:To:Subject:Date:Cc:References:In-Reply-To; b=Ova92A0js79Hz6MBTszm7Q63hNDmUUuVC/KWL/dREBKwNSLN/FC9BGKcQUI40SoLl SJOJzgqO9QbLEFT95ikDjwyhI9k5SB7wb9LCXoZYHmcfSMGmmAJbBVCb3Z4FOOeeOs kHXs/83zpK6an75hV2AtXQKf1dLwBIlO+B0Z2ksk= From: Ondrej Zary To: Finn Thain Subject: Re: [PATCH v6 0/6] g_NCR5380: PDMA fixes and cleanup Date: Sat, 1 Jul 2017 23:49:03 +0200 User-Agent: KMail/1.9.10 (enterprise35 0.20100827.1168748) Cc: "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Schmitz References: In-Reply-To: X-KMail-QuotePrefix: > MIME-Version: 1.0 Content-Disposition: inline Message-Id: <201707012349.04652.linux@rainbow-software.org> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Saturday 01 July 2017 04:40:53 Finn Thain wrote: > Ondrej, would you please test this new series? > > Changed since v1: > - PDMA transfer residual is calculated earlier. > - End of DMA flag check is now polled (if there is any residual). > > Changed since v2: > - Bail out of transfer loops when Gated IRQ gets asserted. > - Make udelay conditional on board type. > - Drop sg_tablesize patch due to performance regression. > > Changed since v3: > - Add Ondrej's workaround for corrupt WRITE commands on DTC boards. > - Reset the 53c400 logic after any short PDMA transfer. > - Don't fail the transfer if the 53c400 logic got a reset. > > Changed since v4: > - Bail out of transfer loops when Gated IRQ gets asserted. (Again.) > - Always call wait_for_53c80_registers() at end of transfer. > - Drain chip buffers after PDMA receive is interrupted. > - Rework residual calculation. > - Add new patch to correct DMA terminology. > > Changed since v5: > - Rework residual calculation to account for on-chip buffer swap. > - Attempt to retain the disconnect/IRQ detection in the DTC436 workaround. > - Move all DTC436 workarounds to final patch. > > > Finn Thain (2): > g_NCR5380: Cleanup comments and whitespace > g_NCR5380: Use unambiguous terminology for PDMA send and receive > > Ondrej Zary (4): > g_NCR5380: Fix PDMA transfer size > g_NCR5380: End PDMA transfer correctly on target disconnection > g_NCR5380: Re-work PDMA loops > g_NCR5380: Various DTC436 workarounds > > drivers/scsi/g_NCR5380.c | 273 > ++++++++++++++++++++++++++--------------------- 1 file changed, 151 > insertions(+), 122 deletions(-) The write corruption is still present - "start" must be rolled back in both IRQ and timeout cases. And 128 B is not enough , 256 is OK (why did it work last time?). We just wrote a buffer to the chip but the chip is writing the previous one to the drive - so if a problem arises, both buffers are lost. This fixes the corruption (although the "start > 0" check seems wrong now): DTC seems to work too. --- a/drivers/scsi/g_NCR5380.c +++ b/drivers/scsi/g_NCR5380.c @@ -598,23 +598,17 @@ static inline int generic_NCR5380_psend(struct NCR5380_hostdata *hostdata, CSR_HOST_BUF_NOT_RDY, 0, hostdata->c400_ctl_status, CSR_GATED_53C80_IRQ, - CSR_GATED_53C80_IRQ, HZ / 64) < 0) - break; - - if (NCR5380_read(hostdata->c400_ctl_status) & - CSR_HOST_BUF_NOT_RDY) { + CSR_GATED_53C80_IRQ, HZ / 64) < 0 || + (NCR5380_read(hostdata->c400_ctl_status) & + (CSR_HOST_BUF_NOT_RDY | CSR_GATED_53C80_IRQ))) { /* The chip has done a 128 B buffer swap but the first * buffer still has not reached the SCSI bus. */ if (start > 0) - start -= 128; + start -= 256; break; } - if (NCR5380_read(hostdata->c400_ctl_status) & - CSR_GATED_53C80_IRQ) - break; - if (hostdata->io_port && hostdata->io_width == 2) outsw(hostdata->io_port + hostdata->c400_host_buf, src + start, 64);