* Re: [PATCH 6/13] devres: implement managed iomap interface [not found] <11684073371547-git-send-email-htejun@gmail.com> @ 2008-04-07 16:46 ` Sergei Shtylyov 2008-04-08 14:48 ` Tejun Heo 0 siblings, 1 reply; 9+ messages in thread From: Sergei Shtylyov @ 2008-04-07 16:46 UTC (permalink / raw) To: Tejun Heo; +Cc: linuxppc-dev, gregkh, linux-kernel, linux-ide, jgarzik, alan Tejun Heo wrote: > +/** > + * devm_ioremap - Managed ioremap() > + * @dev: Generic device to remap IO address for > + * @offset: BUS offset to map > + * @size: Size of map > + * > + * Managed ioremap(). Map is automatically unmapped on driver detach. > + */ > +void __iomem *devm_ioremap(struct device *dev, unsigned long offset, > + unsigned long size) > +{ > + void __iomem **ptr, *addr; > + > + ptr = devres_alloc(devm_ioremap_release, sizeof(*ptr), GFP_KERNEL); > + if (!ptr) > + return NULL; > + > + addr = ioremap(offset, size); > + if (addr) { > + *ptr = addr; > + devres_add(dev, ptr); > + } else > + devres_free(ptr); > + > + return addr; > +} > +EXPORT_SYMBOL(devm_ioremap); > + > +/** > + * devm_ioremap_nocache - Managed ioremap_nocache() > + * @dev: Generic device to remap IO address for > + * @offset: BUS offset to map > + * @size: Size of map > + * > + * Managed ioremap_nocache(). Map is automatically unmapped on driver > + * detach. > + */ > +void __iomem *devm_ioremap_nocache(struct device *dev, unsigned long offset, > + unsigned long size) > +{ > + void __iomem **ptr, *addr; > + > + ptr = devres_alloc(devm_ioremap_release, sizeof(*ptr), GFP_KERNEL); > + if (!ptr) > + return NULL; > + > + addr = ioremap_nocache(offset, size); > + if (addr) { > + *ptr = addr; > + devres_add(dev, ptr); > + } else > + devres_free(ptr); > + > + return addr; > +} > +EXPORT_SYMBOL(devm_ioremap_nocache); A very late comment but nevertheless... :-) Those functions are going to break on 32-bit platforms with extended physical address (well, that's starting with Pentiums which had 36-bit PAE :-) AND devices mapped beyond 4 GB (e.g. PowerPC 44x). You should have used resource_size_t for the 'offset' parameter. As this most probably means that libata is broken on such platforms, I'm going to submit a patch... WBR, Sergei ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 6/13] devres: implement managed iomap interface 2008-04-07 16:46 ` [PATCH 6/13] devres: implement managed iomap interface Sergei Shtylyov @ 2008-04-08 14:48 ` Tejun Heo 2008-04-08 14:55 ` Sergei Shtylyov 0 siblings, 1 reply; 9+ messages in thread From: Tejun Heo @ 2008-04-08 14:48 UTC (permalink / raw) To: Sergei Shtylyov Cc: linuxppc-dev, gregkh, linux-kernel, linux-ide, jgarzik, alan Sergei Shtylyov wrote: > A very late comment but nevertheless... :-) Better late than never. > Those functions are going to break on 32-bit platforms with extended > physical address (well, that's starting with Pentiums which had 36-bit > PAE :-) AND devices mapped beyond 4 GB (e.g. PowerPC 44x). You should > have used resource_size_t for the 'offset' parameter. As this most > probably means that libata is broken on such platforms, I'm going to > submit a patch... Yeah, right please go ahead. But I wonder whether any BIOS was actually crazy enough to map mmio region above 4G on 32bit machine. -- tejun ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 6/13] devres: implement managed iomap interface 2008-04-08 14:48 ` Tejun Heo @ 2008-04-08 14:55 ` Sergei Shtylyov 2008-04-08 15:03 ` Tejun Heo 2008-04-10 16:56 ` Sergei Shtylyov 0 siblings, 2 replies; 9+ messages in thread From: Sergei Shtylyov @ 2008-04-08 14:55 UTC (permalink / raw) To: Tejun Heo; +Cc: linuxppc-dev, gregkh, linux-kernel, linux-ide, jgarzik, alan Tejun Heo wrote: >> A very late comment but nevertheless... :-) > Better late than never. :-) >> Those functions are going to break on 32-bit platforms with >> extended physical address (well, that's starting with Pentiums which >> had 36-bit PAE :-) AND devices mapped beyond 4 GB (e.g. PowerPC 44x). >> You should have used resource_size_t for the 'offset' parameter. As >> this most probably means that libata is broken on such platforms, I'm >> going to submit a patch... It's broken with drivers using MMIO, I meant to say. > Yeah, right please go ahead. But I wonder whether any BIOS was actually > crazy enough to map mmio region above 4G on 32bit machine. This is a *hardware* mapping on some non-x86 platforms (like PPC 44x or MIPS Alchemy). The arch/ppc/ and arch/mips/ kernels have special hooks called from ioremap() which help create an illusion that the PCI memory space on such platforms (not only it) is mapped below 4 GB; arch/powerpc/ kernel doesn't do this anymore -- hence this newly encountered issue. WBR, Sergei ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 6/13] devres: implement managed iomap interface 2008-04-08 14:55 ` Sergei Shtylyov @ 2008-04-08 15:03 ` Tejun Heo 2008-04-10 16:56 ` Sergei Shtylyov 1 sibling, 0 replies; 9+ messages in thread From: Tejun Heo @ 2008-04-08 15:03 UTC (permalink / raw) To: Sergei Shtylyov Cc: linuxppc-dev, gregkh, linux-kernel, linux-ide, jgarzik, alan Sergei Shtylyov wrote: >> Yeah, right please go ahead. But I wonder whether any BIOS was >> actually crazy enough to map mmio region above 4G on 32bit machine. > > This is a *hardware* mapping on some non-x86 platforms (like PPC 44x > or MIPS Alchemy). The arch/ppc/ and arch/mips/ kernels have special > hooks called from ioremap() which help create an illusion that the PCI > memory space on such platforms (not only it) is mapped below 4 GB; > arch/powerpc/ kernel doesn't do this anymore -- hence this newly > encountered issue. Ah... I see. Thanks for the clarification. -- tejun ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 6/13] devres: implement managed iomap interface 2008-04-08 14:55 ` Sergei Shtylyov 2008-04-08 15:03 ` Tejun Heo @ 2008-04-10 16:56 ` Sergei Shtylyov 2008-04-10 17:44 ` Kumar Gala 1 sibling, 1 reply; 9+ messages in thread From: Sergei Shtylyov @ 2008-04-10 16:56 UTC (permalink / raw) To: Tejun Heo; +Cc: linux-ide, gregkh, linux-kernel, linuxppc-dev, jgarzik, alan Hello, I wrote: >>> Those functions are going to break on 32-bit platforms with >>> extended physical address (well, that's starting with Pentiums which >>> had 36-bit PAE :-) AND devices mapped beyond 4 GB (e.g. PowerPC >>> 44x). You should have used resource_size_t for the 'offset' >>> parameter. As this most probably means that libata is broken on such >>> platforms, I'm going to submit a patch... > It's broken with drivers using MMIO, I meant to say. Oops, I meant PCI drivers here, at least for the time being. And it looks like that was a false alarm. :-] >> Yeah, right please go ahead. But I wonder whether any BIOS was >> actually crazy enough to map mmio region above 4G on 32bit machine. > This is a *hardware* mapping on some non-x86 platforms (like PPC 44x > or MIPS Alchemy). The arch/ppc/ and arch/mips/ kernels have special > hooks called from ioremap() which help create an illusion that the PCI > memory space on such platforms (not only it) is mapped below 4 GB; > arch/powerpc/ kernel doesn't do this anymore -- hence this newly > encountered issue. I thought that pcim_iomap() used devm_ioremap() or something -- which of course turned to be wrong. devm_ioremap() alone is yet safe since there are no users for it amongst PPC 44x platform device drivers... MBR, Sergei ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 6/13] devres: implement managed iomap interface 2008-04-10 16:56 ` Sergei Shtylyov @ 2008-04-10 17:44 ` Kumar Gala 2008-04-10 18:24 ` Sergei Shtylyov 0 siblings, 1 reply; 9+ messages in thread From: Kumar Gala @ 2008-04-10 17:44 UTC (permalink / raw) To: Sergei Shtylyov Cc: Tejun Heo, linux-ide, gregkh, linux-kernel, linuxppc-dev, jgarzik, alan On Apr 10, 2008, at 11:56 AM, Sergei Shtylyov wrote: > Hello, I wrote: > >>>> Those functions are going to break on 32-bit platforms with >>>> extended physical address (well, that's starting with Pentiums >>>> which had 36-bit PAE :-) AND devices mapped beyond 4 GB (e.g. >>>> PowerPC 44x). You should have used resource_size_t for the >>>> 'offset' parameter. As this most probably means that libata is >>>> broken on such platforms, I'm going to submit a patch... > >> It's broken with drivers using MMIO, I meant to say. > > Oops, I meant PCI drivers here, at least for the time being. And > it looks like that was a false alarm. :-] > >>> Yeah, right please go ahead. But I wonder whether any BIOS was >>> actually crazy enough to map mmio region above 4G on 32bit machine. > >> This is a *hardware* mapping on some non-x86 platforms (like PPC >> 44x or MIPS Alchemy). The arch/ppc/ and arch/mips/ kernels have >> special hooks called from ioremap() which help create an illusion >> that the PCI memory space on such platforms (not only it) is mapped >> below 4 GB; arch/powerpc/ kernel doesn't do this anymore -- hence >> this newly encountered issue. > > I thought that pcim_iomap() used devm_ioremap() or something -- > which of course turned to be wrong. devm_ioremap() alone is yet safe > since there are no users for it amongst PPC 44x platform device > drivers... but there is no reason not to make it work properly. For example I believe libata uses devm_* and the fsl SATA driver (non-PCI) will need to work in cases similar to the 44x. - k ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 6/13] devres: implement managed iomap interface 2008-04-10 17:44 ` Kumar Gala @ 2008-04-10 18:24 ` Sergei Shtylyov 2008-04-10 19:40 ` Kumar Gala 0 siblings, 1 reply; 9+ messages in thread From: Sergei Shtylyov @ 2008-04-10 18:24 UTC (permalink / raw) To: Kumar Gala Cc: Tejun Heo, linux-ide, gregkh, linux-kernel, linuxppc-dev, jgarzik, alan Kumar Gala wrote: >>>>> Those functions are going to break on 32-bit platforms with >>>>> extended physical address (well, that's starting with Pentiums >>>>> which had 36-bit PAE :-) AND devices mapped beyond 4 GB (e.g. >>>>> PowerPC 44x). You should have used resource_size_t for the >>>>> 'offset' parameter. As this most probably means that libata is >>>>> broken on such platforms, I'm going to submit a patch... >>> It's broken with drivers using MMIO, I meant to say. >> Oops, I meant PCI drivers here, at least for the time being. And it >> looks like that was a false alarm. :-] >>>> Yeah, right please go ahead. But I wonder whether any BIOS was >>>> actually crazy enough to map mmio region above 4G on 32bit machine. >>> This is a *hardware* mapping on some non-x86 platforms (like PPC >>> 44x or MIPS Alchemy). The arch/ppc/ and arch/mips/ kernels have >>> special hooks called from ioremap() which help create an illusion >>> that the PCI memory space on such platforms (not only it) is mapped >>> below 4 GB; arch/powerpc/ kernel doesn't do this anymore -- hence >>> this newly encountered issue. >> I thought that pcim_iomap() used devm_ioremap() or something -- >> which of course turned to be wrong. devm_ioremap() alone is yet safe >> since there are no users for it amongst PPC 44x platform device >> drivers... > but there is no reason not to make it work properly. For example I > believe libata uses devm_* and the fsl SATA driver (non-PCI) will need > to work in cases similar to the 44x. Well, as for sata_fsl, it calls of_iomap() which does The Right Thing. > - k WBR, Sergei ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 6/13] devres: implement managed iomap interface 2008-04-10 18:24 ` Sergei Shtylyov @ 2008-04-10 19:40 ` Kumar Gala 2008-04-11 2:08 ` Tejun Heo 0 siblings, 1 reply; 9+ messages in thread From: Kumar Gala @ 2008-04-10 19:40 UTC (permalink / raw) To: Sergei Shtylyov Cc: Tejun Heo, linux-ide, gregkh, linux-kernel, linuxppc-dev, jgarzik, alan On Apr 10, 2008, at 1:24 PM, Sergei Shtylyov wrote: > Kumar Gala wrote: > >>>>>> Those functions are going to break on 32-bit platforms with >>>>>> extended physical address (well, that's starting with Pentiums >>>>>> which had 36-bit PAE :-) AND devices mapped beyond 4 GB (e.g. >>>>>> PowerPC 44x). You should have used resource_size_t for the >>>>>> 'offset' parameter. As this most probably means that libata is >>>>>> broken on such platforms, I'm going to submit a patch... > >>>> It's broken with drivers using MMIO, I meant to say. > >>> Oops, I meant PCI drivers here, at least for the time being. And >>> it looks like that was a false alarm. :-] > >>>>> Yeah, right please go ahead. But I wonder whether any BIOS was >>>>> actually crazy enough to map mmio region above 4G on 32bit >>>>> machine. > >>>> This is a *hardware* mapping on some non-x86 platforms (like >>>> PPC 44x or MIPS Alchemy). The arch/ppc/ and arch/mips/ kernels >>>> have special hooks called from ioremap() which help create an >>>> illusion that the PCI memory space on such platforms (not only >>>> it) is mapped below 4 GB; arch/powerpc/ kernel doesn't do this >>>> anymore -- hence this newly encountered issue. > >>> I thought that pcim_iomap() used devm_ioremap() or something -- >>> which of course turned to be wrong. devm_ioremap() alone is yet >>> safe since there are no users for it amongst PPC 44x platform >>> device drivers... > >> but there is no reason not to make it work properly. For example >> I believe libata uses devm_* and the fsl SATA driver (non-PCI) >> will need to work in cases similar to the 44x. > > Well, as for sata_fsl, it calls of_iomap() which does The Right > Thing. Fair, but I don't see why we should introduce new APIs that are already "broken". We went through a lot of effort to clean up and introduce resource_t (and clearly still have some bugs) for the >32- bit physical address problem. - k ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 6/13] devres: implement managed iomap interface 2008-04-10 19:40 ` Kumar Gala @ 2008-04-11 2:08 ` Tejun Heo 0 siblings, 0 replies; 9+ messages in thread From: Tejun Heo @ 2008-04-11 2:08 UTC (permalink / raw) To: Kumar Gala; +Cc: linuxppc-dev, gregkh, linux-kernel, linux-ide, jgarzik, alan Kumar Gala wrote: >>> but there is no reason not to make it work properly. For example I >>> believe libata uses devm_* and the fsl SATA driver (non-PCI) will >>> need to work in cases similar to the 44x. >> >> Well, as for sata_fsl, it calls of_iomap() which does The Right Thing. > > Fair, but I don't see why we should introduce new APIs that are already > "broken". We went through a lot of effort to clean up and introduce > resource_t (and clearly still have some bugs) for the >32-bit physical > address problem. Yes, please go ahead. In case it wasn't clear, I wasn't objecting to the fix at all. I was just curious what could actually happen on x86. -- tejun ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2008-04-11 2:08 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <11684073371547-git-send-email-htejun@gmail.com> 2008-04-07 16:46 ` [PATCH 6/13] devres: implement managed iomap interface Sergei Shtylyov 2008-04-08 14:48 ` Tejun Heo 2008-04-08 14:55 ` Sergei Shtylyov 2008-04-08 15:03 ` Tejun Heo 2008-04-10 16:56 ` Sergei Shtylyov 2008-04-10 17:44 ` Kumar Gala 2008-04-10 18:24 ` Sergei Shtylyov 2008-04-10 19:40 ` Kumar Gala 2008-04-11 2:08 ` Tejun Heo
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).