linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
To: Borislav Petkov <petkovbb@googlemail.com>
Cc: linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 14/14] ide: unify interrupt reason checking
Date: Sun, 10 May 2009 23:39:37 +0200	[thread overview]
Message-ID: <200905102339.38126.bzolnier@gmail.com> (raw)
In-Reply-To: <1241855134-4984-15-git-send-email-petkovbb@gmail.com>

On Saturday 09 May 2009 09:45:34 Borislav Petkov wrote:
> Add ide_check_ireason() function that handles all ATAPI devices. Move
> the ATAPI_COD check later in the if-else chain since the case for
> ATAPI_COD to be set is rather unlikely in a normal operation. Also, add
> a branch predictor hint for it. Generally, move all unlikely cases in
> ireason checking further down in the code path.
> 
> In addition, add PFX for printks originating from ide-atapi. Finally,
> remove ide_cd_check_ireason.
> 
> Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
> ---
>  drivers/ide/ide-atapi.c |   94 ++++++++++++++++++++++++++++++++++-------------
>  drivers/ide/ide-cd.c    |   48 +-----------------------
>  include/linux/ide.h     |    2 +
>  3 files changed, 71 insertions(+), 73 deletions(-)

[...]

> @@ -324,6 +327,56 @@ void ide_read_bcount_and_ireason(ide_drive_t *drive, u16 *bcount, u8 *ireason)
>  EXPORT_SYMBOL_GPL(ide_read_bcount_and_ireason);
>  
>  /*
> + * Check the contents of the interrupt reason register and attempt to recover if
> + * there are problems.
> + *
> + * Returns:
> + * - 0 if everything's ok
> + * - 1 if the request has to be terminated.
> + */
> +int ide_check_ireason(ide_drive_t *drive, struct request *rq, int len,
> +		      int ireason, int rw)
> +{
> +	ide_hwif_t *hwif = drive->hwif;
> +
> +	debug_log("ireason: 0x%x, rw: 0x%x\n", ireason, rw);
> +
> +	if (ireason == (!rw << 1))
> +		return 0;
> +	else if (ireason == (rw << 1)) {
> +		printk(KERN_ERR PFX "%s: %s: wrong transfer direction!\n",
> +				drive->name, __func__);
> +
> +		if (dev_is_idecd(drive))
> +			ide_pad_transfer(drive, rw, len);
> +	}
> +	else if (!rw && ireason == ATAPI_COD) {

ERROR: else should follow close brace '}'
#90: FILE: drivers/ide/ide-atapi.c:353:
+       }
+       else if (!rw && ireason == ATAPI_COD) {

> +		if (dev_is_idecd(drive)) {
> +			/*
> +			 * some drives (ASUS) seem to tell us that status info

s/some/Some/

> +			 * is available.  Just get it and ignore.
> +			 */
> +			(void)hwif->tp_ops->read_status(hwif);
> +			return 0;
> +		}
> +	} else {
> +		if (unlikely(ireason & ATAPI_COD))
> +			printk(KERN_ERR PFX "%s: CoD != 0 in %s\n", drive->name,
> +					__func__);

This is redundant given printk() below and using unlikely() in error-only
code-paths is overdoing it a bit (putting it very mildly)...

> +		/* drive wants a command packet, or invalid ireason... */
> +		printk(KERN_ERR PFX "%s: %s: bad interrupt reason 0x%02x\n",
> +				drive->name, __func__, ireason);

> @@ -501,13 +543,13 @@ static u8 ide_wait_ireason(ide_drive_t *drive, u8 ireason)
>  
>  	while (retries-- && ((ireason & ATAPI_COD) == 0 ||
>  		(ireason & ATAPI_IO))) {
> -		printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing "
> +		printk(KERN_ERR PFX "%s: (IO,CoD != (0,1) while issuing "

WARNING: line over 80 characters
#203: FILE: drivers/ide/ide-atapi.c:625:
+                       printk(KERN_ERR PFX "%s: (IO,CoD) != (0,1) while issuing "

[ Please remember about checkpatch.pl. ]

> @@ -652,9 +608,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
>  		goto out_end;
>  	}
>  
> -	/* check which way to transfer data */
> -	rc = ide_cd_check_ireason(drive, rq, len, ireason, write);
> -	if (rc)
> +	if (ide_check_ireason(drive, rq, len, ireason, write))
>  		goto out_end;

This introduces a real bug -- we check rc's value in "out_end" path.

  reply	other threads:[~2009-05-10 21:36 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-09  7:45 [RFC PATCH 0/12] ide-atapi remove pc->buf Borislav Petkov
2009-05-09  7:45 ` [PATCH 01/14] ide-tape: fix potential fs requests bug Borislav Petkov
2009-05-09  8:02   ` Sam Ravnborg
2009-05-09  8:50     ` Borislav Petkov
2009-05-09 10:25       ` Sam Ravnborg
2009-05-09 12:09         ` Borislav Petkov
2009-05-09  7:45 ` [PATCH 02/14] ide-atapi: switch to blk_rq_bytes() on do_request() path Borislav Petkov
2009-05-10 21:32   ` Bartlomiej Zolnierkiewicz
2009-05-09  7:45 ` [PATCH 03/14] ide-atapi: switch to rq->resid_len Borislav Petkov
2009-05-10 21:32   ` Bartlomiej Zolnierkiewicz
2009-05-11  7:23     ` Borislav Petkov
2009-05-11 11:22       ` Bartlomiej Zolnierkiewicz
2009-05-12 14:38   ` Sergei Shtylyov
2009-05-09  7:45 ` [PATCH 04/14] ide-atapi: add a len-parameter to ide_queue_pc_tail Borislav Petkov
2009-05-09  7:45 ` [PATCH 05/14] ide-atapi: add a buffer-arg " Borislav Petkov
2009-05-10 21:32   ` Bartlomiej Zolnierkiewicz
2009-05-09  7:45 ` [PATCH 06/14] ide-floppy/ide_floppy_get_flexible_disk_page: use local buffer Borislav Petkov
2009-05-09  7:45 ` [PATCH 07/14] ide-floppy/ide_floppy_get_sfrp_bit: " Borislav Petkov
2009-05-09  7:45 ` [PATCH 08/14] ide-floppy/ide_floppy_format_unit: " Borislav Petkov
2009-05-09  7:45 ` [PATCH 09/14] ide-atapi: use local sense buffer Borislav Petkov
2009-05-10 21:32   ` Bartlomiej Zolnierkiewicz
2009-05-12  7:17     ` Borislav Petkov
2009-05-09  7:45 ` [PATCH 10/14] ide-tape: fix READ POSITION cmd handling Borislav Petkov
2009-05-09  7:45 ` [PATCH 11/14] ide-tape/ide_tape_get_bsize_from_bdesc: use local buffer Borislav Petkov
2009-05-09  7:45 ` [PATCH 12/14] ide-atapi: remove pc->buf Borislav Petkov
2009-05-09  7:45 ` [PATCH 13/14] ide-cd: use whole request_sense buffer in EH Borislav Petkov
2009-05-09  7:45 ` [PATCH 14/14] ide: unify interrupt reason checking Borislav Petkov
2009-05-10 21:39   ` Bartlomiej Zolnierkiewicz [this message]
2009-05-10 21:32 ` [RFC PATCH 0/12] ide-atapi remove pc->buf Bartlomiej Zolnierkiewicz
2009-05-10 23:30   ` Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200905102339.38126.bzolnier@gmail.com \
    --to=bzolnier@gmail.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=petkovbb@googlemail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).