From patchwork Sun Jan 3 05:05:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Finn Thain X-Patchwork-Id: 7942651 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9D0919F1C0 for ; Sun, 3 Jan 2016 05:39:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B7D2C20351 for ; Sun, 3 Jan 2016 05:39:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C4B412034F for ; Sun, 3 Jan 2016 05:39:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752591AbcACFTv (ORCPT ); Sun, 3 Jan 2016 00:19:51 -0500 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:49461 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751670AbcACFSR (ORCPT ); Sun, 3 Jan 2016 00:18:17 -0500 Received: by kvm5.telegraphics.com.au (Postfix, from userid 502) id 0061D22D07; Sun, 3 Jan 2016 00:18:07 -0500 (EST) Message-Id: <20160103050509.771815158@telegraphics.com.au> User-Agent: quilt/0.50-1 Date: Sun, 03 Jan 2016 16:05:34 +1100 From: Finn Thain To: "James E.J. Bottomley" , "Martin K. Petersen" , Michael Schmitz , , , Subject: [PATCH v4 33/78] atari_NCR5380: Set do_abort() timeouts References: <20160103050501.042035135@telegraphics.com.au> Content-Disposition: inline; filename=atari_NCR5380-do_abort-timeouts Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use timeouts in do_abort() in atari_NCR5380.c instead of infinite loops. Also fix the kernel-doc comment. Keep the two core driver forks in sync. Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Tested-by: Ondrej Zary Tested-by: Michael Schmitz --- drivers/scsi/NCR5380.c | 26 +++++++++++++------------- drivers/scsi/atari_NCR5380.c | 34 +++++++++++++++++++++------------- 2 files changed, 34 insertions(+), 26 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux/drivers/scsi/atari_NCR5380.c =================================================================== --- linux.orig/drivers/scsi/atari_NCR5380.c 2016-01-03 16:03:39.000000000 +1100 +++ linux/drivers/scsi/atari_NCR5380.c 2016-01-03 16:03:43.000000000 +1100 @@ -1835,19 +1835,19 @@ static void do_reset(struct Scsi_Host *i local_irq_restore(flags); } -/* - * Function : do_abort (Scsi_Host *host) +/** + * do_abort - abort the currently established nexus by going to + * MESSAGE OUT phase and sending an ABORT message. + * @instance: relevant scsi host instance * - * Purpose : abort the currently established nexus. Should only be - * called from a routine which can drop into a - * - * Returns : 0 on success, -1 on failure. + * Returns 0 on success, -1 on failure. */ static int do_abort(struct Scsi_Host *instance) { unsigned char tmp, *msgptr, phase; int len; + int rc; /* Request message out phase */ NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN); @@ -1862,16 +1862,20 @@ static int do_abort(struct Scsi_Host *in * the target sees, so we just handshake. */ - while (!((tmp = NCR5380_read(STATUS_REG)) & SR_REQ)) - ; + rc = NCR5380_poll_politely(instance, STATUS_REG, SR_REQ, SR_REQ, 10 * HZ); + if (rc < 0) + goto timeout; + + tmp = NCR5380_read(STATUS_REG) & PHASE_MASK; NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(tmp)); - if ((tmp & PHASE_MASK) != PHASE_MSGOUT) { - NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN | - ICR_ASSERT_ACK); - while (NCR5380_read(STATUS_REG) & SR_REQ) - ; + if (tmp != PHASE_MSGOUT) { + NCR5380_write(INITIATOR_COMMAND_REG, + ICR_BASE | ICR_ASSERT_ATN | ICR_ASSERT_ACK); + rc = NCR5380_poll_politely(instance, STATUS_REG, SR_REQ, 0, 3 * HZ); + if (rc < 0) + goto timeout; NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN); } @@ -1887,6 +1891,10 @@ static int do_abort(struct Scsi_Host *in */ return len ? -1 : 0; + +timeout: + NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); + return -1; } #if defined(REAL_DMA) Index: linux/drivers/scsi/NCR5380.c =================================================================== --- linux.orig/drivers/scsi/NCR5380.c 2016-01-03 16:03:42.000000000 +1100 +++ linux/drivers/scsi/NCR5380.c 2016-01-03 16:03:43.000000000 +1100 @@ -1458,16 +1458,12 @@ static void do_reset(struct Scsi_Host *i local_irq_restore(flags); } -/* - * Function : do_abort (Scsi_Host *host) - * - * Purpose : abort the currently established nexus. Should only be - * called from a routine which can drop into a - * - * Returns : 0 on success, -1 on failure. +/** + * do_abort - abort the currently established nexus by going to + * MESSAGE OUT phase and sending an ABORT message. + * @instance: relevant scsi host instance * - * Locks: queue lock held by caller - * FIXME: sort this out and get new_eh running + * Returns 0 on success, -1 on failure. */ static int do_abort(struct Scsi_Host *instance) @@ -1489,9 +1485,9 @@ static int do_abort(struct Scsi_Host *in * the target sees, so we just handshake. */ - rc = NCR5380_poll_politely(instance, STATUS_REG, SR_REQ, SR_REQ, 60 * HZ); + rc = NCR5380_poll_politely(instance, STATUS_REG, SR_REQ, SR_REQ, 10 * HZ); if (rc < 0) - return -1; + goto timeout; tmp = NCR5380_read(STATUS_REG) & PHASE_MASK; @@ -1500,9 +1496,9 @@ static int do_abort(struct Scsi_Host *in if (tmp != PHASE_MSGOUT) { NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN | ICR_ASSERT_ACK); rc = NCR5380_poll_politely(instance, STATUS_REG, SR_REQ, 0, 3 * HZ); - NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN); if (rc < 0) - return -1; + goto timeout; + NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN); } tmp = ABORT; msgptr = &tmp; @@ -1516,6 +1512,10 @@ static int do_abort(struct Scsi_Host *in */ return len ? -1 : 0; + +timeout: + NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); + return -1; } #if defined(REAL_DMA) || defined(PSEUDO_DMA) || defined (REAL_DMA_POLL)