The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] /drivers/char sx.c ioremap -> pci_ioremap api
@ 2007-08-24 18:49 Scott Thompson
  2007-08-24 18:59 ` Jiri Slaby
  0 siblings, 1 reply; 10+ messages in thread
From: Scott Thompson @ 2007-08-24 18:49 UTC (permalink / raw)
  To: linux-kernel, kernel-janitors, jirislaby


patchset against 2.6.23-rc3.

moves the iomap/iounmap call to pci 'flavor'.  this was a
recommendation from a previously submitted patch that handles
the unchecked iomap (or, now, pci_iomap) return code.

Signed-off-by: Scott Thompson <postfail <at> hushmail.com>
----------------------------------------------------------

diff --git a/drivers/char/sx.c b/drivers/char/sx.c
index 85a2328..481334f 100644
--- a/drivers/char/sx.c
+++ b/drivers/char/sx.c
@@ -2626,14 +2626,14 @@ static void __devinit fix_sx_pci(struct pci_dev *pdev, struct sx_board *board)

  	pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &hwbase);
  	hwbase &= PCI_BASE_ADDRESS_MEM_MASK;
-	rebase = ioremap(hwbase, 0x80);
+	rebase = pci_iomap(pdev, 0, 0x80);
  	t = readl(rebase + CNTRL_REG_OFFSET);
  	if (t != CNTRL_REG_GOODVALUE) {
  		printk(KERN_DEBUG "sx: performing cntrl reg fix: %08x -> "
  			"%08x\n", t, CNTRL_REG_GOODVALUE);
  		writel(CNTRL_REG_GOODVALUE, rebase + CNTRL_REG_OFFSET);
  	}
-	iounmap(rebase);
+	pci_iounmap(pdev, rebase);
  }
  #endif

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] /drivers/char sx.c ioremap -> pci_ioremap api
  2007-08-24 18:49 [PATCH] /drivers/char sx.c ioremap -> pci_ioremap api Scott Thompson
@ 2007-08-24 18:59 ` Jiri Slaby
  2007-08-24 19:15   ` Alan Cox
  0 siblings, 1 reply; 10+ messages in thread
From: Jiri Slaby @ 2007-08-24 18:59 UTC (permalink / raw)
  To: postfail; +Cc: linux-kernel, kernel-janitors

On 8/24/07, Scott Thompson <postfailathushmail@gmail.com> wrote:
>
> patchset against 2.6.23-rc3.
>
> moves the iomap/iounmap call to pci 'flavor'.  this was a
> recommendation from a previously submitted patch that handles
> the unchecked iomap (or, now, pci_iomap) return code.
>
> Signed-off-by: Scott Thompson <postfail <at> hushmail.com>
> ----------------------------------------------------------
>
> diff --git a/drivers/char/sx.c b/drivers/char/sx.c
> index 85a2328..481334f 100644
> --- a/drivers/char/sx.c
> +++ b/drivers/char/sx.c
> @@ -2626,14 +2626,14 @@ static void __devinit fix_sx_pci(struct pci_dev
> *pdev, struct sx_board *board)
>
>   	pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &hwbase);
>   	hwbase &= PCI_BASE_ADDRESS_MEM_MASK;
> -	rebase = ioremap(hwbase, 0x80);

remove also the hwbase var.

> +	rebase = pci_iomap(pdev, 0, 0x80);
>   	t = readl(rebase + CNTRL_REG_OFFSET);
>   	if (t != CNTRL_REG_GOODVALUE) {
>   		printk(KERN_DEBUG "sx: performing cntrl reg fix: %08x -> "
>   			"%08x\n", t, CNTRL_REG_GOODVALUE);
>   		writel(CNTRL_REG_GOODVALUE, rebase + CNTRL_REG_OFFSET);
>   	}
> -	iounmap(rebase);
> +	pci_iounmap(pdev, rebase);
>   }
>   #endif
>


-- 
http://www.fi.muni.cz/~xslaby/            Jiri Slaby
faculty of informatics, masaryk university, brno, cz
e-mail: jirislaby gmail com, gpg pubkey fingerprint:
B674 9967 0407 CE62 ACC8  22A0 32CC 55C3 39D4 7A7E

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] /drivers/char sx.c ioremap -> pci_ioremap api
  2007-08-24 18:59 ` Jiri Slaby
@ 2007-08-24 19:15   ` Alan Cox
  2007-08-24 20:03     ` Jiri Slaby
  0 siblings, 1 reply; 10+ messages in thread
From: Alan Cox @ 2007-08-24 19:15 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: postfail, linux-kernel, kernel-janitors

ase, 0x80);
> 
> remove also the hwbase var.
> 
> > +	rebase = pci_iomap(pdev, 0, 0x80);
> >   	t = readl(rebase + CNTRL_REG_OFFSET);

Switch to ioread* if you are using the iomap interface. Its not a trivial
conversion and its slower and bulkier - the original ioremap was much
better

