LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* devres and requesting resources
@ 2008-02-29 0:36 Jeff Garzik
2008-02-29 11:26 ` Alan Cox
0 siblings, 1 reply; 10+ messages in thread
From: Jeff Garzik @ 2008-02-29 0:36 UTC (permalink / raw)
To: Tejun Heo; +Cc: Linux IDE mailing list, LKML
Something I just noticed, which I missed during the initial devres review...
The vast majority of my ATA drivers originally called
pci_request_regions(), to reserve all regions attached to a device.
In converting to pcim_iomap_regions(), we no longer reserve /all/
regions, only the ones requested.
This is actually a bug: it was intentional to call
pci_request_regions(), because that ensures that no other software will
use our resources -- even if we are not actively using the resource in
question.
Or IOW, I wanted to ensure that there would be no device sharing...
which this devres conversion accidentally enabled.
The simple fix is obviously to replace pci_request_region() call with
pci_request_regions() in lib/devres.c, but I wonder if that will break
any existing driver?
Jeff
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: devres and requesting resources
2008-02-29 0:36 devres and requesting resources Jeff Garzik
@ 2008-02-29 11:26 ` Alan Cox
2008-02-29 12:11 ` Jeff Garzik
0 siblings, 1 reply; 10+ messages in thread
From: Alan Cox @ 2008-02-29 11:26 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Tejun Heo, Linux IDE mailing list, LKML
> In converting to pcim_iomap_regions(), we no longer reserve /all/
> regions, only the ones requested.
>
> This is actually a bug: it was intentional to call
> pci_request_regions(), because that ensures that no other software will
> use our resources -- even if we are not actively using the resource in
> question.
That would be a bug. We should only reserve the regions we are using. It
is possible that the other regions can be used correctly by another driver
(consider the CS5520 or the MPIIX where the IDE is only part of one
function of the PCI device).
I believe the current code is in fact correct.
> Or IOW, I wanted to ensure that there would be no device sharing...
> which this devres conversion accidentally enabled.
Why ?
> The simple fix is obviously to replace pci_request_region() call with
> pci_request_regions() in lib/devres.c, but I wonder if that will break
> any existing driver?
It would make devres mostly useless especially outside of libata.
Alan
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: devres and requesting resources
2008-02-29 11:26 ` Alan Cox
@ 2008-02-29 12:11 ` Jeff Garzik
2008-02-29 12:28 ` Tejun Heo
2008-02-29 13:55 ` Alan Cox
0 siblings, 2 replies; 10+ messages in thread
From: Jeff Garzik @ 2008-02-29 12:11 UTC (permalink / raw)
To: Alan Cox; +Cc: Tejun Heo, Linux IDE mailing list, LKML
Alan Cox wrote:
>> In converting to pcim_iomap_regions(), we no longer reserve /all/
>> regions, only the ones requested.
>>
>> This is actually a bug: it was intentional to call
>> pci_request_regions(), because that ensures that no other software will
>> use our resources -- even if we are not actively using the resource in
>> question.
>
> That would be a bug. We should only reserve the regions we are using. It
> is possible that the other regions can be used correctly by another driver
> (consider the CS5520 or the MPIIX where the IDE is only part of one
> function of the PCI device).
Only rare PCI devices are shareable among multiple drivers.
sata_* at least intentionally used pci_request_regions() because it is
obvious from the hardware spec that multiple regions accessed by
multiple drivers is highly unlikely, without the driver being
specifically coded to support such sharing. Such sharing code is far
beyond simple resource reservation, to avoid stepping on toes when there
is a single MMIO region and set of interrupt clearing registers.
So reading your email it sounds like there are valid cases for both
configurations.
Its a design choice either way, not a bug either way.
Jeff
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: devres and requesting resources
2008-02-29 12:11 ` Jeff Garzik
@ 2008-02-29 12:28 ` Tejun Heo
2008-02-29 14:01 ` Alan Cox
2008-02-29 13:55 ` Alan Cox
1 sibling, 1 reply; 10+ messages in thread
From: Tejun Heo @ 2008-02-29 12:28 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Alan Cox, Linux IDE mailing list, LKML
Jeff Garzik wrote:
> Only rare PCI devices are shareable among multiple drivers.
>
> sata_* at least intentionally used pci_request_regions() because it is
> obvious from the hardware spec that multiple regions accessed by
> multiple drivers is highly unlikely, without the driver being
> specifically coded to support such sharing. Such sharing code is far
> beyond simple resource reservation, to avoid stepping on toes when there
> is a single MMIO region and set of interrupt clearing registers.
>
> So reading your email it sounds like there are valid cases for both
> configurations.
>
> Its a design choice either way, not a bug either way.
I was thinking like Alan when I was writing pcim_request_regions() but I
agree reserving all the regions does avoid certain problems. Especially
true for controller which duals as native SATA and compatible SFF
controller like ICH AHCIs. ata_generic or ide generic might attach to a
controller which is already being driven by ahci under certain
configurations.
Please note that pcim_request_regions() is a helper to do
pci_request_region() calls and pcim_iomap() in one go. Drivers which
have different requirements can just open code pci_request_regions() and
pcim_iomap(). pcim_request_regions() should provide sensible default
behavior for common cases.
I think the best solution is to allow duplicate request regions for
managed devices which is okay as we know we're holding the resource and
let drivers which need to reserve all regions call pci_request_regions()
before calling pcim_request_regions().
How does it sound?
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: devres and requesting resources
2008-02-29 12:28 ` Tejun Heo
@ 2008-02-29 14:01 ` Alan Cox
2008-02-29 14:17 ` Tejun Heo
2008-02-29 17:04 ` Bartlomiej Zolnierkiewicz
0 siblings, 2 replies; 10+ messages in thread
From: Alan Cox @ 2008-02-29 14:01 UTC (permalink / raw)
To: Tejun Heo; +Cc: Jeff Garzik, Linux IDE mailing list, LKML
> controller like ICH AHCIs. ata_generic or ide generic might attach to a
> controller which is already being driven by ahci under certain
> configurations.
ata_generic will not nor ata_legacy both are much too smart for that. The
legacy old IDE driver might but that probably isn't going to be fixed by
devres and is trivial to fix in that driver (just steal the code from
pata_legacy).
> have different requirements can just open code pci_request_regions() and
> pcim_iomap(). pcim_request_regions() should provide sensible default
> behavior for common cases.
Which is arguably the current behaviour. Changing the behaviour and not
the name is a really bad idea and will cause problems in future so don't
do that.
>
> I think the best solution is to allow duplicate request regions for
> managed devices which is okay as we know we're holding the resource and
> let drivers which need to reserve all regions call pci_request_regions()
> before calling pcim_request_regions().
How about
pcim_request_all_regions()
for the behaviour Jeff wants, simple, direct, differently named and
obvious what it does.
Alan
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: devres and requesting resources
2008-02-29 14:01 ` Alan Cox
@ 2008-02-29 14:17 ` Tejun Heo
2008-02-29 19:25 ` Jeff Garzik
2008-02-29 17:04 ` Bartlomiej Zolnierkiewicz
1 sibling, 1 reply; 10+ messages in thread
From: Tejun Heo @ 2008-02-29 14:17 UTC (permalink / raw)
To: Alan Cox
Cc: Jeff Garzik, Linux IDE mailing list, LKML, Bartlomiej Zolnierkiewicz
Alan Cox wrote:
>> controller like ICH AHCIs. ata_generic or ide generic might attach to a
>> controller which is already being driven by ahci under certain
>> configurations.
>
> ata_generic will not nor ata_legacy both are much too smart for that. The
> legacy old IDE driver might but that probably isn't going to be fixed by
> devres and is trivial to fix in that driver (just steal the code from
> pata_legacy).
Yeah, I saw the behavior with ahci + ide generic combination. I think
it was on SB600. Heh... neat trick in pata_legacy(). Hmm... it's
probably better to do at generic device level and with a generic helper.
>> have different requirements can just open code pci_request_regions() and
>> pcim_iomap(). pcim_request_regions() should provide sensible default
>> behavior for common cases.
>
> Which is arguably the current behaviour. Changing the behaviour and not
> the name is a really bad idea and will cause problems in future so don't
> do that.
>> I think the best solution is to allow duplicate request regions for
>> managed devices which is okay as we know we're holding the resource and
>> let drivers which need to reserve all regions call pci_request_regions()
>> before calling pcim_request_regions().
>
> How about
>
> pcim_request_all_regions()
>
> for the behaviour Jeff wants, simple, direct, differently named and
> obvious what it does.
Sounds good to me. Jeff?
--
tejun
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: devres and requesting resources
2008-02-29 14:17 ` Tejun Heo
@ 2008-02-29 19:25 ` Jeff Garzik
0 siblings, 0 replies; 10+ messages in thread
From: Jeff Garzik @ 2008-02-29 19:25 UTC (permalink / raw)
To: Tejun Heo
Cc: Alan Cox, Linux IDE mailing list, LKML, Bartlomiej Zolnierkiewicz
Tejun Heo wrote:
>> How about
>>
>> pcim_request_all_regions()
>>
>> for the behaviour Jeff wants, simple, direct, differently named and
>> obvious what it does.
>
> Sounds good to me. Jeff?
Fine with me... Naming doesn't really matter to much as simply having
the capability, in one form or another.
Jeff
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: devres and requesting resources
2008-02-29 14:01 ` Alan Cox
2008-02-29 14:17 ` Tejun Heo
@ 2008-02-29 17:04 ` Bartlomiej Zolnierkiewicz
2008-02-29 17:04 ` Alan Cox
1 sibling, 1 reply; 10+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-02-29 17:04 UTC (permalink / raw)
To: Alan Cox; +Cc: Tejun Heo, Jeff Garzik, Linux IDE mailing list, LKML
On Friday 29 February 2008, Alan Cox wrote:
> > controller like ICH AHCIs. ata_generic or ide generic might attach to a
> > controller which is already being driven by ahci under certain
> > configurations.
>
> ata_generic will not nor ata_legacy both are much too smart for that. The
> legacy old IDE driver might but that probably isn't going to be fixed by
> devres and is trivial to fix in that driver (just steal the code from
> pata_legacy).
Yep, nice trick.
Since it is your idea/code could you please also fix ide_generic? :)
> > have different requirements can just open code pci_request_regions() and
> > pcim_iomap(). pcim_request_regions() should provide sensible default
> > behavior for common cases.
>
> Which is arguably the current behaviour. Changing the behaviour and not
> the name is a really bad idea and will cause problems in future so don't
> do that.
> >
> > I think the best solution is to allow duplicate request regions for
> > managed devices which is okay as we know we're holding the resource and
> > let drivers which need to reserve all regions call pci_request_regions()
> > before calling pcim_request_regions().
This will work until code outside libata (i.e. IDE) starts using devres...
[ Incidentally, just yesterday I finished moving resource management handling
to host drivers so it might as well happen. ]
> How about
>
> pcim_request_all_regions()
>
> for the behaviour Jeff wants, simple, direct, differently named and
> obvious what it does.
Seconded.
Thanks,
Bart
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: devres and requesting resources
2008-02-29 17:04 ` Bartlomiej Zolnierkiewicz
@ 2008-02-29 17:04 ` Alan Cox
0 siblings, 0 replies; 10+ messages in thread
From: Alan Cox @ 2008-02-29 17:04 UTC (permalink / raw)
To: Bartlomiej Zolnierkiewicz
Cc: Tejun Heo, Jeff Garzik, Linux IDE mailing list, LKML
> > legacy old IDE driver might but that probably isn't going to be fixed by
> > devres and is trivial to fix in that driver (just steal the code from
> > pata_legacy).
>
> Yep, nice trick.
>
> Since it is your idea/code could you please also fix ide_generic? :)
In my copious free time - ask me around August ;)
Alan
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: devres and requesting resources
2008-02-29 12:11 ` Jeff Garzik
2008-02-29 12:28 ` Tejun Heo
@ 2008-02-29 13:55 ` Alan Cox
1 sibling, 0 replies; 10+ messages in thread
From: Alan Cox @ 2008-02-29 13:55 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Tejun Heo, Linux IDE mailing list, LKML
> Only rare PCI devices are shareable among multiple drivers.
Really. Let me see
AGP & EDAC
Serial/Parallel combo ports
MPIIX
CS5520
Lots of I2C bus stuff
VGA v 3D
There are quite a few, and some are already quite fun enough with our pci
struct model.
> sata_* at least intentionally used pci_request_regions() because it is
> obvious from the hardware spec that multiple regions accessed by
> multiple drivers is highly unlikely, without the driver being
> specifically coded to support such sharing. Such sharing code is far
> beyond simple resource reservation, to avoid stepping on toes when there
> is a single MMIO region and set of interrupt clearing registers.
>
> So reading your email it sounds like there are valid cases for both
> configurations.
>
> Its a design choice either way, not a bug either way.
It is a flaw: devres that assumes it should grab all resources is unusable
for some other drivers - it is no longer generic and that makes it far
less useful. I've got no problem with the idea of a devres way to say
"and I want it all, mine mine mine" but that should not be the only
behaviour.
Alan
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2008-02-29 19:25 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-29 0:36 devres and requesting resources Jeff Garzik
2008-02-29 11:26 ` Alan Cox
2008-02-29 12:11 ` Jeff Garzik
2008-02-29 12:28 ` Tejun Heo
2008-02-29 14:01 ` Alan Cox
2008-02-29 14:17 ` Tejun Heo
2008-02-29 19:25 ` Jeff Garzik
2008-02-29 17:04 ` Bartlomiej Zolnierkiewicz
2008-02-29 17:04 ` Alan Cox
2008-02-29 13:55 ` Alan Cox
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).