linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
To: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: linux-ide@vger.kernel.org
Subject: Re: [PATCH] ide: make ide_pci_check_iomem() actually work
Date: Mon, 7 Apr 2008 22:46:40 +0200	[thread overview]
Message-ID: <200804072246.40223.bzolnier@gmail.com> (raw)
In-Reply-To: <200804072027.17520.sshtylyov@ru.mvista.com>


Hi,

On Monday 07 April 2008, Sergei Shtylyov wrote:
> This function didn't actually check if a given BAR is in I/O space because of
> using the bogus PCI_BASE_ADDRESS_IO_MASK (which equals ~3) to test the resource
> flags instead of IORESOURCE_IO -- fix this, make ide_hwif_configure() check the
> results failing if necessary, and move the printk() call to the failure path.

This change is OK in itself but I worry that ide_pci_check_iomem() may now
return "false" errors (bogus PCI_BASE_ADDRESS_IO_MASK check resulted in MEM
resources always surviving ide_pci_check_iomem() calls before the fix) for
some host drivers (siimage, scc_pata...) resulting in failed initialization.

How's about removing this dead/broken function instead for now?

[ IIRC for managed PCI devices these checks are done by generic code so
  once IDE got converted to use it we will get them as an added bonus... ]

Thanks,
Bart

> Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
> 
> ---
> The patch is against today's Linus' tree...
> 
>  drivers/ide/setup-pci.c |   23 ++++++++++++-----------
>  1 files changed, 12 insertions(+), 11 deletions(-)
> 
> Index: linux-2.6/drivers/ide/setup-pci.c
> ===================================================================
> --- linux-2.6.orig/drivers/ide/setup-pci.c
> +++ linux-2.6/drivers/ide/setup-pci.c
> @@ -312,11 +312,12 @@ static int ide_pci_configure(struct pci_
>   *	@d: IDE port info
>   *	@bar: BAR number
>   *
> - *	Checks if a BAR is configured and points to MMIO space. If so
> - *	print an error and return an error code. Otherwise return 0
> + *	Checks if a BAR is configured and points to MMIO space. If so,
> + *	return an error code. Otherwise return 0
>   */
>  
> -static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info *d, int bar)
> +static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info *d,
> +			       int bar)
>  {
>  	ulong flags = pci_resource_flags(dev, bar);
>  	
> @@ -324,14 +325,11 @@ static int ide_pci_check_iomem(struct pc
>  	if (!flags || pci_resource_len(dev, bar) == 0)
>  		return 0;
>  
> -	/* I/O space */		
> -	if(flags & PCI_BASE_ADDRESS_IO_MASK)
> +	/* I/O space */
> +	if (flags & IORESOURCE_IO)
>  		return 0;
>  		
>  	/* Bad */
> -	printk(KERN_ERR "%s: IO baseregs (BIOS) are reported "
> -			"as MEM, report to "
> -			"<andre@linux-ide.org>.\n", d->name);
>  	return -EINVAL;
>  }
>  
> @@ -360,9 +358,12 @@ static ide_hwif_t *ide_hwif_configure(st
>  	struct hw_regs_s hw;
>  
>  	if ((d->host_flags & IDE_HFLAG_ISA_PORTS) == 0) {
> -		/*  Possibly we should fail if these checks report true */
> -		ide_pci_check_iomem(dev, d, 2*port);
> -		ide_pci_check_iomem(dev, d, 2*port+1);
> +		if (ide_pci_check_iomem(dev, d, 2 * port) ||
> +		    ide_pci_check_iomem(dev, d, 2 * port + 1)) {
> +			printk(KERN_ERR "%s: I/O baseregs (BIOS) are reported "
> +					"as MEM for port %d!\n", d->name, port);
> +			return NULL;
> +		}
>   
>  		ctl  = pci_resource_start(dev, 2*port+1);
>  		base = pci_resource_start(dev, 2*port);

  reply	other threads:[~2008-04-07 20:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-07 16:27 [PATCH] ide: make ide_pci_check_iomem() actually work Sergei Shtylyov
2008-04-07 20:46 ` Bartlomiej Zolnierkiewicz [this message]
2008-04-08 11:45   ` Sergei Shtylyov
2008-04-08 12:38     ` Sergei Shtylyov
2008-04-09 18:34       ` Bartlomiej Zolnierkiewicz
2008-04-15 20:45         ` Bartlomiej Zolnierkiewicz

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=200804072246.40223.bzolnier@gmail.com \
    --to=bzolnier@gmail.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=sshtylyov@ru.mvista.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).