NAK this change therefore

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] /drivers/char sx.c ioremap -> pci_ioremap api
@ 2007-08-24 19:31 Scott Thompson
  0 siblings, 0 replies; 10+ messages in thread
From: Scott Thompson @ 2007-08-24 19:31 UTC (permalink / raw)
  To: jirislaby, alan; +Cc: linux-kernel, kernel-janitors

On Fri, 24 Aug 2007 15:15:30 -0400 Alan Cox 
<alan@lxorguk.ukuu.org.uk> wrote:
>ase, 0x80);
>> 
>> remove also the hwbase var.
>> 
>> > +	rebase = pci_iomap(pdev, 0, 0x80);
>> >   	t = readl(rebase + CNTRL_REG_OFFSET);
>
>Switch to ioread* if you are using the iomap interface. Its not a 
>trivial
>conversion and its slower and bulkier - the original ioremap was 
>much
>better
>
>NAK this change therefore

Jiri had requested this in relation to previous patch on unchecked 
ioremap return codes, but if the original ioremap is better NAK is 
fine
here and I won't resubmit w/ the hwbase var pulled out or the readl 
-> ioread32 switchover.

---------------------------------------
Scott Thompson / postfail@hushmail.com
---------------------------------------


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] /drivers/char sx.c ioremap -> pci_ioremap api
  2007-08-24 19:15   ` Alan Cox
@ 2007-08-24 20:03     ` Jiri Slaby
  2007-08-24 20:34       ` Alan Cox
  0 siblings, 1 reply; 10+ messages in thread
From: Jiri Slaby @ 2007-08-24 20:03 UTC (permalink / raw)
  To: Alan Cox; +Cc: Jiri Slaby, postfail, linux-kernel, kernel-janitors

Alan Cox napsal(a):
> ase, 0x80);
>> remove also the hwbase var.
>>
>>> +	rebase = pci_iomap(pdev, 0, 0x80);
>>>   	t = readl(rebase + CNTRL_REG_OFFSET);
> 
> Switch to ioread* if you are using the iomap interface. Its not a trivial

Why, if you know it's surely a mem region (and thus you rely on it and do
ioremap)? There are many places in the kernel, where this approach is used, e.g.
libata piix.

> conversion and its slower and bulkier - the original ioremap was much
> better

at least get rid of the reading the hwbase address from pci conf space, use
pci_resource_start instead.

-- 
Jiri Slaby (jirislaby@gmail.com)
Faculty of Informatics, Masaryk University

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] /drivers/char sx.c ioremap -> pci_ioremap api
  2007-08-24 20:03     ` Jiri Slaby
@ 2007-08-24 20:34       ` Alan Cox
  2007-08-25  8:45         ` readXs on pci*iomap-ped regions [Was: [PATCH] /drivers/char sx.c ioremap -> pci_ioremap api] Jiri Slaby
  0 siblings, 1 reply; 10+ messages in thread
From: Alan Cox @ 2007-08-24 20:34 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: Jiri Slaby, postfail, linux-kernel, kernel-janitors

On Fri, 24 Aug 2007 22:03:42 +0200
Jiri Slaby <jirislaby@gmail.com> wrote:

> Alan Cox napsal(a):
> > ase, 0x80);
> >> remove also the hwbase var.
> >>
> >>> +	rebase = pci_iomap(pdev, 0, 0x80);
> >>>   	t = readl(rebase + CNTRL_REG_OFFSET);
> > 
> > Switch to ioread* if you are using the iomap interface. Its not a trivial
> 
> Why, if you know it's surely a mem region (and thus you rely on it and do
> ioremap)? There are many places in the kernel, where this approach is used, e.g.
> libata piix.

Every single one of them is wrong. The encoding of iomap values is
platform dependant. Fixed in my tree.
> 
> > conversion and its slower and bulkier - the original ioremap was much
> > better
> 
> at least get rid of the reading the hwbase address from pci conf space, use
> pci_resource_start instead.

Agreed entirely

^ permalink raw reply	[flat|nested] 10+ messages in thread

