pci_alloc_resource patch

From: Barney Cordoba <barney_cordoba_at_yahoo.com>
Date: Sun, 5 Apr 2009 05:01:17 -0700 (PDT)
--- On Wed, 4/1/09, Peter Jeremy <peterjeremy_at_optushome.com.au> wrote:

> From: Peter Jeremy <peterjeremy_at_optushome.com.au>
> Subject: Re: pci_alloc_resource is broken
> To: "Barney Cordoba" <barney_cordoba_at_yahoo.com>
> Cc: "John Baldwin" <jhb_at_freebsd.org>, freebsd-current_at_freebsd.org
> Date: Wednesday, April 1, 2009, 2:54 AM
> On 2009-Mar-31 10:55:26 -0700, Barney Cordoba
> <barney_cordoba_at_yahoo.com> wrote:
> >Its really you who is being condescending.
> 
> You _really_ need to learn some manners.  Despite your
> goading,
> John has remained polite and helpful.
> 
> >in business for 20 years with 3000 active customers
> that
> 
> Given your attitude, I'm surprised you have _any_
> customers.
> I presume you have other minions who actually interact with
> them.
> 
> > If you were Bill Gates
> >I'd accept that. But you're a programmer.
> 
> More insults.  BTW, I suspect Bill Gates considers himself
> a
> programmer - he used to be a fairly good one.


Bill Gates is a successful businessman. John Baldwin is not. So his
"advice" about what is commercially acceptable has zero value. I'm
sorry if that went over your head.



> 
> >Now is a resource in use a "fatal" system
> error? 
> 
> That depends on the resource but, possibly, yes.
> 
> >Face it please. You replaced one bug with another. If
> you spent half the
> >effort doing it correctly as you are spending defending
> what you've done
> >we'd all be a lot happier.
> 
> If you spent as much time helping the project by providing
> patches or
> constructive input as you do insulting the developers,
> we'd all be a
> lot happier.
> 
> -- 
> Peter Jeremy

If the developer's fragile egos won't allow them to admit that their
code is wrong or deficient, then whats the point of spending my time
doing PRs or submitting patches? John believes that the OS is his 
personal toy and that putting panics into his code is a good thing. If
you can't get him to admit that his coding philosophy is part of the
problem, then you have no chance of fixing it with a PR.


So Peter, I assume you agree that the panic in pci_alloc_resource()
is appropriate instead of the expected NULL return? Or are you just
blindly bloviating for your friend? 

Here's your fix. Now a driver that attempts to re-allocate a busy resource
gets a nice "Unable to allocate bus resource: memory" message instead of
a system panic. The way a good OS is supposed to work. I really
don't have time to do PRs so you can do it yourself.

3539,3540d3538
< 
< 
3594,3595c3592,3599
< 		if (rle != NULL && rle->res != NULL &&
< 		    rman_get_device(rle->res) == dev) {
---
> 		if (rle != NULL && rle->res != NULL){
> 			if (rman_get_device(rle->res) != dev){
> 				if (bootverbose){
> 					device_printf(child,
> 			    			"pci_alloc_resource: resource busy\n");
> 				}
> 				return(NULL);
> 			}
 

Barney


      
Received on Sun Apr 05 2009 - 10:01:18 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:45 UTC