From patchwork Sun Jan 24 10:38:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 8098441 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 83150BEEE5 for ; Sun, 24 Jan 2016 10:39:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 900F920395 for ; Sun, 24 Jan 2016 10:39:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 859ED20389 for ; Sun, 24 Jan 2016 10:39:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751515AbcAXKit (ORCPT ); Sun, 24 Jan 2016 05:38:49 -0500 Received: from mail-io0-f196.google.com ([209.85.223.196]:33150 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751444AbcAXKir (ORCPT ); Sun, 24 Jan 2016 05:38:47 -0500 Received: by mail-io0-f196.google.com with SMTP id f81so10660080iof.0; Sun, 24 Jan 2016 02:38:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=vX4/M+5WHpjOUiTK5uLz05unWN5mlWeMnLuQia/LokY=; b=cVyTWXnfBUI/hN0HBSruliQaDly0HKLocTliZqcuj3CVyEiuwSXnNSg/pLYTXg/DI0 9R6Dq9lsM8gkJ88FOFFEnzWgngmD9JjObj4c7vWFCa5ESuhHDXRh9nXJjuIVTbL0nMYS qZZBYkDzXk4rdnHYzkcT+GHjk95dnbfIz5eX3NT2tE1dDo5Nrnxz4rD/guQoTlW7l17b sEoNxhgoF7tZFsglVgnTnoCnBc3fbAJZWCxIYG8Vjl7OgGfPCpRELMUQhxqg5N1g04Mh 9ip18ZyNgcf8KzsmNnp5uDr5ndY715W+kXShvjS3aAWz4AdqQ0vkBtPoRiaa9RYal9L1 2xiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=vX4/M+5WHpjOUiTK5uLz05unWN5mlWeMnLuQia/LokY=; b=c5lUrBhrlrd5IsTCwe/TTTKHBxG/JatWY0x9Pb6ne2DpzqczywLwHR+o7y2BYzIBmQ Nl3b7u7nc7mrp1Loc1GnPB0rov21V0aSAuaX/vLZIyOtMwUTCbfy/Z7DX5hEchsPfTyu dOHfAxzY3j0ycrQINczbKhNGWqnWP4Y3Wnuk1Zi29H1l/JJaNfooijN6P2bGe7zU+b/W hpF0J9b+BE8tGVV6dJo2cmAbmaUrU6Vl2lG6J9B0Utmh1I9HTTEOTjpdwwzPaKV7dPHq FABfzIN4zqOwA57TP9ZhttJPsP8UvcB0y6xFG+dFc0A5PPZVep4F/9G+q4K3EYnadb/1 h+lg== X-Gm-Message-State: AG10YORsmxxNgibeq6CcTTfevAz1Vxf0jYmsi1pfWvB8ANKXj6d2/Wy6dzA48z04pyJgDoiqwbEzIUyT7l0f6A== MIME-Version: 1.0 X-Received: by 10.107.148.75 with SMTP id w72mr14093554iod.115.1453631926632; Sun, 24 Jan 2016 02:38:46 -0800 (PST) Received: by 10.107.9.97 with HTTP; Sun, 24 Jan 2016 02:38:46 -0800 (PST) In-Reply-To: <20160103050510.031796194@telegraphics.com.au> References: <20160103050501.042035135@telegraphics.com.au> <20160103050510.031796194@telegraphics.com.au> Date: Sun, 24 Jan 2016 11:38:46 +0100 X-Google-Sender-Auth: zZorQMPr89fOoRZwLzOi3xiaThI Message-ID: Subject: Re: [PATCH v4 34/78] atari_NCR5380: Use arbitration timeout From: Geert Uytterhoeven To: Finn Thain Cc: "James E.J. Bottomley" , "Martin K. Petersen" , Michael Schmitz , "Linux/m68k" , scsi , "linux-kernel@vger.kernel.org" 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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 Hi Finn, On Sun, Jan 3, 2016 at 6:05 AM, Finn Thain wrote: > Allow target selection to fail with a timeout instead of waiting in > infinite loops. This gets rid of the unused NCR_TIMEOUT macro, it is more > defensive and has proved helpful in debugging. > > Signed-off-by: Finn Thain > Reviewed-by: Hannes Reinecke > Tested-by: Ondrej Zary > Tested-by: Michael Schmitz This patch (commit 55500d9b08295e3b6016b53879dea1cb7787f1b0) causes a hang on ARAnyM with atari_defconfig after: scsi host0: Atari native SCSI, io_port 0x0, n_io_port 0, base 0x0, irq 15, can_queue 8, cmd_per_lun 1, sg_tablesize 0, this_id 7, flags { }, options { REAL_DMA SUPPORT_TAGS } blk_queue_max_segments: set to minimum 1 > --- linux.orig/drivers/scsi/atari_NCR5380.c 2016-01-03 16:03:43.000000000 +1100 > +++ linux/drivers/scsi/atari_NCR5380.c 2016-01-03 16:03:44.000000000 +1100 > @@ -1436,42 +1437,28 @@ static int NCR5380_select(struct Scsi_Ho > NCR5380_write(OUTPUT_DATA_REG, hostdata->id_mask); > NCR5380_write(MODE_REG, MR_ARBITRATE); > > - local_irq_restore(flags); > + /* The chip now waits for BUS FREE phase. Then after the 800 ns > + * Bus Free Delay, arbitration will begin. > + */ > > - /* Wait for arbitration logic to complete */ > -#if defined(NCR_TIMEOUT) > - { > - unsigned long timeout = jiffies + 2*NCR_TIMEOUT; > - > - while (!(NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_PROGRESS) && > - time_before(jiffies, timeout) && !hostdata->connected) > - ; > - if (time_after_eq(jiffies, timeout)) { > - printk("scsi : arbitration timeout at %d\n", __LINE__); > + local_irq_restore(flags); > + timeout = jiffies + HZ; > + while (1) { > + if (time_is_before_jiffies(timeout)) { > NCR5380_write(MODE_REG, MR_BASE); > - NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); > + shost_printk(KERN_ERR, instance, > + "select: arbitration timeout\n"); > return -1; > } > + if (!(NCR5380_read(MODE_REG) & MR_ARBITRATE)) { This newly added check always triggers, causing an infinite loop calling NCR5380_select(). Perhaps this is an ARAnyM quirk? If not, does it trigger (on some hardware) with drivers/scsi/NCR5380.c, too? > + /* Reselection interrupt */ > + return -1; > + } > + if (NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_PROGRESS) > + break; > } > -#else /* NCR_TIMEOUT */ > - while (!(NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_PROGRESS) && > - !hostdata->connected) > - ; > -#endif > - > - dprintk(NDEBUG_ARBITRATION, "scsi%d: arbitration complete\n", HOSTNO); > - > - if (hostdata->connected) { > - NCR5380_write(MODE_REG, MR_BASE); > - return -1; > - } > - /* > - * The arbitration delay is 2.2us, but this is a minimum and there is > - * no maximum so we can safely sleep for ceil(2.2) usecs to accommodate > - * the integral nature of udelay(). > - * > - */ > > + /* The SCSI-2 arbitration delay is 2.4 us */ > udelay(3); > > /* Check for lost arbitration */ On current mainline, this (whitespace-damaged) patch fixed the issue for me: shost_printk(KERN_ERR, instance, @@ -1297,10 +1293,6 @@ static struct scsi_cmnd *NCR5380_select(struct Scsi_Host *instance, spin_lock_irq(&hostdata->lock); - /* NCR5380_reselect() clears MODE_REG after a reselection interrupt */ - if (!(NCR5380_read(MODE_REG) & MR_ARBITRATE)) - goto out; - if (!hostdata->selecting) { NCR5380_write(MODE_REG, MR_BASE); NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); Gr{oetje,eeting}s, Geert --- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds -- 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 --- a/drivers/scsi/atari_NCR5380.c +++ b/drivers/scsi/atari_NCR5380.c @@ -1253,10 +1253,6 @@ static struct scsi_cmnd *NCR5380_select(struct Scsi_Host *instance, INITIATOR_COMMAND_REG, ICR_ARBITRATION_PROGRESS, ICR_ARBITRATION_PROGRESS, HZ); spin_lock_irq(&hostdata->lock); - if (!(NCR5380_read(MODE_REG) & MR_ARBITRATE)) { - /* Reselection interrupt */ - goto out; - } if (err < 0) { NCR5380_write(MODE_REG, MR_BASE);