* readXs on pci*iomap-ped regions [Was: [PATCH] /drivers/char sx.c ioremap -> pci_ioremap api]
  2007-08-24 20:34       ` Alan Cox
@ 2007-08-25  8:45         ` Jiri Slaby
  2007-08-25  8:56           ` Jeff Garzik
  0 siblings, 1 reply; 10+ messages in thread
From: Jiri Slaby @ 2007-08-25  8:45 UTC (permalink / raw)
  To: Alan Cox; +Cc: linux-kernel, Greg KH, linux-ide, linux-pci, Jeff Garzik

Alan Cox napsal(a):
>>>>> +	rebase = pci_iomap(pdev, 0, 0x80);
>>>>>   	t = readl(rebase + CNTRL_REG_OFFSET);
>>> Switch to ioread* if you are using the iomap interface. Its not a trivial
>> Why, if you know it's surely a mem region (and thus you rely on it and do
>> ioremap)? There are many places in the kernel, where this approach is used, e.g.
>> libata piix.
> 
> Every single one of them is wrong. The encoding of iomap values is
> platform dependant. Fixed in my tree.

OK, fast search found these suspicious (not considering e.g. arch/):
$ find drivers/ -name '*.c' -exec grep -q pci.*iomap {} \; -a -exec grep -l
'\<readl\>' {} \+
drivers/firewire/fw-ohci.c
drivers/scsi/sym53c8xx_2/sym_glue.c
drivers/media/dvb/pluto2/pluto2.c
drivers/media/dvb/b2c2/flexcop-pci.c
drivers/ssb/scan.c
drivers/char/cyclades.c
drivers/char/sx.c
drivers/ata/ata_piix.c
drivers/ata/sata_inic162x.c
drivers/ata/pata_pdc2027x.c
drivers/ata/sata_sx4.c
drivers/ata/sata_qstor.c
drivers/ata/sata_mv.c
drivers/ata/sata_svw.c
drivers/ata/sata_nv.c
drivers/ata/sata_sil.c
drivers/ata/sata_vsc.c
drivers/ata/sata_promise.c
drivers/ata/ahci.c
drivers/ata/sata_sil24.c
drivers/net/cassini.c
drivers/mtd/nand/cafe_nand.c

How do you imagine a proper fix?
- move to ioreadX/iowriteX
or
- move back to ioremap (unlikely for the most)
or?

thanks,
-- 
Jiri Slaby (jirislaby@gmail.com)
Faculty of Informatics, Masaryk University

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: readXs on pci*iomap-ped regions [Was: [PATCH] /drivers/char sx.c ioremap -> pci_ioremap api]
  2007-08-25  8:45         ` readXs on pci*iomap-ped regions [Was: [PATCH] /drivers/char sx.c ioremap -> pci_ioremap api] Jiri Slaby
@ 2007-08-25  8:56           ` Jeff Garzik
  2007-08-25  9:02             ` Jiri Slaby
  2007-08-25 10:17             ` Alan Cox
  0 siblings, 2 replies; 10+ messages in thread
From: Jeff Garzik @ 2007-08-25  8:56 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: Alan Cox, linux-kernel, Greg KH, linux-ide, linux-pci

If the driver knows its MMIO, using readX/writeX after pci_iomap() is 
just fine, for all current implementations, and it makes sense that way.

	Jeff




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: readXs on pci*iomap-ped regions [Was: [PATCH] /drivers/char sx.c ioremap -> pci_ioremap api]
  2007-08-25  8:56           ` Jeff Garzik
@ 2007-08-25  9:02             ` Jiri Slaby
  2007-08-25 10:17             ` Alan Cox
  1 sibling, 0 replies; 10+ messages in thread
From: Jiri Slaby @ 2007-08-25  9:02 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Alan Cox, linux-kernel, Greg KH, linux-ide, linux-pci

Jeff Garzik napsal(a):
> If the driver knows its MMIO, using readX/writeX after pci_iomap() is
> just fine, for all current implementations, and it makes sense that way.

Hmm, that's what I'm claiming.

-- 
Jiri Slaby (jirislaby@gmail.com)
Faculty of Informatics, Masaryk University

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: readXs on pci*iomap-ped regions [Was: [PATCH] /drivers/char sx.c ioremap -> pci_ioremap api]
  2007-08-25  8:56           ` Jeff Garzik
  2007-08-25  9:02             ` Jiri Slaby
@ 2007-08-25 10:17             ` Alan Cox
  1 sibling, 0 replies; 10+ messages in thread
From: Alan Cox @ 2007-08-25 10:17 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Jiri Slaby, linux-kernel, Greg KH, linux-ide, linux-pci

On Sat, 25 Aug 2007 04:56:19 -0400
Jeff Garzik <jgarzik@pobox.com> wrote:

> If the driver knows its MMIO, using readX/writeX after pci_iomap() is 
> just fine, for all current implementations, and it makes sense that way.

There is nothing that guarantees this is permitted, any more than there
is anything saying not to use outb/outl. Some of the implementations do
quite strange things. It may happen to work but its not in the
documentation or the comments.

If you want to change this then you need to check the existing usages and
update all the docs if its safe, oh and tell the sparc64 pcmcia people to
take a hike, which is probably not a big problem.

Alan

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-08-25 10:10 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-24 18:49 [PATCH] /drivers/char sx.c ioremap -> pci_ioremap api Scott Thompson
2007-08-24 18:59 ` Jiri Slaby
2007-08-24 19:15   ` Alan Cox
2007-08-24 20:03     ` Jiri Slaby
2007-08-24 20:34       ` Alan Cox
2007-08-25  8:45         ` readXs on pci*iomap-ped regions [Was: [PATCH] /drivers/char sx.c ioremap -> pci_ioremap api] Jiri Slaby
2007-08-25  8:56           ` Jeff Garzik
2007-08-25  9:02             ` Jiri Slaby
2007-08-25 10:17             ` Alan Cox
  -- strict thread matches above, loose matches on Subject: below --
2007-08-24 19:31 [PATCH] /drivers/char sx.c ioremap -> pci_ioremap api Scott Thompson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox