Message ID | 11281928.0BBlrNprhI@vostro.rjw.lan (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
On Mon, Nov 12, 2012 at 01:02:11PM +0100, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > Currently, whoever wants to use ACPI device resources has to call > acpi_walk_resources() to browse the buffer returned by the _CRS > method for the given device and create filters passed to that > routine to apply to the individual resource items. This generally > is cumbersome, time-consuming and inefficient. Moreover, it may > be problematic if resource conflicts need to be resolved, because > the different users of _CRS will need to do that in a consistent > way. > > For this reason, add code to the ACPI core to execute _CRS once, > when the struct acpi_device object is created for a given device > node, and attach a list of ACPI resources returned by _CRS to that > object for future processing. > > Convert the ACPI code that creates platform device objects to using > the new resources list instead of executing acpi_walk_resources() by > itself, which makes it much more straightforward and easier to > follow. > > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > --- > drivers/acpi/acpi_platform.c | 90 ++++++++++++------------------------------- > drivers/acpi/resource.c | 12 +++++ > drivers/acpi/scan.c | 56 ++++++++++++++++++++++++++ > include/acpi/acpi_bus.h | 6 ++ > include/linux/acpi.h | 1 > 5 files changed, 102 insertions(+), 63 deletions(-) > > Index: linux/include/acpi/acpi_bus.h > =================================================================== > --- linux.orig/include/acpi/acpi_bus.h > +++ linux/include/acpi/acpi_bus.h > @@ -259,6 +259,11 @@ struct acpi_device_physical_node { > struct device *dev; > }; > > +struct acpi_resource_list_entry { > + struct list_head node; > + struct acpi_resource resource; > +}; > + > /* set maximum of physical nodes to 32 for expansibility */ > #define ACPI_MAX_PHYSICAL_NODE 32 > > @@ -268,6 +273,7 @@ struct acpi_device { > acpi_handle handle; /* no handle for fixed hardware */ > struct acpi_device *parent; > struct list_head children; > + struct list_head resources; /* Device resources. */ > struct list_head node; > struct list_head wakeup_list; > struct acpi_device_status status; > Index: linux/drivers/acpi/scan.c > =================================================================== > --- linux.orig/drivers/acpi/scan.c > +++ linux/drivers/acpi/scan.c > @@ -382,6 +382,52 @@ static void acpi_device_remove_files(str > ACPI Bus operations > -------------------------------------------------------------------------- */ > > +static void acpi_bus_drop_resources(struct acpi_device *adev) > +{ > + struct acpi_resource_list_entry *entry, *s; > + > + list_for_each_entry_safe(entry, s, &adev->resources, node) { > + list_del(&entry->node); > + kfree(entry); > + } > +} > + > +static acpi_status acpi_bus_add_resource(struct acpi_resource *res, > + void *context) > +{ > + struct list_head *list = context; > + struct acpi_resource_list_entry *entry; > + > + entry = kzalloc(sizeof(*entry), GFP_KERNEL); > + if (!entry) > + return AE_NO_MEMORY; > + > + entry->resource = *res; This does not work well with all resource types - specifically those that contain pointers, like acpi_resource_gpio and acpi_resource_source. The memory for the resources gets freed once acpi_walk_resources() is done. > + INIT_LIST_HEAD(&entry->node); > + list_add_tail(&entry->node, list); > + return AE_OK; > +} -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Monday, November 12, 2012 04:46:21 PM Mika Westerberg wrote: > On Mon, Nov 12, 2012 at 01:02:11PM +0100, Rafael J. Wysocki wrote: > > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > > > Currently, whoever wants to use ACPI device resources has to call > > acpi_walk_resources() to browse the buffer returned by the _CRS > > method for the given device and create filters passed to that > > routine to apply to the individual resource items. This generally > > is cumbersome, time-consuming and inefficient. Moreover, it may > > be problematic if resource conflicts need to be resolved, because > > the different users of _CRS will need to do that in a consistent > > way. > > > > For this reason, add code to the ACPI core to execute _CRS once, > > when the struct acpi_device object is created for a given device > > node, and attach a list of ACPI resources returned by _CRS to that > > object for future processing. > > > > Convert the ACPI code that creates platform device objects to using > > the new resources list instead of executing acpi_walk_resources() by > > itself, which makes it much more straightforward and easier to > > follow. > > > > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > --- > > drivers/acpi/acpi_platform.c | 90 ++++++++++++------------------------------- > > drivers/acpi/resource.c | 12 +++++ > > drivers/acpi/scan.c | 56 ++++++++++++++++++++++++++ > > include/acpi/acpi_bus.h | 6 ++ > > include/linux/acpi.h | 1 > > 5 files changed, 102 insertions(+), 63 deletions(-) > > > > Index: linux/include/acpi/acpi_bus.h > > =================================================================== > > --- linux.orig/include/acpi/acpi_bus.h > > +++ linux/include/acpi/acpi_bus.h > > @@ -259,6 +259,11 @@ struct acpi_device_physical_node { > > struct device *dev; > > }; > > > > +struct acpi_resource_list_entry { > > + struct list_head node; > > + struct acpi_resource resource; > > +}; > > + > > /* set maximum of physical nodes to 32 for expansibility */ > > #define ACPI_MAX_PHYSICAL_NODE 32 > > > > @@ -268,6 +273,7 @@ struct acpi_device { > > acpi_handle handle; /* no handle for fixed hardware */ > > struct acpi_device *parent; > > struct list_head children; > > + struct list_head resources; /* Device resources. */ > > struct list_head node; > > struct list_head wakeup_list; > > struct acpi_device_status status; > > Index: linux/drivers/acpi/scan.c > > =================================================================== > > --- linux.orig/drivers/acpi/scan.c > > +++ linux/drivers/acpi/scan.c > > @@ -382,6 +382,52 @@ static void acpi_device_remove_files(str > > ACPI Bus operations > > -------------------------------------------------------------------------- */ > > > > +static void acpi_bus_drop_resources(struct acpi_device *adev) > > +{ > > + struct acpi_resource_list_entry *entry, *s; > > + > > + list_for_each_entry_safe(entry, s, &adev->resources, node) { > > + list_del(&entry->node); > > + kfree(entry); > > + } > > +} > > + > > +static acpi_status acpi_bus_add_resource(struct acpi_resource *res, > > + void *context) > > +{ > > + struct list_head *list = context; > > + struct acpi_resource_list_entry *entry; > > + > > + entry = kzalloc(sizeof(*entry), GFP_KERNEL); > > + if (!entry) > > + return AE_NO_MEMORY; > > + > > + entry->resource = *res; > > This does not work well with all resource types - specifically those that > contain pointers, like acpi_resource_gpio and acpi_resource_source. Good point. Well, this pretty much means we can't copy those things. > The memory for the resources gets freed once acpi_walk_resources() is done. I know that. Having to evaluate _CRS and creating a buffer, converting the output into ACPI resources and so on every time we need to look into the device's current resources is totally inefficient. We _need_ to cache the _CRS output. Now, because of the pointers in certain types of resources, we can't make copies of the resource objects used by acpi_walk_resources() which makes that function totally unuseful to us. I suppose we can just do acpi_get_current_resources() and play with the buffer returned by it. That won't be nice, but still better than what we have. Thanks, Rafael
On Mon, Nov 12, 2012 at 10:03:56PM +0100, Rafael J. Wysocki wrote: > > > +static acpi_status acpi_bus_add_resource(struct acpi_resource *res, > > > + void *context) > > > +{ > > > + struct list_head *list = context; > > > + struct acpi_resource_list_entry *entry; > > > + > > > + entry = kzalloc(sizeof(*entry), GFP_KERNEL); > > > + if (!entry) > > > + return AE_NO_MEMORY; > > > + > > > + entry->resource = *res; > > > > This does not work well with all resource types - specifically those that > > contain pointers, like acpi_resource_gpio and acpi_resource_source. > > Good point. > > Well, this pretty much means we can't copy those things. Yeah. I only noticed this yesterday when I tested the GPIO translation in a custom driver (since it uses the acpi_resource_gpio). > > The memory for the resources gets freed once acpi_walk_resources() is done. > > I know that. > > Having to evaluate _CRS and creating a buffer, converting the output into > ACPI resources and so on every time we need to look into the device's current > resources is totally inefficient. We _need_ to cache the _CRS output. I agree and besides having adev->resources is much easier to use than calling acpi_walk_resources() everytime. > Now, because of the pointers in certain types of resources, we can't > make copies of the resource objects used by acpi_walk_resources() which > makes that function totally unuseful to us. > > I suppose we can just do acpi_get_current_resources() and play with the > buffer returned by it. That won't be nice, but still better than what we > have. I don't know any better option. Thanks. -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
> I suppose we can just do acpi_get_current_resources() and play with > the buffer returned by it. That won't be nice, but still better than > what we have. A couple of the reasons we created the ACPICA resource manager was to: 1) Simplify host access to the various resource fields, especially packed flags. 2) Avoid alignment issues, especially on machines that don't support misaligned transfers. If there are issues with the current resource manager, we can discuss them. But I would hope that you really don't want to be fussing around with the raw data coming back from the AML. It is not pretty and we have gone to some lengths to make the entire conversion table-driven to minimize bugs and simplify maintenance. Bob > -----Original Message----- > From: Mika Westerberg [mailto:mika.westerberg@linux.intel.com] > Sent: Monday, November 12, 2012 11:12 PM > To: Rafael J. Wysocki > Cc: mathias.nyman@linux.intel.com; linux-acpi@vger.kernel.org; linux- > kernel@vger.kernel.org; lenb@kernel.org; Wysocki, Rafael J; > broonie@opensource.wolfsonmicro.com; grant.likely@secretlab.ca; > linus.walleij@linaro.org; khali@linux-fr.org; Bjorn Helgaas; Moore, Robert > Subject: Re: [PATCH 3/3] ACPI: Evaluate _CRS while creating device node > objects > > On Mon, Nov 12, 2012 at 10:03:56PM +0100, Rafael J. Wysocki wrote: > > > > +static acpi_status acpi_bus_add_resource(struct acpi_resource *res, > > > > + void *context) > > > > +{ > > > > + struct list_head *list = context; > > > > + struct acpi_resource_list_entry *entry; > > > > + > > > > + entry = kzalloc(sizeof(*entry), GFP_KERNEL); > > > > + if (!entry) > > > > + return AE_NO_MEMORY; > > > > + > > > > + entry->resource = *res; > > > > > > This does not work well with all resource types - specifically those > > > that contain pointers, like acpi_resource_gpio and > acpi_resource_source. > > > > Good point. > > > > Well, this pretty much means we can't copy those things. > > Yeah. I only noticed this yesterday when I tested the GPIO translation in > a custom driver (since it uses the acpi_resource_gpio). > > > > The memory for the resources gets freed once acpi_walk_resources() is > done. > > > > I know that. > > > > Having to evaluate _CRS and creating a buffer, converting the output > > into ACPI resources and so on every time we need to look into the > > device's current resources is totally inefficient. We _need_ to cache > the _CRS output. > > I agree and besides having adev->resources is much easier to use than > calling acpi_walk_resources() everytime. > > > Now, because of the pointers in certain types of resources, we can't > > make copies of the resource objects used by acpi_walk_resources() > > which makes that function totally unuseful to us. > > > > I suppose we can just do acpi_get_current_resources() and play with > > the buffer returned by it. That won't be nice, but still better than > > what we have. > > I don't know any better option. > > Thanks. -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tuesday, November 13, 2012 04:34:07 PM Moore, Robert wrote: > > I suppose we can just do acpi_get_current_resources() and play with > > the buffer returned by it. That won't be nice, but still better than > > what we have. > > A couple of the reasons we created the ACPICA resource manager was to: > 1) Simplify host access to the various resource fields, especially packed flags. > 2) Avoid alignment issues, especially on machines that don't support misaligned transfers. That's fine. > If there are issues with the current resource manager, we can discuss them. > But I would hope that you really don't want to be fussing around with the raw > data coming back from the AML. No, I don't. :-) I'd like to be able to do more things with struct acpi_resource objects. Pretty much the output of acpi_get_current_resources() is what I'm interested in, but there doesn't seem to be any convenient way to access things in the return buffer from the outside of ACPICA now. > It is not pretty and we have gone to some lengths to make the entire > conversion table-driven to minimize bugs and simplify maintenance. OK So what I would like to have, in general terms, is something like acpi_walk_resources() split into three parts: (1) One that processes the _CRS output and creates a list of struct acpi_resource objects for us to play with. I suppose it's OK if that's just a buffer filled with resource objects, but a linked list might be more convenient. (2) One that allows us to access (read/write) resources in the list returned by (1). We don't need to open code walking the list and I probably wouldn't event want to do that. What we need is to be able to walk the same list for a number of times and possibly to modify values in the resource objects if there are conflicts. (3) One allowing us to free the list returned by (1) if not needed any more. And it would be great if we could take the list returned by (1), modify the resources in it and feed it back to _SRS (after conversion back to the format that _SRS understands). Thanks, Rafael > > -----Original Message----- > > From: Mika Westerberg [mailto:mika.westerberg@linux.intel.com] > > Sent: Monday, November 12, 2012 11:12 PM > > To: Rafael J. Wysocki > > Cc: mathias.nyman@linux.intel.com; linux-acpi@vger.kernel.org; linux- > > kernel@vger.kernel.org; lenb@kernel.org; Wysocki, Rafael J; > > broonie@opensource.wolfsonmicro.com; grant.likely@secretlab.ca; > > linus.walleij@linaro.org; khali@linux-fr.org; Bjorn Helgaas; Moore, Robert > > Subject: Re: [PATCH 3/3] ACPI: Evaluate _CRS while creating device node > > objects > > > > On Mon, Nov 12, 2012 at 10:03:56PM +0100, Rafael J. Wysocki wrote: > > > > > +static acpi_status acpi_bus_add_resource(struct acpi_resource *res, > > > > > + void *context) > > > > > +{ > > > > > + struct list_head *list = context; > > > > > + struct acpi_resource_list_entry *entry; > > > > > + > > > > > + entry = kzalloc(sizeof(*entry), GFP_KERNEL); > > > > > + if (!entry) > > > > > + return AE_NO_MEMORY; > > > > > + > > > > > + entry->resource = *res; > > > > > > > > This does not work well with all resource types - specifically those > > > > that contain pointers, like acpi_resource_gpio and > > acpi_resource_source. > > > > > > Good point. > > > > > > Well, this pretty much means we can't copy those things. > > > > Yeah. I only noticed this yesterday when I tested the GPIO translation in > > a custom driver (since it uses the acpi_resource_gpio). > > > > > > The memory for the resources gets freed once acpi_walk_resources() is > > done. > > > > > > I know that. > > > > > > Having to evaluate _CRS and creating a buffer, converting the output > > > into ACPI resources and so on every time we need to look into the > > > device's current resources is totally inefficient. We _need_ to cache > > the _CRS output. > > > > I agree and besides having adev->resources is much easier to use than > > calling acpi_walk_resources() everytime. > > > > > Now, because of the pointers in certain types of resources, we can't > > > make copies of the resource objects used by acpi_walk_resources() > > > which makes that function totally unuseful to us. > > > > > > I suppose we can just do acpi_get_current_resources() and play with > > > the buffer returned by it. That won't be nice, but still better than > > > what we have. > > > > I don't know any better option. > > > > Thanks. >
SSBtYXkgbm90IHF1aXRlIHVuZGVyc3RhbmQgd2hhdCB5b3UgYXJlIGFza2luZyBmb3IsIGJ1dCBJ IHdpbGwgdHJ5LiBJdCBzZWVtcyBsaWtlIHdlIGFscmVhZHkgaGF2ZSBtdWNoIG9mIHdoYXQgeW91 IHdhbnQvbmVlZCwgc28gbWF5YmUgSSdtIG1pc3Npbmcgc29tZXRoaW5nLg0KDQoNCg0KPiBTbyB3 aGF0IEkgd291bGQgbGlrZSB0byBoYXZlLCBpbiBnZW5lcmFsIHRlcm1zLCBpcyBzb21ldGhpbmcg bGlrZQ0KPiBhY3BpX3dhbGtfcmVzb3VyY2VzKCkgc3BsaXQgaW50byB0aHJlZSBwYXJ0czoNCj4g DQo+ICAoMSkgT25lIHRoYXQgcHJvY2Vzc2VzIHRoZSBfQ1JTIG91dHB1dCBhbmQgY3JlYXRlcyBh IGxpc3Qgb2YNCj4gICAgICBzdHJ1Y3QgYWNwaV9yZXNvdX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rbm93IGFueSBiZXR0ZXIgb3B0 aW9uLg0KPiA+ID4NCj4gPiA+IFRoYW5rcy4NCj4gPg0KPiAtLQ0KPiBJIHNwZWFrIG9ubHkgZm9y IG15c2VsZi4NCj4gUmFmYWVsIEouIFd5c29ja2ksIEludGVsIE9wZW4gU291cmNlIFRlY2hub2xv Z3kgQ2VudGVyLg0K -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tuesday, November 13, 2012 10:06:03 PM Moore, Robert wrote: > I may not quite understand what you are asking for, but I will try. > It seems like we already have much of what you want/need, so maybe > I'm missing something. I think all of the necessary pieces are there. > > So what I would like to have, in general terms, is something like > > acpi_walk_resources() split into three parts: > > > > (1) One that processes the _CRS output and creates a list of > > struct acpi_resource objects for us to play with. I suppose > > it's OK if that's just a buffer filled with resource objects, > > but a linked list might be more convenient. > > > > This sounds like AcpiGetCurrentResources. It executes _CRS and formats > the data into acpi_resource objects. Yes, it does. However, it is not completely clear to me if/how the caller is supposed to prepare the buffer object pointed to by the second arg. If the buffer is initialized by AcpiGetCurrentResources, then that's what I need for (1). > > (2) One that allows us to access (read/write) resources in the > > list returned by (1). We don't need to open code walking > > the list and I probably wouldn't event want to do that. What > > we need is to be able to walk the same list for a number of > > times and possibly to modify values in the resource objects > > if there are conflicts. > > This sounds like AcpiWalkResources. I suppose a possible issue is that > currently, AcpiWalkResources actually invokes the _CRS, _PRS, or _AEI > method on behalf of the caller. Yes, that exactly is the problem. > It might make more sense to allow the caller to pass in the resource buffer > returned from a call to _CRS, etc. Yes! :-) > > > > (3) One allowing us to free the list returned by (1) if not needed > > any more. > > > > AcpiGetCurrentResources: Currently, everything is returned in a single buffer > to minimize the number of allocations. A buffer you can free when you are > done with it. I suppose I should use ACPI_FREE(buffer.pointer) for that, but isn't it for the ACPICA's internal use only? Besides, I would prefer to be able to pass just "buffer" for freeing, without having to touch its internals. No big deal, but it would be nicer. :-) > I think I saw where you mentioned that you cannot copy this buffer because > of internal pointers to other areas of the buffer. Yes. However, we can build > linked lists all day if you really want them :-) I really won't care if I can pass a resource buffer to a "walker" routine. :-) > > And it would be great if we could take the list returned by (1), modify > > the resources in it and feed it back to _SRS (after conversion back to the > > format that _SRS understands). > > > > AcpiSetCurrentResources. > > The AML debugger already has a command that illustrates the use of the > various resource interfaces, see dbcmds.c I will. Thanks, Rafael
UmFmYWVsLA0KDQpJIHNvdW5kcyBsaWtlIHdpdGggYSBmZXcgY2hhbmdlcywgd2UgY2FuIGVuaGFu Y2UgdGhpcyBtZWNoYW5pc20gdG8gYmUgbW9yZSB1c2VmdWwgdG8geW91IGFuZCBvdGhlcnMuIFNv bWUgY29tbWVudHMgYmVsb3cuIEkgbmVlZCB0byBsb29rIGF0IHRoZSBjb2RlIGluIHF1ZXN0aW9u IGEgYml0IG1vcmUsIGJ1dCBJIHNlZSBubyBpbnN1cm1vdW50YWJsZSBpc3N1ZXMuDQoNCkJvYg0K DQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogUmFmYWVsIEouIFd5c29j a2kgW21haWx0bzpyandAc2lzay5wbF0NCj4gU2VudDogVHVlc2RheSwgTm92ZW1iZXIgMTMsIDIw MTIgMjo1NyBQTQ0KPiBUbzogTW9vcmUsIFJvYmVydA0KPiBDYzogTWlrYSBXZXN0ZXJiZXJnOyBt YXRoaWFzLm55bWFuQGxpbnV4LmludGVsLmNvbTsgbGludXgtDQo+IGFjcGlAdmdlci5rZXJuZWwu b3JnOyBsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnOyBsZW5iQGtlcm5lbC5vcmc7DQo+IFd5 c29ja2ksIFJhZmFlbCBKOyBicm9vbmllQG9wZW5zb3VyY2Uud29sZnNvbm1pY3JvLmNvbTsNCj4g Z3JhbnQubGlrZWx5QHNlY3JldGxhYi5jYTsgbGludXMud2FsbGVpakBsaW5hcm8ub3JnOyBraGFs aUBsaW51eC1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4gPg0KPiA+IFRo ZSBBTUwgZGVidWdnZXIgYWxyZWFkeSBoYXMgYSBjb21tYW5kIHRoYXQgaWxsdXN0cmF0ZXMgdGhl IHVzZSBvZiB0aGUNCj4gPiB2YXJpb3VzIHJlc291cmNlIGludGVyZmFjZXMsIHNlZSBkYmNtZHMu Yw0KPiANCj4gSSB3aWxsLg0KPiANCj4gVGhhbmtzLA0KPiBSYWZhZWwNCj4gDQo+IA0KPiAtLQ0K PiBJIHNwZWFrIG9ubHkgZm9yIG15c2VsZi4NCj4gUmFmYWVsIEouIFd5c29ja2ksIEludGVsIE9w ZW4gU291cmNlIFRlY2hub2xvZ3kgQ2VudGVyLg0K -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wednesday, November 14, 2012 02:23:51 AM Moore, Robert wrote: > Rafael, > > I sounds like with a few changes, we can enhance this mechanism to > be more useful to you and others. Some comments below. I need to look > at the code in question a bit more, but I see no insurmountable issues. Great, thanks! > > -----Original Message----- > > From: Rafael J. Wysocki [mailto:rjw@sisk.pl] > > Sent: Tuesday, November 13, 2012 2:57 PM > > To: Moore, Robert > > Cc: Mika Westerberg; mathias.nyman@linux.intel.com; linux- > > acpi@vger.kernel.org; linux-kernel@vger.kernel.org; lenb@kernel.org; > > Wysocki, Rafael J; broonie@opensource.wolfsonmicro.com; > > grant.likely@secretlab.ca; linus.walleij@linaro.org; khali@linux-fr.org; > > Bjorn Helgaas; Zheng, Lv > > Subject: Re: [PATCH 3/3] ACPI: Evaluate _CRS while creating device node > > objects > > > > On Tuesday, November 13, 2012 10:06:03 PM Moore, Robert wrote: > > > I may not quite understand what you are asking for, but I will try. > > > It seems like we already have much of what you want/need, so maybe I'm > > > missing something. > > > > I think all of the necessary pieces are there. > > > > > > So what I would like to have, in general terms, is something like > > > > acpi_walk_resources() split into three parts: > > > > > > > > (1) One that processes the _CRS output and creates a list of > > > > struct acpi_resource objects for us to play with. I suppose > > > > it's OK if that's just a buffer filled with resource objects, > > > > but a linked list might be more convenient. > > > > > > > > > > This sounds like AcpiGetCurrentResources. It executes _CRS and formats > > > the data into acpi_resource objects. > > > > Yes, it does. However, it is not completely clear to me if/how the caller > > is supposed to prepare the buffer object pointed to by the second arg. > > > > If the buffer is initialized by AcpiGetCurrentResources, then that's what > > I need for (1). > > > It looks to me that at least AcpiGetCurrentResources does not actually ever > allocate a buffer for the resource template, it expects the caller to > eventually provide one of at least the size of the returned resource template. > > This is really quite a bit out-of-date as far as the memory allocation model. > It should also support the option to just allocate the buffer of the appropriate > size before returning it to the caller. Yes, that would be really useful. Ideally, I'd like to be able to pass a pointer to an uninitialized buffer structure to it (or to a wrapper around it) and get a buffer full of struct acpi_resource objects (if _CRS returns any) back from it. :-) > > > > (2) One that allows us to access (read/write) resources in the > > > > list returned by (1). We don't need to open code walking > > > > the list and I probably wouldn't event want to do that. What > > > > we need is to be able to walk the same list for a number of > > > > times and possibly to modify values in the resource objects > > > > if there are conflicts. > > > > > > This sounds like AcpiWalkResources. I suppose a possible issue is that > > > currently, AcpiWalkResources actually invokes the _CRS, _PRS, or _AEI > > > method on behalf of the caller. > > > > Yes, that exactly is the problem. > > > > > It might make more sense to allow the caller to pass in the resource > > > buffer returned from a call to _CRS, etc. > > > > Yes! :-) > > > I'll take a closer look at this tomorrow. Cool, thanks! > > > > (3) One allowing us to free the list returned by (1) if not needed > > > > any more. > > > > > > > > > > AcpiGetCurrentResources: Currently, everything is returned in a single > > > buffer to minimize the number of allocations. A buffer you can free > > > when you are done with it. > > > > I suppose I should use ACPI_FREE(buffer.pointer) for that, but isn't it > > for the ACPICA's internal use only? > > > > Besides, I would prefer to be able to pass just "buffer" for freeing, > > without having to touch its internals. No big deal, but it would be > > nicer. :-) > > > The ACPI_BUFFER type is in fact a public type that is meant to return both the > buffer and the (actual) length. You will find many instances of > ACPI_FREE(buffer.pointer) within existing linux code, since it also used for > objects returned by control method execution/object evaluation. Well, I suppose I only wanted to say that acpi_free_buffer(buffer) would look a bit more straightforward than ACPI_FREE(buffer.pointer). :-) Thanks, Rafael
On Wednesday, November 14, 2012 10:18:46 AM Rafael J. Wysocki wrote: > On Wednesday, November 14, 2012 02:23:51 AM Moore, Robert wrote: > > Rafael, > > > > I sounds like with a few changes, we can enhance this mechanism to > > be more useful to you and others. Some comments below. I need to look > > at the code in question a bit more, but I see no insurmountable issues. > > Great, thanks! > > > > > -----Original Message----- > > > From: Rafael J. Wysocki [mailto:rjw@sisk.pl] > > > Sent: Tuesday, November 13, 2012 2:57 PM > > > To: Moore, Robert > > > Cc: Mika Westerberg; mathias.nyman@linux.intel.com; linux- > > > acpi@vger.kernel.org; linux-kernel@vger.kernel.org; lenb@kernel.org; > > > Wysocki, Rafael J; broonie@opensource.wolfsonmicro.com; > > > grant.likely@secretlab.ca; linus.walleij@linaro.org; khali@linux-fr.org; > > > Bjorn Helgaas; Zheng, Lv > > > Subject: Re: [PATCH 3/3] ACPI: Evaluate _CRS while creating device node > > > objects > > > > > > On Tuesday, November 13, 2012 10:06:03 PM Moore, Robert wrote: > > > > I may not quite understand what you are asking for, but I will try. > > > > It seems like we already have much of what you want/need, so maybe I'm > > > > missing something. > > > > > > I think all of the necessary pieces are there. > > > > > > > > So what I would like to have, in general terms, is something like > > > > > acpi_walk_resources() split into three parts: > > > > > > > > > > (1) One that processes the _CRS output and creates a list of > > > > > struct acpi_resource objects for us to play with. I suppose > > > > > it's OK if that's just a buffer filled with resource objects, > > > > > but a linked list might be more convenient. > > > > > > > > > > > > > This sounds like AcpiGetCurrentResources. It executes _CRS and formats > > > > the data into acpi_resource objects. > > > > > > Yes, it does. However, it is not completely clear to me if/how the caller > > > is supposed to prepare the buffer object pointed to by the second arg. > > > > > > If the buffer is initialized by AcpiGetCurrentResources, then that's what > > > I need for (1). > > > > > > It looks to me that at least AcpiGetCurrentResources does not actually ever > > allocate a buffer for the resource template, it expects the caller to > > eventually provide one of at least the size of the returned resource template. > > > > This is really quite a bit out-of-date as far as the memory allocation model. > > It should also support the option to just allocate the buffer of the appropriate > > size before returning it to the caller. > > Yes, that would be really useful. > > Ideally, I'd like to be able to pass a pointer to an uninitialized buffer > structure to it (or to a wrapper around it) and get a buffer full of > struct acpi_resource objects (if _CRS returns any) back from it. :-) Of course, I can add such a wrapper in the Linux-specific code just fine. > > > > > (2) One that allows us to access (read/write) resources in the > > > > > list returned by (1). We don't need to open code walking > > > > > the list and I probably wouldn't event want to do that. What > > > > > we need is to be able to walk the same list for a number of > > > > > times and possibly to modify values in the resource objects > > > > > if there are conflicts. > > > > > > > > This sounds like AcpiWalkResources. I suppose a possible issue is that > > > > currently, AcpiWalkResources actually invokes the _CRS, _PRS, or _AEI > > > > method on behalf of the caller. > > > > > > Yes, that exactly is the problem. > > > > > > > It might make more sense to allow the caller to pass in the resource > > > > buffer returned from a call to _CRS, etc. > > > > > > Yes! :-) > > > > > > I'll take a closer look at this tomorrow. > > Cool, thanks! > > > > > > > (3) One allowing us to free the list returned by (1) if not needed > > > > > any more. > > > > > > > > > > > > > AcpiGetCurrentResources: Currently, everything is returned in a single > > > > buffer to minimize the number of allocations. A buffer you can free > > > > when you are done with it. > > > > > > I suppose I should use ACPI_FREE(buffer.pointer) for that, but isn't it > > > for the ACPICA's internal use only? > > > > > > Besides, I would prefer to be able to pass just "buffer" for freeing, > > > without having to touch its internals. No big deal, but it would be > > > nicer. :-) > > > > > > The ACPI_BUFFER type is in fact a public type that is meant to return both the > > buffer and the (actual) length. You will find many instances of > > ACPI_FREE(buffer.pointer) within existing linux code, since it also used for > > objects returned by control method execution/object evaluation. > > Well, I suppose I only wanted to say that acpi_free_buffer(buffer) would look > a bit more straightforward than ACPI_FREE(buffer.pointer). :-) And I can define acpi_free_buffer() in the Linux-specific code too. Thanks, Rafael
PiBBbmQgSSBjYW4gZGVmaW5lIGFjcGlfZnJlZV9idWZmZXIoKSBpbiB0aGUgTGludXgtc3BlY2lm aWMgY29kZSB0b28uDQo+IA0KPiBUaGFua3Ms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Qo+ID4gPiA+IGl0IHdv dWxkIGJlIG5pY2VyLiA6LSkNCj4gPiA+DQo+ID4gPg0KPiA+ID4gVGhlIEFDUElfQlVGRkVSIHR5 cGUgaXMgaW4gZmFjdCBhIHB1YmxpYyB0eXBlIHRoYXQgaXMgbWVhbnQgdG8NCj4gPiA+IHJldHVy biBib3RoIHRoZSBidWZmZXIgYW5kIHRoZSAoYWN0dWFsKSBsZW5ndGguIFlvdSB3aWxsIGZpbmQg bWFueQ0KPiA+ID4gaW5zdGFuY2VzIG9mDQo+ID4gPiBBQ1BJX0ZSRUUoYnVmZmVyLnBvaW50ZXIp IHdpdGhpbiBleGlzdGluZyBsaW51eCBjb2RlLCBzaW5jZSBpdCBhbHNvDQo+ID4gPiB1c2VkIGZv ciBvYmplY3RzIHJldHVybmVkIGJ5IGNvbnRyb2wgbWV0aG9kIGV4ZWN1dGlvbi9vYmplY3QNCj4g ZXZhbHVhdGlvbi4NCj4gPg0KPiA+IFdlbGwsIEkgc3VwcG9zZSBJIG9ubHkgd2FudGVkIHRvIHNh eSB0aGF0IGFjcGlfZnJlZV9idWZmZXIoYnVmZmVyKQ0KPiA+IHdvdWxkIGxvb2sgYSBiaXQgbW9y ZSBzdHJhaWdodGZvcndhcmQgdGhhbiBBQ1BJX0ZSRUUoYnVmZmVyLnBvaW50ZXIpLg0KPiA+IDot KQ0KPiANCj4gQW5kIEkgY2FuIGRlZmluZSBhY3BpX2ZyZWVfYnVmZmVyKCkgaW4gdGhlIExpbnV4 LXNwZWNpZmljIGNvZGUgdG9vLg0KPiANCj4gVGhhbmtzLA0KPiBSYWZhZWwNCj4gDQo+IA0KPiAt LQ0KPiBJIHNwZWFrIG9ubHkgZm9yIG15c2VsZi4NCj4gUmFmYWVsIEouIFd5c29ja2ksIEludGVs IE9wZW4gU291cmNlIFRlY2hub2xvZ3kgQ2VudGVyLg0K -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Index: linux/include/acpi/acpi_bus.h =================================================================== --- linux.orig/include/acpi/acpi_bus.h +++ linux/include/acpi/acpi_bus.h @@ -259,6 +259,11 @@ struct acpi_device_physical_node { struct device *dev; }; +struct acpi_resource_list_entry { + struct list_head node; + struct acpi_resource resource; +}; + /* set maximum of physical nodes to 32 for expansibility */ #define ACPI_MAX_PHYSICAL_NODE 32 @@ -268,6 +273,7 @@ struct acpi_device { acpi_handle handle; /* no handle for fixed hardware */ struct acpi_device *parent; struct list_head children; + struct list_head resources; /* Device resources. */ struct list_head node; struct list_head wakeup_list; struct acpi_device_status status; Index: linux/drivers/acpi/scan.c =================================================================== --- linux.orig/drivers/acpi/scan.c +++ linux/drivers/acpi/scan.c @@ -382,6 +382,52 @@ static void acpi_device_remove_files(str ACPI Bus operations -------------------------------------------------------------------------- */ +static void acpi_bus_drop_resources(struct acpi_device *adev) +{ + struct acpi_resource_list_entry *entry, *s; + + list_for_each_entry_safe(entry, s, &adev->resources, node) { + list_del(&entry->node); + kfree(entry); + } +} + +static acpi_status acpi_bus_add_resource(struct acpi_resource *res, + void *context) +{ + struct list_head *list = context; + struct acpi_resource_list_entry *entry; + + entry = kzalloc(sizeof(*entry), GFP_KERNEL); + if (!entry) + return AE_NO_MEMORY; + + entry->resource = *res; + INIT_LIST_HEAD(&entry->node); + list_add_tail(&entry->node, list); + return AE_OK; +} + +static int acpi_bus_get_resources(struct acpi_device *adev) +{ + acpi_status status; + acpi_handle not_used; + int ret = 0; + + status = acpi_get_handle(adev->handle, METHOD_NAME__CRS, ¬_used); + if (ACPI_FAILURE(status)) + return 0; + + status = acpi_walk_resources(adev->handle, METHOD_NAME__CRS, + acpi_bus_add_resource, &adev->resources); + if (ACPI_FAILURE(status)) { + acpi_bus_drop_resources(adev); + ret = status == AE_NO_MEMORY ? -ENOMEM : -EIO; + } + + return ret; +} + static const struct acpi_device_id *__acpi_match_device( struct acpi_device *device, const struct acpi_device_id *ids) { @@ -681,6 +727,7 @@ static void acpi_device_unregister(struc acpi_device_remove_files(device); device_unregister(&device->dev); + acpi_bus_drop_resources(device); } /* -------------------------------------------------------------------------- @@ -1412,6 +1459,15 @@ static int acpi_add_single_object(struct acpi_device_set_id(device); /* + * Device Resources + * ---------------- + */ + INIT_LIST_HEAD(&device->resources); + result = acpi_bus_get_resources(device); + if (result) + goto end; + + /* * Power Management * ---------------- */ Index: linux/drivers/acpi/resource.c =================================================================== --- linux.orig/drivers/acpi/resource.c +++ linux/drivers/acpi/resource.c @@ -391,3 +391,15 @@ bool acpi_dev_resource_interrupt(struct return true; } EXPORT_SYMBOL_GPL(acpi_dev_resource_interrupt); + +unsigned int acpi_dev_resource_count(struct acpi_resource *ares) +{ + switch (ares->type) { + case ACPI_RESOURCE_TYPE_IRQ: + return ares->data.irq.interrupt_count; + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: + return ares->data.extended_irq.interrupt_count; + } + return 1; +} +EXPORT_SYMBOL_GPL(acpi_dev_resource_count); Index: linux/drivers/acpi/acpi_platform.c =================================================================== --- linux.orig/drivers/acpi/acpi_platform.c +++ linux/drivers/acpi/acpi_platform.c @@ -19,59 +19,26 @@ ACPI_MODULE_NAME("platform"); -struct resource_info { - struct device *dev; - struct resource *res; - size_t n, cur; -}; - -static acpi_status acpi_platform_count_resources(struct acpi_resource *res, - void *data) +static unsigned int acpi_platform_add_resource(struct acpi_resource *res, + struct resource *r) { - struct acpi_resource_extended_irq *acpi_xirq; - struct acpi_resource_irq *acpi_irq; - struct resource_info *ri = data; - - switch (res->type) { - case ACPI_RESOURCE_TYPE_IRQ: - acpi_irq = &res->data.irq; - ri->n += acpi_irq->interrupt_count; - break; - case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: - acpi_xirq = &res->data.extended_irq; - ri->n += acpi_xirq->interrupt_count; - break; - default: - ri->n++; - } - - return AE_OK; -} - -static acpi_status acpi_platform_add_resources(struct acpi_resource *res, - void *data) -{ - struct resource_info *ri = data; - struct resource *r; - - r = ri->res + ri->cur; if (acpi_dev_resource_memory(res, r) || acpi_dev_resource_io(res, r) || acpi_dev_resource_address_space(res, r) - || acpi_dev_resource_ext_address_space(res, r)) { - ri->cur++; - return AE_OK; - } + || acpi_dev_resource_ext_address_space(res, r)) + return 1; + if (acpi_dev_resource_interrupt(res, 0, r)) { - int i; + unsigned int i; r++; for (i = 1; acpi_dev_resource_interrupt(res, i, r); i++) r++; - ri->cur += i; + return i; } - return AE_OK; + + return 0; } /** @@ -89,35 +56,32 @@ struct platform_device *acpi_create_plat struct platform_device *pdev = NULL; struct acpi_device *acpi_parent; struct device *parent = NULL; - struct resource_info ri; - acpi_status status; + struct acpi_resource_list_entry *entry; + struct resource *resources; + unsigned int count; /* If the ACPI node already has a physical device attached, skip it. */ if (adev->physical_node_count) return NULL; - memset(&ri, 0, sizeof(ri)); - /* First, count the resources. */ - status = acpi_walk_resources(adev->handle, METHOD_NAME__CRS, - acpi_platform_count_resources, &ri); - if (ACPI_FAILURE(status) || !ri.n) + count = 0; + list_for_each_entry(entry, &adev->resources, node) + count += acpi_dev_resource_count(&entry->resource); + + if (!count) return NULL; /* Next, allocate memory for all the resources and populate it. */ - ri.dev = &adev->dev; - ri.res = kzalloc(ri.n * sizeof(struct resource), GFP_KERNEL); - if (!ri.res) { - dev_err(&adev->dev, - "failed to allocate memory for resources\n"); + resources = kzalloc(count * sizeof(struct resource), GFP_KERNEL); + if (!resources) { + dev_err(&adev->dev, "No memory for resources\n"); return NULL; } - status = acpi_walk_resources(adev->handle, METHOD_NAME__CRS, - acpi_platform_add_resources, &ri); - if (ACPI_FAILURE(status)) { - dev_err(&adev->dev, "failed to walk resources\n"); - goto out; - } + count = 0; + list_for_each_entry(entry, &adev->resources, node) + count += acpi_platform_add_resource(&entry->resource, + resources + count); /* * If the ACPI node has a parent and that parent has a physical device @@ -139,8 +103,9 @@ struct platform_device *acpi_create_plat } mutex_unlock(&acpi_parent->physical_node_lock); } + pdev = platform_device_register_resndata(parent, dev_name(&adev->dev), - -1, ri.res, ri.cur, NULL, 0); + -1, resources, count, NULL, 0); if (IS_ERR(pdev)) { dev_err(&adev->dev, "platform device creation failed: %ld\n", PTR_ERR(pdev)); @@ -150,8 +115,7 @@ struct platform_device *acpi_create_plat dev_name(&pdev->dev)); } - out: - kfree(ri.res); + kfree(resources); return pdev; } Index: linux/include/linux/acpi.h =================================================================== --- linux.orig/include/linux/acpi.h +++ linux/include/linux/acpi.h @@ -260,6 +260,7 @@ bool acpi_dev_resource_ext_address_space unsigned long acpi_dev_irq_flags(u8 triggering, u8 polarity, u8 shareable); bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index, struct resource *res); +unsigned int acpi_dev_resource_count(struct acpi_resource *ares); int acpi_check_resource_conflict(const struct resource *res);