Improve ACPI resource parsing interfaces and data structures
Subsystems (8)
cover Improve ACPI resource parsing interfaces and data structures
During enabling ACPI based IOAPIC hotplug, Thomas noticed some issues in ACPI resource parsing interfaces. So this is an effort to improve them.
Patch 1-12 improve ACPI resource parsing interfaces and also fixes some bugs.
Patch 13-19 try to share the common data structure resource_list_entry between PCI and ACPI. It may also be shared with PNP too.
The patchset is based on v3.19-rc3 and you may get it from:
https://github.com/jiangliu/linux.git acpires_v1
Jiang Liu (11):
ACPI: Fix a bug in parsing ACPI Memroy24 resource
ACPI: Normalize return value of resource parser functions
ACPI: Set flag IORESOURCE_UNSET for unassigned resources
ACPI: Enforce stricter checks for address space descriptors
ACPI: Return translation offset when parsing ACPI address space
resources
ACPI: Translate resource into master side address for bridge window
resources
ACPI: Add field offset to struct resource_list_entry
ACPI: Introduce helper function acpi_dev_filter_resource_type()
resources: Move struct resource_list_entry from ACPI into resource
core
PCI: Use common resource list management code instead of private
implementation
x86/PCI/ACPI: Use common ACPI resource interfaces to simplify
implementation
Thomas Gleixner (8):
ACPI: Remove redundant check in function
acpi_dev_resource_address_space()
ACPI: Implement proper length checks for mem resources
ACPI: Use the length check for io resources as well
ACPI: Let the parser return false for disabled resources
ACPI: Provide union for address_space64 and ext_address_space64
ACPI: Unify the parsing of address_space and ext_address_space
ACPI: Move the window flag logic to the combined parser
ACPI: Add prefetch decoding to the address space parser
arch/arm/kernel/bios32.c | 5 +- arch/x86/pci/acpi.c | 297 ++++++++++--------------------- arch/x86/pci/bus_numa.c | 4 +- drivers/acpi/acpi_lpss.c | 6 +- drivers/acpi/acpi_platform.c | 2 +- drivers/acpi/resource.c | 333 ++++++++++++++++++++++------------- drivers/dma/acpi-dma.c | 8 +- drivers/pci/bus.c | 18 +- drivers/pci/host-bridge.c | 8 +- drivers/pci/host/pci-host-generic.c | 4 +- drivers/pci/host/pci-xgene.c | 4 +- drivers/pci/host/pcie-xilinx.c | 4 +- drivers/pci/probe.c | 10 +- drivers/pnp/pnpacpi/rsparser.c | 4 +- include/acpi/acrestyp.h | 49 ++++-- include/linux/acpi.h | 12 +- include/linux/ioport.h | 25 +++ include/linux/pci.h | 8 +- kernel/resource.c | 48 +++++ 19 files changed, 452 insertions(+), 397 deletions(-)
Signature · 1 line
1.7.10.4
RFC PATCH 2/19 ACPI: Implement proper length checks for mem resources
From: Thomas Gleixner <[email protected]>
Check whether the resulting length is the same as the given length. Check for start <= end as well.
We need to hand in the resource for this, so we can apply the flags directly.
[Jiang] Remove enforcement that resource starting address must be non-zero.
--- drivers/acpi/resource.c | 61 ++++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 27 deletions(-)
drivers/acpi/resource.c +34 -27
@@ -34,21 +34,37 @@#define valid_IRQ (i) (true)#endif -static unsigned long acpi_dev_memresource_flags (u64 len,u8 write_protect, -bool window) +static bool acpi_dev_resource_len_valid (u64 start,u64 end,u64 len,bool io) { -unsigned long flags =IORESOURCE_MEM ; +u64 reslen = end - start +1 ; -if (len ==0 ) - flags |=IORESOURCE_DISABLED ; +/* +* CHECKME: len might be required to check versus a minimum +* length as well. 1 for io is fine, but for memory it does +* not make any sense at all. +*/ +if (len && reslen && reslen == len && start <= end) +return true; + +pr_info ("ACPI: invalid or unassigned resource %s [%016llx - %016llx] length [%016llx]\n" , + io ?"io" :"mem" , start, end, len); + +return false; +} + +static void acpi_dev_memresource_flags (struct resource *res,u64 len, +u8 write_protect,bool window) +{ + res->flags =IORESOURCE_MEM ; + +if (!acpi_dev_resource_len_valid (res->start, res->end, len, false)) + res->flags |=IORESOURCE_DISABLED ;if (write_protect ==ACPI_READ_WRITE_MEMORY ) - flags |=IORESOURCE_MEM_WRITEABLE ; + res->flags |=IORESOURCE_MEM_WRITEABLE ;if (window) - flags |=IORESOURCE_WINDOW ; - -return flags; + res->flags |=IORESOURCE_WINDOW ; } static void acpi_dev_get_memresource(struct resource *res, u64 start, u64 len,
@@ -56,7 +72,7 @@ static void acpi_dev_get_memresource(struct resource *res, u64 start, u64 len, { res->start = start; res->end = start + len -1 ; - res->flags =acpi_dev_memresource_flags (len, write_protect, false); +acpi_dev_memresource_flags (res, len, write_protect, false); }/**
@@ -77,24 +93,18 @@ bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res)switch (ares->type) {case ACPI_RESOURCE_TYPE_MEMORY24 : memory24 = &ares->data.memory24; -if (!memory24->minimum && !memory24->address_length) -return false;acpi_dev_get_memresource (res, memory24->minimum, memory24->address_length, memory24->write_protect);break ;case ACPI_RESOURCE_TYPE_MEMORY32 : memory32 = &ares->data.memory32; -if (!memory32->minimum && !memory32->address_length) -return false;acpi_dev_get_memresource (res, memory32->minimum, memory32->address_length, memory32->write_protect);break ;case ACPI_RESOURCE_TYPE_FIXED_MEMORY32 : fixed_memory32 = &ares->data.fixed_memory32; -if (!fixed_memory32->address && !fixed_memory32->address_length) -return false;acpi_dev_get_memresource (res, fixed_memory32->address, fixed_memory32->address_length, fixed_memory32->write_protect);
@@ -102,7 +112,8 @@ bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res)default :return false; } -return true; + +return !(res->flags &IORESOURCE_DISABLED ); }EXPORT_SYMBOL_GPL (acpi_dev_resource_memory);
@@ -186,7 +197,6 @@ bool acpi_dev_resource_address_space(struct acpi_resource *ares,acpi_status status;struct acpi_resource_address64 addr;bool window; -u64 len;u8 io_decode; status =acpi_resource_to_address64 (ares, &addr);
@@ -199,10 +209,9 @@ bool acpi_dev_resource_address_space(struct acpi_resource *ares,switch (addr.resource_type) {case ACPI_MEMORY_RANGE : - len = addr.maximum - addr.minimum +1 ; - res->flags =acpi_dev_memresource_flags (len, - addr.info.mem.write_protect, - window); +acpi_dev_memresource_flags (res, addr.address_length, + addr.info.mem.write_protect, + window);break ;case ACPI_IO_RANGE : io_decode = addr.granularity == 0xfff ?
@@ -236,7 +245,6 @@ bool acpi_dev_resource_ext_address_space(struct acpi_resource *ares, {struct acpi_resource_extended_address64 *ext_addr;bool window; -u64 len;u8 io_decode;if (ares->type !=ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 )
@@ -250,10 +258,9 @@ bool acpi_dev_resource_ext_address_space(struct acpi_resource *ares,switch (ext_addr->resource_type) {case ACPI_MEMORY_RANGE : - len = ext_addr->maximum - ext_addr->minimum +1 ; - res->flags =acpi_dev_memresource_flags (len, - ext_addr->info.mem.write_protect, - window); +acpi_dev_memresource_flags (res, ext_addr->address_length, + ext_addr->info.mem.write_protect, + window);break ;case ACPI_IO_RANGE : io_decode = ext_addr->granularity == 0xfff ?
Signature · 1 line
1.7.10.4
RFC PATCH 1/19 ACPI: Remove redundant check in function acpi_dev_resource_address_space()
In reply to Jiang LiuFrom: Thomas Gleixner <[email protected]>
The ACPI type is checked in acpi_resource_to_address64() anyway.
--- drivers/acpi/resource.c | 9 --------- 1 file changed, 9 deletions(-)
drivers/acpi/resource.c +0 -9
@@ -189,15 +189,6 @@ bool acpi_dev_resource_address_space(struct acpi_resource *ares,u64 len;u8 io_decode; -switch (ares->type) { -case ACPI_RESOURCE_TYPE_ADDRESS16 : -case ACPI_RESOURCE_TYPE_ADDRESS32 : -case ACPI_RESOURCE_TYPE_ADDRESS64 : -break ; -default : -return false; - } - status =acpi_resource_to_address64 (ares, &addr);if (ACPI_FAILURE (status))return false;
Signature · 1 line
1.7.10.4
RFC PATCH 4/19 ACPI: Let the parser return false for disabled resources
In reply to Jiang LiuFrom: Thomas Gleixner <[email protected]>
If the parser disables a resource during parsing, let it return false, so the calling code does not need to implement further checks.
--- drivers/acpi/resource.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/acpi/resource.c +4 -4
@@ -219,10 +219,10 @@ bool acpi_dev_resource_address_space(struct acpi_resource *ares, res->flags =IORESOURCE_BUS ;break ;default : - res->flags =0 ; +return false; } -return true; +return !(res->flags &IORESOURCE_DISABLED ); }EXPORT_SYMBOL_GPL (acpi_dev_resource_address_space);
@@ -267,10 +267,10 @@ bool acpi_dev_resource_ext_address_space(struct acpi_resource *ares, res->flags =IORESOURCE_BUS ;break ;default : - res->flags =0 ; +return false; } -return true; +return !(res->flags &IORESOURCE_DISABLED ); }EXPORT_SYMBOL_GPL (acpi_dev_resource_ext_address_space);
Signature · 1 line
1.7.10.4
RFC PATCH 3/19 ACPI: Use the length check for io resources as well
In reply to Jiang LiuFrom: Thomas Gleixner <[email protected]>
Also apply length check to IO resources.
[Jiang] Remove enforcement that resource starting address must be non-zero.
--- drivers/acpi/resource.c | 44 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 25 deletions(-)
drivers/acpi/resource.c +19 -25
@@ -117,31 +117,30 @@ bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res) }EXPORT_SYMBOL_GPL (acpi_dev_resource_memory); -static unsigned int acpi_dev_ioresource_flags (u64 start,u64 end,u8 io_decode, -bool window) +static void acpi_dev_ioresource_flags (struct resource *res,u64 len, +u8 io_decode,bool window) { -int flags =IORESOURCE_IO ; + res->flags =IORESOURCE_IO ; -if (io_decode ==ACPI_DECODE_16 ) - flags |=IORESOURCE_IO_16BIT_ADDR ; +if (!acpi_dev_resource_len_valid (res->start, res->end, len, true)) + res->flags |=IORESOURCE_DISABLED ; -if (start > end || end >=0x10003 ) - flags |=IORESOURCE_DISABLED ; +if (res->end >=0x10003 ) + res->flags |=IORESOURCE_DISABLED ; -if (window) - flags |=IORESOURCE_WINDOW ; +if (io_decode ==ACPI_DECODE_16 ) + res->flags |=IORESOURCE_IO_16BIT_ADDR ; -return flags; +if (window) + res->flags |=IORESOURCE_WINDOW ; }static void acpi_dev_get_ioresource (struct resource *res,u64 start,u64 len,u8 io_decode) { -u64 end = start + len -1 ; - res->start = start; - res->end = end; - res->flags =acpi_dev_ioresource_flags (start, end, io_decode, false); + res->end = start + len -1 ; +acpi_dev_ioresource_flags (res, len, io_decode, false); }/**
@@ -161,16 +160,12 @@ bool acpi_dev_resource_io(struct acpi_resource *ares, struct resource *res)switch (ares->type) {case ACPI_RESOURCE_TYPE_IO : io = &ares->data.io; -if (!io->minimum && !io->address_length) -return false;acpi_dev_get_ioresource (res, io->minimum, io->address_length, io->io_decode);break ;case ACPI_RESOURCE_TYPE_FIXED_IO : fixed_io = &ares->data.fixed_io; -if (!fixed_io->address && !fixed_io->address_length) -return false;acpi_dev_get_ioresource (res, fixed_io->address, fixed_io->address_length,ACPI_DECODE_10 );
@@ -178,7 +173,8 @@ bool acpi_dev_resource_io(struct acpi_resource *ares, struct resource *res)default :return false; } -return true; + +return !(res->flags &IORESOURCE_DISABLED ); }EXPORT_SYMBOL_GPL (acpi_dev_resource_io);
@@ -216,9 +212,8 @@ bool acpi_dev_resource_address_space(struct acpi_resource *ares,case ACPI_IO_RANGE : io_decode = addr.granularity ==0xfff ?ACPI_DECODE_10 :ACPI_DECODE_16 ; - res->flags =acpi_dev_ioresource_flags (addr.minimum, - addr.maximum, - io_decode, window); +acpi_dev_ioresource_flags (res, addr.address_length, + io_decode, window);break ;case ACPI_BUS_NUMBER_RANGE : res->flags =IORESOURCE_BUS ;
@@ -265,9 +260,8 @@ bool acpi_dev_resource_ext_address_space(struct acpi_resource *ares,case ACPI_IO_RANGE : io_decode = ext_addr->granularity ==0xfff ?ACPI_DECODE_10 :ACPI_DECODE_16 ; - res->flags =acpi_dev_ioresource_flags (ext_addr->minimum, - ext_addr->maximum, - io_decode, window); +acpi_dev_ioresource_flags (res, ext_addr->address_length, + io_decode, window);break ;case ACPI_BUS_NUMBER_RANGE : res->flags =IORESOURCE_BUS ;
Signature · 1 line
1.7.10.4
RFC PATCH 6/19 ACPI: Unify the parsing of address_space and ext_address_space
In reply to Jiang LiuFrom: Thomas Gleixner <[email protected]>
With the unions in place which let us identify the substructs we can use a single parser for address_space and ext_address_space.
--- drivers/acpi/resource.c | 88 ++++++++++++++++++----------------------------- 1 file changed, 33 insertions(+), 55 deletions(-)
drivers/acpi/resource.c +33 -55
@@ -178,6 +178,35 @@ bool acpi_dev_resource_io(struct acpi_resource *ares, struct resource *res) }EXPORT_SYMBOL_GPL (acpi_dev_resource_io); +static bool acpi_decode_space (struct resource *res, +struct acpi_resource_address *base, +struct acpi_resource_address64_common *addr) +{ +u8 iodec = addr->granularity ==0xfff ?ACPI_DECODE_10 :ACPI_DECODE_16 ; +bool window = base->producer_consumer ==ACPI_PRODUCER ; +bool wp = base->info.mem.write_protect; +u64 len = addr->address_length; + + res->start = addr->minimum; + res->end = addr->maximum; + +switch (base->resource_type) { +case ACPI_MEMORY_RANGE : +acpi_dev_memresource_flags (res, len, wp, window); +break ; +case ACPI_IO_RANGE : +acpi_dev_ioresource_flags (res, len, iodec, window); +break ; +case ACPI_BUS_NUMBER_RANGE : + res->flags =IORESOURCE_BUS ; +break ; +default : +return false; + } + +return !(res->flags &IORESOURCE_DISABLED ); +} +/** * acpi_dev_resource_address_space - Extract ACPI address space information. * @ares: Input ACPI resource object.
@@ -190,39 +219,12 @@ EXPORT_SYMBOL_GPL(acpi_dev_resource_io);bool acpi_dev_resource_address_space (struct acpi_resource *ares,struct resource *res) { -acpi_status status;struct acpi_resource_address64 addr; -bool window; -u8 io_decode; - - status =acpi_resource_to_address64 (ares, &addr); -if (ACPI_FAILURE (status)) -return false; - res->start = addr.minimum; - res->end = addr.maximum; - window = addr.producer_consumer ==ACPI_PRODUCER ; - -switch (addr.resource_type) { -case ACPI_MEMORY_RANGE : -acpi_dev_memresource_flags (res, addr.address_length, - addr.info.mem.write_protect, - window); -break ; -case ACPI_IO_RANGE : - io_decode = addr.granularity ==0xfff ? -ACPI_DECODE_10 :ACPI_DECODE_16 ; -acpi_dev_ioresource_flags (res, addr.address_length, - io_decode, window); -break ; -case ACPI_BUS_NUMBER_RANGE : - res->flags =IORESOURCE_BUS ; -break ; -default : +if (ACPI_FAILURE (acpi_resource_to_address64 (ares, &addr)))return false; - } -return !(res->flags &IORESOURCE_DISABLED ); +return acpi_decode_space (res, &addr.common.base, &addr.common.addr); }EXPORT_SYMBOL_GPL (acpi_dev_resource_address_space);
@@ -239,38 +241,14 @@ bool acpi_dev_resource_ext_address_space(struct acpi_resource *ares, struct resource *res) {struct acpi_resource_extended_address64 *ext_addr; -bool window; -u8 io_decode;if (ares->type !=ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 )return false; ext_addr = &ares->data.ext_address64; - res->start = ext_addr->minimum; - res->end = ext_addr->maximum; - window = ext_addr->producer_consumer ==ACPI_PRODUCER ; - -switch (ext_addr->resource_type) { -case ACPI_MEMORY_RANGE : -acpi_dev_memresource_flags (res, ext_addr->address_length, - ext_addr->info.mem.write_protect, - window); -break ; -case ACPI_IO_RANGE : - io_decode = ext_addr->granularity ==0xfff ? -ACPI_DECODE_10 :ACPI_DECODE_16 ; -acpi_dev_ioresource_flags (res, ext_addr->address_length, - io_decode, window); -break ; -case ACPI_BUS_NUMBER_RANGE : - res->flags =IORESOURCE_BUS ; -break ; -default : -return false; - } - -return !(res->flags &IORESOURCE_DISABLED ); +return acpi_decode_space (res, &ext_addr->common.base, + &ext_addr->common.addr); }EXPORT_SYMBOL_GPL (acpi_dev_resource_ext_address_space);
Signature · 1 line
1.7.10.4
RFC PATCH 7/19 ACPI: Move the window flag logic to the combined parser
In reply to Jiang LiuFrom: Thomas Gleixner <[email protected]>
Normal memory and io resources have window always set to false. Move the flag logic to the unified address space parser.
--- drivers/acpi/resource.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)
drivers/acpi/resource.c +9 -13
@@ -53,7 +53,7 @@ static bool acpi_dev_resource_len_valid(u64 start, u64 end, u64 len, bool io) }static void acpi_dev_memresource_flags (struct resource *res,u64 len, -u8 write_protect,bool window) +u8 write_protect) { res->flags =IORESOURCE_MEM ;
@@ -62,9 +62,6 @@ static void acpi_dev_memresource_flags(struct resource *res, u64 len,if (write_protect ==ACPI_READ_WRITE_MEMORY ) res->flags |=IORESOURCE_MEM_WRITEABLE ; - -if (window) - res->flags |=IORESOURCE_WINDOW ; } static void acpi_dev_get_memresource(struct resource *res, u64 start, u64 len,
@@ -72,7 +69,7 @@ static void acpi_dev_get_memresource(struct resource *res, u64 start, u64 len, { res->start = start; res->end = start + len -1 ; -acpi_dev_memresource_flags (res, len, write_protect, false); +acpi_dev_memresource_flags (res, len, write_protect); }/**
@@ -118,7 +115,7 @@ bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res)EXPORT_SYMBOL_GPL (acpi_dev_resource_memory);static void acpi_dev_ioresource_flags (struct resource *res,u64 len, -u8 io_decode,bool window) +u8 io_decode) { res->flags =IORESOURCE_IO ;
@@ -130,9 +127,6 @@ static void acpi_dev_ioresource_flags(struct resource *res, u64 len,if (io_decode ==ACPI_DECODE_16 ) res->flags |=IORESOURCE_IO_16BIT_ADDR ; - -if (window) - res->flags |=IORESOURCE_WINDOW ; } static void acpi_dev_get_ioresource(struct resource *res, u64 start, u64 len,
@@ -140,7 +134,7 @@ static void acpi_dev_get_ioresource(struct resource *res, u64 start, u64 len, { res->start = start; res->end = start + len -1 ; -acpi_dev_ioresource_flags (res, len, io_decode, false); +acpi_dev_ioresource_flags (res, len, io_decode); }/**
@@ -183,7 +177,6 @@ static bool acpi_decode_space(struct resource *res, struct acpi_resource_address64_common *addr) {u8 iodec = addr->granularity ==0xfff ?ACPI_DECODE_10 :ACPI_DECODE_16 ; -bool window = base->producer_consumer ==ACPI_PRODUCER ;bool wp = base->info.mem.write_protect;u64 len = addr->address_length;
@@ -192,10 +185,10 @@ static bool acpi_decode_space(struct resource *res,switch (base->resource_type) {case ACPI_MEMORY_RANGE : -acpi_dev_memresource_flags (res, len, wp, window); +acpi_dev_memresource_flags (res, len, wp);break ;case ACPI_IO_RANGE : -acpi_dev_ioresource_flags (res, len, iodec, window); +acpi_dev_ioresource_flags (res, len, iodec);break ;case ACPI_BUS_NUMBER_RANGE : res->flags =IORESOURCE_BUS ;
@@ -204,6 +197,9 @@ static bool acpi_decode_space(struct resource *res,return false; } +if (base->producer_consumer ==ACPI_PRODUCER ) + res->flags |=IORESOURCE_WINDOW ; +return !(res->flags &IORESOURCE_DISABLED ); }
Signature · 1 line
1.7.10.4
RFC PATCH 8/19 ACPI: Add prefetch decoding to the address space parser
In reply to Jiang LiuFrom: Thomas Gleixner <[email protected]>
Add support of PREFETCH attributre to ACPI address space and extended address space parser.
--- drivers/acpi/resource.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/acpi/resource.c +3 -0
@@ -200,6 +200,9 @@ static bool acpi_decode_space(struct resource *res,if (base->producer_consumer ==ACPI_PRODUCER ) res->flags |=IORESOURCE_WINDOW ; +if (base->info.mem.caching ==ACPI_PREFETCHABLE_MEMORY ) + res->flags |=IORESOURCE_PREFETCH ; +return !(res->flags &IORESOURCE_DISABLED ); }
Signature · 1 line
1.7.10.4
RFC PATCH 9/19 ACPI: Fix a bug in parsing ACPI Memroy24 resource
In reply to Jiang LiuAccording to ACPI spec 5, section 6.4.3.1 "24-Bit Memory Range Descriptor", minimum, maximum and address_length field in struct acpi_resource_memory24 is in granularity of 256-bytes. So shift 8-bit left to get correct address.
--- drivers/acpi/resource.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/resource.c +2 -2
@@ -90,8 +90,8 @@ bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res)switch (ares->type) {case ACPI_RESOURCE_TYPE_MEMORY24 : memory24 = &ares->data.memory24; -acpi_dev_get_memresource (res, memory24->minimum, - memory24->address_length, +acpi_dev_get_memresource (res, memory24->minimum <<8 , + memory24->address_length <<8 , memory24->write_protect);break ;case ACPI_RESOURCE_TYPE_MEMORY32 :
Signature · 1 line
1.7.10.4
RFC PATCH 12/19 ACPI: Enforce stricter checks for address space descriptors
In reply to Jiang LiuEnforce stricter checks for address space descriptors according to ACPI spec.
--- drivers/acpi/resource.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/acpi/resource.c +8 -0
@@ -192,6 +192,14 @@ static bool acpi_decode_space(struct resource *res,bool wp = base->info.mem.write_protect;u64 len = addr->address_length; +/* +* Filter out invalid descriptor according to ACPI Spec 5.0, section +* 6.4.3.5 Address Space Resource Descriptors. +*/ +if ((base->min_address_fixed != base->max_address_fixed && len) || + (base->min_address_fixed && base->max_address_fixed && !len)) +return false; + res->start = addr->minimum; res->end = addr->maximum;
Signature · 1 line
1.7.10.4
RFC PATCH 11/19 ACPI: Set flag IORESOURCE_UNSET for unassigned resources
In reply to Jiang LiuAlso set flag IORESOURCE_UNSET for unassigned resource in addition to IORESOURCE_DISABLED to mark resource as unassigned.
--- drivers/acpi/resource.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/acpi/resource.c +4 -4
@@ -58,7 +58,7 @@ static void acpi_dev_memresource_flags(struct resource *res, u64 len, res->flags =IORESOURCE_MEM ;if (!acpi_dev_resource_len_valid (res->start, res->end, len, false)) - res->flags |=IORESOURCE_DISABLED ; + res->flags |=IORESOURCE_DISABLED |IORESOURCE_UNSET ;if (write_protect ==ACPI_READ_WRITE_MEMORY ) res->flags |=IORESOURCE_MEM_WRITEABLE ;
@@ -126,10 +126,10 @@ static void acpi_dev_ioresource_flags(struct resource *res, u64 len, res->flags =IORESOURCE_IO ;if (!acpi_dev_resource_len_valid (res->start, res->end, len, true)) - res->flags |=IORESOURCE_DISABLED ; + res->flags |=IORESOURCE_DISABLED |IORESOURCE_UNSET ;if (res->end >=0x10003 ) - res->flags |=IORESOURCE_DISABLED ; + res->flags |=IORESOURCE_DISABLED |IORESOURCE_UNSET ;if (io_decode ==ACPI_DECODE_16 ) res->flags |=IORESOURCE_IO_16BIT_ADDR ;
@@ -303,7 +303,7 @@ static void acpi_dev_irqresource_disabled(struct resource *res, u32 gsi) { res->start = gsi; res->end = gsi; - res->flags =IORESOURCE_IRQ |IORESOURCE_DISABLED ; + res->flags =IORESOURCE_IRQ |IORESOURCE_DISABLED |IORESOURCE_UNSET ; } static void acpi_dev_get_irqresource(struct resource *res, u32 gsi,
Signature · 1 line
1.7.10.4
RFC PATCH 13/19 ACPI: Return translation offset when parsing ACPI address space resources
In reply to Jiang LiuChange function acpi_dev_resource_address_space() and acpi_dev_resource_ext_address_space() to return address space translation offset.
It's based on a patch from Yinghai Lu <[email protected]>.
--- drivers/acpi/resource.c | 22 +++++++++++++++------- drivers/pnp/pnpacpi/rsparser.c | 4 ++-- include/linux/acpi.h | 6 ++++-- 3 files changed, 21 insertions(+), 11 deletions(-)
drivers/acpi/resource.c +15 -7
@@ -184,7 +184,7 @@ bool acpi_dev_resource_io(struct acpi_resource *ares, struct resource *res) }EXPORT_SYMBOL_GPL (acpi_dev_resource_io); -static bool acpi_decode_space (struct resource *res, +static bool acpi_decode_space (struct resource *res,resource_size_t *offset,struct acpi_resource_address *base,struct acpi_resource_address64_common *addr) {
@@ -217,6 +217,9 @@ static bool acpi_decode_space(struct resource *res,return false; } +if (offset) + *offset = addr->translation_offset; +if (base->producer_consumer ==ACPI_PRODUCER ) res->flags |=IORESOURCE_WINDOW ;
@@ -230,6 +233,7 @@ static bool acpi_decode_space(struct resource *res,* acpi_dev_resource_address_space - Extract ACPI address space information. * @ares: Input ACPI resource object. * @res: Output generic resource object. +* @offset: Output translation offset * * Check if the given ACPI resource object represents an address space resource * and if that's the case, use the information in it to populate the generic
@@ -241,7 +245,8 @@ static bool acpi_decode_space(struct resource *res,* 3) true: valid assigned resource */ bool acpi_dev_resource_address_space (struct acpi_resource *ares, -struct resource *res) +struct resource *res, +resource_size_t *offset) {struct acpi_resource_address64 addr;
@@ -249,7 +254,8 @@ bool acpi_dev_resource_address_space(struct acpi_resource *ares,if (ACPI_FAILURE (acpi_resource_to_address64 (ares, &addr)))return false; -return acpi_decode_space (res, &addr.common.base, &addr.common.addr); +return acpi_decode_space (res, offset, + &addr.common.base, &addr.common.addr); }EXPORT_SYMBOL_GPL (acpi_dev_resource_address_space);
@@ -257,6 +263,7 @@ EXPORT_SYMBOL_GPL(acpi_dev_resource_address_space);* acpi_dev_resource_ext_address_space - Extract ACPI address space information. * @ares: Input ACPI resource object. * @res: Output generic resource object. +* @offset: Output translation offset * * Check if the given ACPI resource object represents an extended address space * resource and if that's the case, use the information in it to populate the
@@ -268,7 +275,8 @@ EXPORT_SYMBOL_GPL(acpi_dev_resource_address_space);* 3) true: valid assigned resource */ bool acpi_dev_resource_ext_address_space (struct acpi_resource *ares, -struct resource *res) +struct resource *res, +resource_size_t *offset) {struct acpi_resource_extended_address64 *ext_addr;
@@ -278,7 +286,7 @@ bool acpi_dev_resource_ext_address_space(struct acpi_resource *ares, ext_addr = &ares->data.ext_address64; -return acpi_decode_space (res, &ext_addr->common.base, +return acpi_decode_space (res, offset, &ext_addr->common.base, &ext_addr->common.addr); }EXPORT_SYMBOL_GPL (acpi_dev_resource_ext_address_space);
@@ -478,8 +486,8 @@ static acpi_status acpi_dev_process_resource(struct acpi_resource *ares,if (acpi_dev_resource_memory (ares, &r) ||acpi_dev_resource_io (ares, &r) - ||acpi_dev_resource_address_space (ares, &r) - ||acpi_dev_resource_ext_address_space (ares, &r)) + ||acpi_dev_resource_address_space (ares, &r,NULL ) + ||acpi_dev_resource_ext_address_space (ares, &r,NULL ))return acpi_dev_new_resource_entry (&r, c);for (i =0 ;acpi_dev_resource_interrupt (ares, i, &r); i++) {
drivers/pnp/pnpacpi/rsparser.c +2 -2
@@ -183,8 +183,8 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,struct resource r = {0 };int i, flags; -if (acpi_dev_resource_address_space (res, &r) - ||acpi_dev_resource_ext_address_space (res, &r)) { +if (acpi_dev_resource_address_space (res, &r,NULL ) + ||acpi_dev_resource_ext_address_space (res, &r,NULL )) {pnp_add_resource (dev, &r);return AE_OK ; }
include/linux/acpi.h +4 -2
@@ -288,9 +288,11 @@ extern int pnpacpi_disabled;bool acpi_dev_resource_memory (struct acpi_resource *ares,struct resource *res);bool acpi_dev_resource_io (struct acpi_resource *ares,struct resource *res);bool acpi_dev_resource_address_space (struct acpi_resource *ares, -struct resource *res); +struct resource *res, +resource_size_t *offset);bool acpi_dev_resource_ext_address_space (struct acpi_resource *ares, -struct resource *res); +struct resource *res, +resource_size_t *offset);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);
Signature · 1 line
1.7.10.4
RFC PATCH 14/19 ACPI: Translate resource into master side address for bridge window resources
In reply to Jiang LiuAdd translation_offset into the result address for bridge window resources to form the master side address.
Currently acpi_dev_resource_{ext_}address_space() are only used for devices instead of bridges, so it won't break current users. Later it will be used to support PCI host bridge drivers.
--- drivers/acpi/resource.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/acpi/resource.c +14 -0
@@ -203,6 +203,20 @@ static bool acpi_decode_space(struct resource *res, resource_size_t *offset, res->start = addr->minimum; res->end = addr->maximum; +/* +* For bridges that translate addresses across the bridge, +* translation_offset is the offset that must be added to the +* address on the secondary side to obtain the address on the +* primary side. Non-bridge devices must list 0 for all Address +* Translation offset bits. +*/ +if (base->producer_consumer ==ACPI_PRODUCER ) { + res->start += addr->translation_offset; + res->end += addr->translation_offset; + }else if (addr->translation_offset) { +return false; + } +switch (base->resource_type) {case ACPI_MEMORY_RANGE :acpi_dev_memresource_flags (res, len, wp);
Signature · 1 line
1.7.10.4
RFC PATCH 15/19 ACPI: Add field offset to struct resource_list_entry
In reply to Jiang LiuAdd field offset to struct resource_list_entry to host address space translation offset so it could be used to represent bridge resources.
--- drivers/acpi/resource.c | 13 ++++++++----- include/linux/acpi.h | 1 + 2 files changed, 9 insertions(+), 5 deletions(-)
drivers/acpi/resource.c +8 -5
@@ -462,7 +462,8 @@ struct res_proc_context { };static acpi_status acpi_dev_new_resource_entry (struct resource *r, -struct res_proc_context *c) +struct res_proc_context *c, +resource_size_t offset) {struct resource_list_entry *rentry;
@@ -472,6 +473,7 @@ static acpi_status acpi_dev_new_resource_entry(struct resource *r,return AE_NO_MEMORY ; } rentry->res = *r; + rentry->offset = offset;list_add_tail (&rentry->node, c->list); c->count++;return AE_OK ;
@@ -480,6 +482,7 @@ static acpi_status acpi_dev_new_resource_entry(struct resource *r,static acpi_status acpi_dev_process_resource (struct acpi_resource *ares,void *context) { +resource_size_t offset =0 ;struct res_proc_context *c = context;struct resource r;int i;
@@ -500,14 +503,14 @@ static acpi_status acpi_dev_process_resource(struct acpi_resource *ares,if (acpi_dev_resource_memory (ares, &r) ||acpi_dev_resource_io (ares, &r) - ||acpi_dev_resource_address_space (ares, &r,NULL ) - ||acpi_dev_resource_ext_address_space (ares, &r,NULL )) -return acpi_dev_new_resource_entry (&r, c); + ||acpi_dev_resource_address_space (ares, &r, &offset) + ||acpi_dev_resource_ext_address_space (ares, &r, &offset)) +return acpi_dev_new_resource_entry (&r, c, offset);for (i =0 ;acpi_dev_resource_interrupt (ares, i, &r); i++) {acpi_status status; - status =acpi_dev_new_resource_entry (&r, c); + status =acpi_dev_new_resource_entry (&r, c,0 );if (ACPI_FAILURE (status))return status; }
include/linux/acpi.h +1 -0
@@ -300,6 +300,7 @@ bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index,struct resource_list_entry {struct list_head node;struct resource res; +resource_size_t offset; };void acpi_dev_free_resource_list (struct list_head *list);
Signature · 1 line
1.7.10.4
RFC PATCH 16/19 ACPI: Introduce helper function acpi_dev_filter_resource_type()
In reply to Jiang LiuIntroduce helper function acpi_dev_filter_resource_type(), which may be used by acpi_dev_get_resources() to filer out resource based on resource type.
--- drivers/acpi/resource.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/acpi.h | 1 + 2 files changed, 55 insertions(+)
drivers/acpi/resource.c +54 -0
@@ -570,3 +570,57 @@ int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list,return c.count; }EXPORT_SYMBOL_GPL (acpi_dev_get_resources); + +/** +* acpi_dev_filter_resource_type - Filter ACPI resource according to resource +* types +* @ares: Input ACPI resource object. +* @arg: Valid resource types of IORESOURCE_XXX +* +* This is a hepler function to support acpi_dev_get_resources(), which filters +* ACPI resource objects according to resource types. +*/ +int acpi_dev_filter_resource_type (struct acpi_resource *ares,void *arg) +{ +unsigned long type =0 , types = (unsigned long )arg; + +switch (ares->type) { +case ACPI_RESOURCE_TYPE_MEMORY24 : +case ACPI_RESOURCE_TYPE_MEMORY32 : +case ACPI_RESOURCE_TYPE_FIXED_MEMORY32 : + type =IORESOURCE_MEM ; +break ; +case ACPI_RESOURCE_TYPE_IO : +case ACPI_RESOURCE_TYPE_FIXED_IO : + type =IORESOURCE_IO ; +break ; +case ACPI_RESOURCE_TYPE_IRQ : +case ACPI_RESOURCE_TYPE_EXTENDED_IRQ : + type =IORESOURCE_IRQ ; +break ; +case ACPI_RESOURCE_TYPE_DMA : +case ACPI_RESOURCE_TYPE_FIXED_DMA : + type =IORESOURCE_DMA ; +break ; +case ACPI_RESOURCE_TYPE_GENERIC_REGISTER : + type =IORESOURCE_REG ; +break ; +case ACPI_RESOURCE_TYPE_ADDRESS16 : +case ACPI_RESOURCE_TYPE_ADDRESS32 : +case ACPI_RESOURCE_TYPE_ADDRESS64 : +case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 : +if (ares->data.address.resource_type ==ACPI_MEMORY_RANGE ) + type =IORESOURCE_MEM ; +else if (ares->data.address.resource_type ==ACPI_IO_RANGE ) + type =IORESOURCE_IO ; +else if (ares->data.address.resource_type == +ACPI_BUS_NUMBER_RANGE ) + type =IORESOURCE_BUS ; +break ; +default : +break ; + } + +return (type & types) ?0 :1 ; +} +EXPORT_SYMBOL_GPL (acpi_dev_filter_resource_type);
include/linux/acpi.h +1 -0
@@ -307,6 +307,7 @@ void acpi_dev_free_resource_list(struct list_head *list);int acpi_dev_get_resources (struct acpi_device *adev,struct list_head *list,int (*preproc)(struct acpi_resource *,void *),void *preproc_data); +int acpi_dev_filter_resource_type (struct acpi_resource *ares,void *arg);int acpi_check_resource_conflict (const struct resource *res);
Signature · 1 line
1.7.10.4
RFC PATCH 17/19 resources: Move struct resource_list_entry from ACPI into resource core
In reply to Jiang LiuCurrently ACPI, PCI and pnp all implement the same resource list management with different data structure. We need to transfer from one data structure into another when passing resources from one subsystem into another subsystem. Sp move struct resource_list_entry from ACPI into resource core, so it could be reused by different subystems and avoid the data structure conversion.
--- drivers/acpi/acpi_lpss.c | 6 +++--- drivers/acpi/acpi_platform.c | 2 +- drivers/acpi/resource.c | 13 ++++-------- drivers/dma/acpi-dma.c | 8 +++---- include/linux/acpi.h | 6 ------ include/linux/ioport.h | 25 ++++++++++++++++++++++ kernel/resource.c | 48 ++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 85 insertions(+), 23 deletions(-)
drivers/acpi/acpi_lpss.c +3 -3
@@ -333,12 +333,12 @@ static int acpi_lpss_create_device(struct acpi_device *adev, goto err_out;list_for_each_entry (rentry, &resource_list, node) -if (resource_type (&rentry->res) ==IORESOURCE_MEM ) { +if (resource_type (rentry->res) ==IORESOURCE_MEM ) {if (dev_desc->prv_size_override) pdata->mmio_size = dev_desc->prv_size_override;else - pdata->mmio_size =resource_size (&rentry->res); - pdata->mmio_base =ioremap (rentry->res.start, + pdata->mmio_size =resource_size (rentry->res); + pdata->mmio_base =ioremap (rentry->res->start, pdata->mmio_size);break ; }
drivers/acpi/acpi_platform.c +1 -1
@@ -71,7 +71,7 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev) } count =0 ;list_for_each_entry (rentry, &resource_list, node) - resources[count++] = rentry->res; + resources[count++] = *rentry->res;acpi_dev_free_resource_list (&resource_list); }
drivers/acpi/resource.c +4 -9
@@ -444,12 +444,7 @@ EXPORT_SYMBOL_GPL(acpi_dev_resource_interrupt);*/ void acpi_dev_free_resource_list (struct list_head *list) { -struct resource_list_entry *rentry, *re; - -list_for_each_entry_safe (rentry, re, list, node) { -list_del (&rentry->node); -kfree (rentry); - } +resource_list_free_list (list); }EXPORT_SYMBOL_GPL (acpi_dev_free_resource_list);
@@ -467,14 +462,14 @@ static acpi_status acpi_dev_new_resource_entry(struct resource *r, {struct resource_list_entry *rentry; - rentry =kmalloc (sizeof (*rentry),GFP_KERNEL ); + rentry =resource_list_alloc (NULL ,0 );if (!rentry) { c->error = -ENOMEM ;return AE_NO_MEMORY ; } - rentry->res = *r; + *rentry->res = *r; rentry->offset = offset; -list_add_tail (&rentry->node, c->list); +resource_list_insert (c->list, rentry, true); c->count++;return AE_OK ; }
drivers/dma/acpi-dma.c +4 -4
@@ -56,10 +56,10 @@ static int acpi_dma_parse_resource_group(const struct acpi_csrt_group *grp,return 0 ;list_for_each_entry (rentry, &resource_list, node) { -if (resource_type (&rentry->res) ==IORESOURCE_MEM ) - mem = rentry->res.start; -else if (resource_type (&rentry->res) ==IORESOURCE_IRQ ) - irq = rentry->res.start; +if (resource_type (rentry->res) ==IORESOURCE_MEM ) + mem = rentry->res->start; +else if (resource_type (rentry->res) ==IORESOURCE_IRQ ) + irq = rentry->res->start; }acpi_dev_free_resource_list (&resource_list);
include/linux/acpi.h +0 -6
@@ -297,12 +297,6 @@ 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); -struct resource_list_entry { -struct list_head node; -struct resource res; -resource_size_t offset; -}; -void acpi_dev_free_resource_list (struct list_head *list); int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list, int (*preproc)(struct acpi_resource *, void *),
include/linux/ioport.h +25 -0
@@ -11,6 +11,7 @@#ifndef __ASSEMBLY__#include <linux/compiler.h> #include <linux/types.h> +/* * Resources are tree-like, allowing * nesting etc..
@@ -255,6 +256,30 @@ static inline bool resource_overlaps(struct resource *r1, struct resource *r2)return (r1->start <= r2->end && r1->end >= r2->start); } +/* +* Common resource list management data structure and interfaces to support +* ACPI, PNP and PCI host bridge etc. +*/ +struct resource_list_entry { +struct list_head node; +struct resource *res;/* In master (CPU) address space */ +resource_size_t offset;/* Translation offset for bridge */ +struct resource __res;/* Default storage for res */ +}; + +extern struct resource_list_entry *resource_list_alloc (struct resource *res, +size_t extra_size); +extern void resource_list_free (struct resource_list_entry *entry); +extern void resource_list_insert (struct list_head *head, +struct resource_list_entry *entry,bool tail); +extern void resource_list_delete (struct resource_list_entry *entry); +extern void resource_list_free_list (struct list_head *head); + +#define resource_list_for_each_entry (entry, list) \ + list_for_each_entry((entry), (list), node) + +#define resource_list_for_each_entry_safe (entry, tmp, list) \ + list_for_each_entry_safe((entry), (tmp), (list), node)#endif /* __ASSEMBLY__ */ #endif /* _LINUX_IOPORT_H */
kernel/resource.c +48 -0
54 lines not on this page · raw message
Signature · 1 line
1.7.10.4
RFC PATCH 18/19 PCI: Use common resource list management code instead of private implementation
In reply to Jiang LiuUse common resource list management data structure and interfaces instead of private implementation.
--- arch/arm/kernel/bios32.c | 5 ++--- arch/x86/pci/bus_numa.c | 4 ++-- drivers/pci/bus.c | 18 ++++++------------ drivers/pci/host-bridge.c | 8 ++++---- drivers/pci/host/pci-host-generic.c | 4 ++-- drivers/pci/host/pci-xgene.c | 4 ++-- drivers/pci/host/pcie-xilinx.c | 4 ++-- drivers/pci/probe.c | 10 +++++----- include/linux/pci.h | 8 +------- 9 files changed, 26 insertions(+), 39 deletions(-)
arch/arm/kernel/bios32.c +2 -3
@@ -422,17 +422,16 @@ static int pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)static int pcibios_init_resources (int busnr,struct pci_sys_data *sys) {int ret; -struct pci_host_bridge_window *window; +struct resource_list_entry *window;if (list_empty (&sys->resources)) {pci_add_resource_offset (&sys->resources, &iomem_resource, sys->mem_offset); } -list_for_each_entry (window, &sys->resources, list) { +resource_list_for_each_entry (window, &sys->resources)if (resource_type (window->res) ==IORESOURCE_IO )return 0 ; - } sys->io_res.start = (busnr *SZ_64K ) ? : pcibios_min_io; sys->io_res.end = (busnr +1 ) *SZ_64K -1 ;
arch/x86/pci/bus_numa.c +2 -2
@@ -31,7 +31,7 @@ void x86_pci_root_bus_resources(int bus, struct list_head *resources) {struct pci_root_info *info =x86_find_pci_root_info (bus);struct pci_root_res *root_res; -struct pci_host_bridge_window *window; +struct resource_list_entry *window;bool found = false;if (!info)
@@ -41,7 +41,7 @@ void x86_pci_root_bus_resources(int bus, struct list_head *resources) bus);/* already added by acpi ? */ -list_for_each_entry (window, resources, list) +resource_list_for_each_entry (window, resources)if (window->res->flags &IORESOURCE_BUS ) { found = true;break ;
drivers/pci/bus.c +6 -12
@@ -20,17 +20,16 @@void pci_add_resource_offset (struct list_head *resources,struct resource *res,resource_size_t offset) { -struct pci_host_bridge_window *window; +struct resource_list_entry *entry; - window =kzalloc (sizeof (struct pci_host_bridge_window ),GFP_KERNEL ); -if (!window) { + entry =resource_list_alloc (res,0 ); +if (!entry) {printk (KERN_ERR "PCI: can't add host bridge window %pR\n" , res);return ; } - window->res = res; - window->offset = offset; -list_add_tail (&window->list, resources); + entry->offset = offset; +resource_list_insert (resources, entry, true); }EXPORT_SYMBOL (pci_add_resource_offset);
@@ -42,12 +41,7 @@ EXPORT_SYMBOL(pci_add_resource);void pci_free_resource_list (struct list_head *resources) { -struct pci_host_bridge_window *window, *tmp; - -list_for_each_entry_safe (window, tmp, resources, list) { -list_del (&window->list); -kfree (window); - } +resource_list_free_list (resources); }EXPORT_SYMBOL (pci_free_resource_list);
drivers/pci/host-bridge.c +4 -4
@@ -35,10 +35,10 @@ void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region, struct resource *res) {struct pci_host_bridge *bridge =find_pci_host_bridge (bus); -struct pci_host_bridge_window *window; +struct resource_list_entry *window;resource_size_t offset =0 ; -list_for_each_entry (window, &bridge->windows, list) { +resource_list_for_each_entry (window, &bridge->windows) {if (resource_contains (window->res, res)) { offset = window->offset;break ;
@@ -60,10 +60,10 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res, struct pci_bus_region *region) {struct pci_host_bridge *bridge =find_pci_host_bridge (bus); -struct pci_host_bridge_window *window; +struct resource_list_entry *window;resource_size_t offset =0 ; -list_for_each_entry (window, &bridge->windows, list) { +resource_list_for_each_entry (window, &bridge->windows) {struct pci_bus_region bus_region;if (resource_type (res) !=resource_type (window->res))
drivers/pci/host/pci-host-generic.c +2 -2
@@ -149,14 +149,14 @@ static int gen_pci_parse_request_of_pci_ranges(struct gen_pci *pci)struct device *dev = pci->host.dev.parent;struct device_node *np = dev->of_node;resource_size_t iobase; -struct pci_host_bridge_window *win; +struct resource_list_entry *win; err =of_pci_get_host_bridge_resources (np,0 ,0xff , &pci->resources, &iobase);if (err)return err; -list_for_each_entry (win, &pci->resources, list) { +resource_list_for_each_entry (win, &pci->resources) {struct resource *parent, *res = win->res;switch (resource_type (res)) {
drivers/pci/host/pci-xgene.c +2 -2
@@ -401,11 +401,11 @@ static int xgene_pcie_map_ranges(struct xgene_pcie_port *port, struct list_head *res, resource_size_t io_base) { -struct pci_host_bridge_window *window; +struct resource_list_entry *window;struct device *dev = port->dev;int ret; -list_for_each_entry (window, res, list) { +resource_list_for_each_entry (window, res) {struct resource *res = window->res;u64 restype =resource_type (res);
drivers/pci/host/pcie-xilinx.c +2 -2
@@ -737,7 +737,7 @@ static int xilinx_pcie_parse_and_add_res(struct xilinx_pcie_port *port)resource_size_t offset;struct of_pci_range_parser parser;struct of_pci_range range; -struct pci_host_bridge_window *win; +struct resource_list_entry *win;int err =0 , mem_resno =0 ;/* Get the ranges */
@@ -807,7 +807,7 @@ static int xilinx_pcie_parse_and_add_res(struct xilinx_pcie_port *port) free_resources:release_child_resources (&iomem_resource); -list_for_each_entry (win, &port->resources, list) +resource_list_for_each_entry (win, &port->resources)devm_kfree (dev, win->res);pci_free_resource_list (&port->resources);
drivers/pci/probe.c +5 -5
@@ -1895,7 +1895,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,int error;struct pci_host_bridge *bridge;struct pci_bus *b, *b2; -struct pci_host_bridge_window *window, *n; +struct resource_list_entry *window, *n;struct resource *res;resource_size_t offset;char bus_addr[64 ];
@@ -1959,8 +1959,8 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,printk (KERN_INFO "PCI host bridge to bus %s\n" ,dev_name (&b->dev));/* Add initial resources to the bus */ -list_for_each_entry_safe (window, n, resources, list) { -list_move_tail (&window->list, &bridge->windows); +resource_list_for_each_entry_safe (window, n, resources) { +list_move_tail (&window->node, &bridge->windows); res = window->res; offset = window->offset;if (res->flags &IORESOURCE_BUS )
@@ -2060,12 +2060,12 @@ void pci_bus_release_busn_res(struct pci_bus *b)struct pci_bus *pci_scan_root_bus (struct device *parent,int bus,struct pci_ops *ops,void *sysdata,struct list_head *resources) { -struct pci_host_bridge_window *window; +struct resource_list_entry *window;bool found = false;struct pci_bus *b;int max; -list_for_each_entry (window, resources, list) +resource_list_for_each_entry (window, resources)if (window->res->flags &IORESOURCE_BUS ) { found = true;break ;
include/linux/pci.h +1 -7
@@ -395,16 +395,10 @@ static inline int pci_channel_offline(struct pci_dev *pdev)return (pdev->error_state != pci_channel_io_normal); } -struct pci_host_bridge_window { -struct list_head list; -struct resource *res;/* host bridge aperture (CPU address) */ -resource_size_t offset;/* bus address + offset = CPU address */ -}; -struct pci_host_bridge {struct device dev;struct pci_bus *bus;/* root bus */ -struct list_head windows;/* pci_host_bridge_windows */ +struct list_head windows;/* resource_list_entry */ void (*release_fn)(struct pci_host_bridge *);void *release_data; };
Signature · 1 line
1.7.10.4
RFC PATCH 19/19 x86/PCI/ACPI: Use common ACPI resource interfaces to simplify implementation
In reply to Jiang LiuUse common ACPI resource discovery interfaces to simplify PCI host bridge resource enumeration.
It also fixes the issue discovered by Thomas that function setup_resource() incorrectly validates IO port resources against iomem_resource.
--- arch/x86/pci/acpi.c | 297 ++++++++++++++++----------------------------------- 1 file changed, 95 insertions(+), 202 deletions(-)
arch/x86/pci/acpi.c +95 -202
@@ -10,9 +10,6 @@struct pci_root_info {struct acpi_device *bridge;char name[16 ]; -unsigned int res_num; -struct resource *res; -resource_size_t *res_offset;struct pci_sysdata sd;#ifdef CONFIG_PCI_MMCONFIG bool mcfg_added;
@@ -218,130 +215,44 @@ static void teardown_mcfg_map(struct pci_root_info *info) }#endif -static acpi_status resource_to_addr (struct acpi_resource *resource, -struct acpi_resource_address64 *addr) -{ -acpi_status status; -struct acpi_resource_memory24 *memory24; -struct acpi_resource_memory32 *memory32; -struct acpi_resource_fixed_memory32 *fixed_memory32; - -memset (addr,0 ,sizeof (*addr)); -switch (resource->type) { -case ACPI_RESOURCE_TYPE_MEMORY24 : - memory24 = &resource->data.memory24; - addr->resource_type =ACPI_MEMORY_RANGE ; - addr->minimum = memory24->minimum; - addr->address_length = memory24->address_length; - addr->maximum = addr->minimum + addr->address_length -1 ; -return AE_OK ; -case ACPI_RESOURCE_TYPE_MEMORY32 : - memory32 = &resource->data.memory32; - addr->resource_type =ACPI_MEMORY_RANGE ; - addr->minimum = memory32->minimum; - addr->address_length = memory32->address_length; - addr->maximum = addr->minimum + addr->address_length -1 ; -return AE_OK ; -case ACPI_RESOURCE_TYPE_FIXED_MEMORY32 : - fixed_memory32 = &resource->data.fixed_memory32; - addr->resource_type =ACPI_MEMORY_RANGE ; - addr->minimum = fixed_memory32->address; - addr->address_length = fixed_memory32->address_length; - addr->maximum = addr->minimum + addr->address_length -1 ; -return AE_OK ; -case ACPI_RESOURCE_TYPE_ADDRESS16 : -case ACPI_RESOURCE_TYPE_ADDRESS32 : -case ACPI_RESOURCE_TYPE_ADDRESS64 : - status =acpi_resource_to_address64 (resource, addr); -if (ACPI_SUCCESS (status) && - (addr->resource_type ==ACPI_MEMORY_RANGE || - addr->resource_type ==ACPI_IO_RANGE ) && - addr->address_length >0 ) { -return AE_OK ; - } -break ; - } -return AE_ERROR ; -} - -static acpi_status count_resource (struct acpi_resource *acpi_res,void *data) +static void validate_resources (struct device *dev,struct list_head *crs_res, +unsigned long type) { -struct pci_root_info *info = data; -struct acpi_resource_address64 addr; -acpi_status status; - - status =resource_to_addr (acpi_res, &addr); -if (ACPI_SUCCESS (status)) - info->res_num++; -return AE_OK ; -} - -static acpi_status setup_resource (struct acpi_resource *acpi_res,void *data) -{ -struct pci_root_info *info = data; -struct resource *res; -struct acpi_resource_address64 addr; -acpi_status status; -unsigned long flags; -u64 start, orig_end, end; - - status =resource_to_addr (acpi_res, &addr); -if (!ACPI_SUCCESS (status)) -return AE_OK ; - -if (addr.resource_type ==ACPI_MEMORY_RANGE ) { - flags =IORESOURCE_MEM ; -if (addr.info.mem.caching ==ACPI_PREFETCHABLE_MEMORY ) - flags |=IORESOURCE_PREFETCH ; - }else if (addr.resource_type ==ACPI_IO_RANGE ) { - flags =IORESOURCE_IO ; - }else -return AE_OK ; - - start = addr.minimum + addr.translation_offset; - orig_end = end = addr.maximum + addr.translation_offset; - -/* Exclude non-addressable range or non-addressable portion of range */ - end =min (end, (u64 )iomem_resource.end); -if (end <= start) { -dev_info (&info->bridge->dev, -"host bridge window [%#llx-%#llx] " -"(ignored, not CPU addressable)\n" , start, orig_end); -return AE_OK ; - }else if (orig_end != end) { -dev_info (&info->bridge->dev, -"host bridge window [%#llx-%#llx] " -"([%#llx-%#llx] ignored, not CPU addressable)\n" , - start, orig_end, end +1 , orig_end); - } +LIST_HEAD (list); +struct resource *res1, *res2, *root =NULL ; +struct resource_list_entry *tmp, *entry, *entry2; - res = &info->res[info->res_num]; - res->name = info->name; - res->flags = flags; - res->start = start; - res->end = end; - info->res_offset[info->res_num] = addr.translation_offset; - info->res_num++; +BUG_ON ((type & (IORESOURCE_MEM |IORESOURCE_IO )) ==0 ); + root = (type &IORESOURCE_MEM ) ? &iomem_resource : &ioport_resource; -if (!pci_use_crs) -dev_printk (KERN_DEBUG , &info->bridge->dev, -"host bridge window %pR (ignored)\n" , res); +list_splice_init (crs_res, &list); +resource_list_for_each_entry_safe (entry, tmp, &list) { +bool free = false; +resource_size_t end; -return AE_OK ; -} - -static void coalesce_windows (struct pci_root_info *info,unsigned long type) -{ -int i, j; -struct resource *res1, *res2; - -for (i =0 ; i < info->res_num; i++) { - res1 = &info->res[i]; + res1 = entry->res;if (!(res1->flags & type)) -continue ; + goto next; + +/* Exclude non-addressable range or non-addressable portion */ + end =min (res1->end, root->end); +if (end <= res1->start) { +dev_info (dev,"host bridge window [%#llx-%#llx] (ignored, not CPU addressable)\n" , + (unsigned long long )res1->start, + (unsigned long long )res1->end); + free = true; + goto next; + }else if (res1->end != end) { +dev_info (dev,"host bridge window [%#llx-%#llx] ([%#llx-%#llx] ignored, not CPU addressable)\n" , + (unsigned long long )res1->start, + (unsigned long long )res1->end, + (unsigned long long )end +1 , + (unsigned long long )res1->end); + res1->end = end; + } -for (j = i +1 ; j < info->res_num; j++) { - res2 = &info->res[j]; +resource_list_for_each_entry (entry2, crs_res) { + res2 = entry2->res;if (!(res2->flags & type))continue ;
@@ -353,118 +264,93 @@ static void coalesce_windows(struct pci_root_info *info, unsigned long type)if (resource_overlaps (res1, res2)) { res2->start =min (res1->start, res2->start); res2->end =max (res1->end, res2->end); -dev_info (&info->bridge->dev, -"host bridge window expanded to %pR; %pR ignored\n" , +dev_info (dev,"host bridge window expanded to %pR; %pR ignored\n" , res2, res1); - res1->flags =0 ; + free = true; + goto next; } } + +next: +resource_list_delete (entry); +if (free) +resource_list_free (entry); +else +resource_list_insert (crs_res, entry, true); } }static void add_resources (struct pci_root_info *info, -struct list_head *resources) +struct list_head *resources, +struct list_head *crs_res) { -int i; -struct resource *res, *root, *conflict; - -coalesce_windows (info,IORESOURCE_MEM ); -coalesce_windows (info,IORESOURCE_IO ); +struct resource_list_entry *entry, *tmp; +struct resource *res, *conflict, *root =NULL ; -for (i =0 ; i < info->res_num; i++) { - res = &info->res[i]; +validate_resources (&info->bridge->dev, crs_res,IORESOURCE_MEM ); +validate_resources (&info->bridge->dev, crs_res,IORESOURCE_IO ); +resource_list_for_each_entry_safe (entry, tmp, crs_res) { + res = entry->res;if (res->flags &IORESOURCE_MEM ) root = &iomem_resource;else if (res->flags &IORESOURCE_IO ) root = &ioport_resource;else -continue ; +BUG_ON (res); conflict =insert_resource_conflict (root, res); -if (conflict) +if (conflict) {dev_info (&info->bridge->dev,"ignoring host bridge window %pR (conflicts with %s %pR)\n" , res, conflict->name, conflict); -else -pci_add_resource_offset (resources, res, - info->res_offset[i]); +resource_list_delete (entry); +resource_list_free (entry); + } } -} -static void free_pci_root_info_res (struct pci_root_info *info) -{ -kfree (info->res); - info->res =NULL ; -kfree (info->res_offset); - info->res_offset =NULL ; - info->res_num =0 ; +list_splice_tail (crs_res, resources); } -static void __release_pci_root_info (struct pci_root_info *info) +static void release_pci_root_info (struct pci_host_bridge *bridge) { -int i;struct resource *res; +struct resource_list_entry *entry; +struct pci_root_info *info = bridge->release_data; -for (i =0 ; i < info->res_num; i++) { - res = &info->res[i]; - -if (!res->parent) -continue ; - -if (!(res->flags & (IORESOURCE_MEM |IORESOURCE_IO ))) -continue ; - -release_resource (res); +resource_list_for_each_entry (entry, &bridge->windows) { + res = entry->res; +if (res->parent && + (res->flags & (IORESOURCE_MEM |IORESOURCE_IO ))) +release_resource (res); } -free_pci_root_info_res (info); -teardown_mcfg_map (info); -kfree (info); } -static void release_pci_root_info (struct pci_host_bridge *bridge) -{ -struct pci_root_info *info = bridge->release_data; - -__release_pci_root_info (info); -} -static void probe_pci_root_info (struct pci_root_info *info,struct acpi_device *device, -int busnum,int domain) +int busnum,int domain, +struct list_head *list) { -size_t size; +int ret; +struct resource_list_entry *entry;sprintf (info->name,"PCI Bus %04x:%02x" , domain, busnum); info->bridge = device; - - info->res_num =0 ; -acpi_walk_resources (device->handle,METHOD_NAME__CRS , count_resource, - info); -if (!info->res_num) -return ; - - size =sizeof (*info->res) * info->res_num; - info->res =kzalloc_node (size,GFP_KERNEL , info->sd.node); -if (!info->res) { - info->res_num =0 ; -return ; - } - - size =sizeof (*info->res_offset) * info->res_num; - info->res_num =0 ; - info->res_offset =kzalloc_node (size,GFP_KERNEL , info->sd.node); -if (!info->res_offset) { -kfree (info->res); - info->res =NULL ; -return ; - } - -acpi_walk_resources (device->handle,METHOD_NAME__CRS , setup_resource, - info); + ret =acpi_dev_get_resources (device, list, + acpi_dev_filter_resource_type, + (void *)(IORESOURCE_IO |IORESOURCE_MEM )); +if (ret <0 ) +dev_warn (&device->dev, +"failed to parse _CRS method, error code %d.\n" , ret); +else if (ret ==0 ) +dev_dbg (&device->dev, +"no IO and memory resources present in _CRS.\n" ); +else +resource_list_for_each_entry (entry, list) + entry->res->name = info->name; }struct pci_bus *pci_acpi_scan_root (struct acpi_pci_root *root)
@@ -473,6 +359,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)struct pci_root_info *info;int domain = root->segment;int busnum = root->secondary.start; +struct resource_list_entry *res_entry; +LIST_HEAD (crs_res);LIST_HEAD (resources);struct pci_bus *bus;struct pci_sysdata *sd;
@@ -520,18 +408,22 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)memcpy (bus->sysdata, sd,sizeof (*sd));kfree (info); }else { -probe_pci_root_info (info, device, busnum, domain); -/* insert busn res at first */ pci_add_resource (&resources, &root->secondary); +/* * _CRS with no apertures is normal, so only fall back to * defaults or native bridge info if we're ignoring _CRS. */ -if (pci_use_crs) -add_resources (info, &resources); -else { -free_pci_root_info_res (info); +probe_pci_root_info (info, device, busnum, domain, &crs_res); +if (pci_use_crs) { +add_resources (info, &resources, &crs_res); + }else { +resource_list_for_each_entry (res_entry, &crs_res) +dev_printk (KERN_DEBUG , &device->dev, +"host bridge window %pR (ignored)\n" , + res_entry->res); +resource_list_free_list (&crs_res);x86_pci_root_bus_resources (busnum, &resources); }
@@ -546,8 +438,9 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)to_pci_host_bridge (bus->bridge), release_pci_root_info, info); }else { -pci_free_resource_list (&resources); -__release_pci_root_info (info); +resource_list_free_list (&resources); +teardown_mcfg_map (info); +kfree (info); } }
Signature · 1 line
1.7.10.4
RFC PATCH 5/19 ACPI: Provide union for address_space64 and ext_address_space64
In reply to Jiang LiuFrom: Thomas Gleixner <[email protected]>
address_space64 and ext_address_space64 share substracts just at different offsets. To unify the parsing functions implement the two structs as unions of their substructs, so we can extract the shared data.
--- include/acpi/acrestyp.h | 49 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 13 deletions(-)
include/acpi/acrestyp.h +36 -13
@@ -326,23 +326,46 @@ struct acpi_resource_address32 {struct acpi_resource_source resource_source; }; -struct acpi_resource_address64 { - ACPI_RESOURCE_ADDRESS_COMMON u64 granularity; -u64 minimum; -u64 maximum; -u64 translation_offset; +#define ACPI_RESOURCE_ADDRESS64_COMMON \ + u64 granularity; \ + u64 minimum; \ + u64 maximum; \ + u64 translation_offset; \ u64 address_length; -struct acpi_resource_source resource_source; + +struct acpi_resource_address64_common { +ACPI_RESOURCE_ADDRESS64_COMMON}; + +struct acpi_resource_address64 { +union { +struct { +ACPI_RESOURCE_ADDRESS_COMMON + ACPI_RESOURCE_ADDRESS64_COMMON +struct acpi_resource_source resource_source; + }; +struct { +struct acpi_resource_address base; +struct acpi_resource_address64_common addr; +struct acpi_resource_source resource_source; + } common; + }; };struct acpi_resource_extended_address64 { - ACPI_RESOURCE_ADDRESS_COMMON u8 revision_ID; -u64 granularity; -u64 minimum; -u64 maximum; -u64 translation_offset; -u64 address_length; -u64 type_specific; +union { +struct { +ACPI_RESOURCE_ADDRESS_COMMON + u8 revision_ID; +ACPI_RESOURCE_ADDRESS64_COMMON + u64 type_specific; + }; +struct { +struct acpi_resource_address base; +u8 revision_ID; +struct acpi_resource_address64_common addr; +u64 type_specific; + } common; + }; }; struct acpi_resource_extended_irq {
Signature · 1 line
1.7.10.4
RFC PATCH 10/19 ACPI: Normalize return value of resource parser functions
In reply to Jiang LiuNormalize return value of resource parse functions as:
1) return "true" if resource is assigned.
2) return "false" and IORESOURCE_DISABLED setting in res->flags if resource is unassigned.
3) return "false" and zeroing res->flags if it's not an valid or expected resource.
--- drivers/acpi/resource.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
drivers/acpi/resource.c +30 -0
@@ -80,6 +80,11 @@ static void acpi_dev_get_memresource(struct resource *res, u64 start, u64 len,* Check if the given ACPI resource object represents a memory resource and * if that's the case, use the information in it to populate the generic * resource object pointed to by @res. +* +* Return: +* 1) false with res->flags setting to zero: not the expected resource type +* 2) false with IORESOURCE_DISABLED in res->flags: valid unassigned resource +* 3) true: valid assigned resource */ bool acpi_dev_resource_memory (struct acpi_resource *ares,struct resource *res) {
@@ -107,6 +112,7 @@ bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res) fixed_memory32->write_protect);break ;default : + res->flags =0 ;return false; }
@@ -145,6 +151,11 @@ static void acpi_dev_get_ioresource(struct resource *res, u64 start, u64 len,* Check if the given ACPI resource object represents an I/O resource and * if that's the case, use the information in it to populate the generic * resource object pointed to by @res. +* +* Return: +* 1) false with res->flags setting to zero: not the expected resource type +* 2) false with IORESOURCE_DISABLED in res->flags: valid unassigned resource +* 3) true: valid assigned resource */ bool acpi_dev_resource_io (struct acpi_resource *ares,struct resource *res) {
@@ -165,6 +176,7 @@ bool acpi_dev_resource_io(struct acpi_resource *ares, struct resource *res) ACPI_DECODE_10);break ;default : + res->flags =0 ;return false; }
@@ -214,12 +226,18 @@ static bool acpi_decode_space(struct resource *res,* Check if the given ACPI resource object represents an address space resource * and if that's the case, use the information in it to populate the generic * resource object pointed to by @res. +* +* Return: +* 1) false with res->flags setting to zero: not the expected resource type +* 2) false with IORESOURCE_DISABLED in res->flags: valid unassigned resource +* 3) true: valid assigned resource */ bool acpi_dev_resource_address_space (struct acpi_resource *ares,struct resource *res) {struct acpi_resource_address64 addr; + res->flags =0 ;if (ACPI_FAILURE (acpi_resource_to_address64 (ares, &addr)))return false;
@@ -235,12 +253,18 @@ EXPORT_SYMBOL_GPL(acpi_dev_resource_address_space);* Check if the given ACPI resource object represents an extended address space * resource and if that's the case, use the information in it to populate the * generic resource object pointed to by @res. +* +* Return: +* 1) false with res->flags setting to zero: not the expected resource type +* 2) false with IORESOURCE_DISABLED in res->flags: valid unassigned resource +* 3) true: valid assigned resource */ bool acpi_dev_resource_ext_address_space (struct acpi_resource *ares,struct resource *res) {struct acpi_resource_extended_address64 *ext_addr; + res->flags =0 ;if (ares->type !=ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 )return false;
@@ -338,6 +362,11 @@ static void acpi_dev_get_irqresource(struct resource *res, u32 gsi,* represented by the resource and populate the generic resource object pointed * to by @res accordingly. If the registration of the GSI is not successful, * IORESOURCE_DISABLED will be set it that object's flags. +* +* Return: +* 1) false with res->flags setting to zero: not the expected resource type +* 2) false with IORESOURCE_DISABLED in res->flags: valid unassigned resource +* 3) true: valid assigned resource */ bool acpi_dev_resource_interrupt (struct acpi_resource *ares,int index,struct resource *res)
@@ -371,6 +400,7 @@ bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index, ext_irq->sharable, false);break ;default : + res->flags =0 ;return false; }
Signature · 1 line
1.7.10.4
Quoted 8 lines · Jiang Liu
During enabling ACPI based IOAPIC hotplug, Thomas noticed some issues in ACPI resource parsing interfaces. So this is an effort to improve them.
Patch 1-12 improve ACPI resource parsing interfaces and also fixes some bugs.
Patch 13-19 try to share the common data structure
resource_list_entrybetween PCI and ACPI. It may also be shared with PNP too.
I've looked at the patches briefly.
I like the changes at the general level, but there are some things I'm potentially concerned about in them. Need more time to look at them, I'll do my best to do that this week while at the conference.
Quoted 54 lines
The patchset is based on v3.19-rc3 and you may get it from:
https://github.com/jiangliu/linux.gitacpires_v1Jiang Liu (11):
ACPI: Fix a bug in parsing ACPI Memroy24 resource
ACPI: Normalize return value of resource parser functions
ACPI: Set flagIORESOURCE_UNSETfor unassigned resources
ACPI: Enforce stricter checks for address space descriptors
ACPI: Return translation offset when parsing ACPI address space
resources
ACPI: Translate resource into master side address for bridge window
resources
ACPI: Add field offset to structresource_list_entry
ACPI: Introduce helper functionacpi_dev_filter_resource_type()
resources: Move structresource_list_entryfrom ACPI into resource
core
PCI: Use common resource list management code instead of private
implementation
x86/PCI/ACPI: Use common ACPI resource interfaces to simplify
implementationThomas Gleixner (8):
ACPI: Remove redundant check in function
acpi_dev_resource_address_space()
ACPI: Implement proper length checks for mem resources
ACPI: Use the length check for io resources as well
ACPI: Let the parser return false for disabled resources
ACPI: Provide union foraddress_space64andext_address_space64
ACPI: Unify the parsing ofaddress_spaceandext_address_space
ACPI: Move the window flag logic to the combined parser
ACPI: Add prefetch decoding to the address space parserarch/arm/kernel/bios32.c | 5 +- arch/x86/pci/acpi.c | 297 ++++++++++--------------------- arch/x86/pci/bus_numa.c | 4 +- drivers/acpi/acpi_lpss.c | 6 +- drivers/acpi/acpi_platform.c | 2 +- drivers/acpi/resource.c | 333 ++++++++++++++++++++++------------- drivers/dma/acpi-dma.c | 8 +- drivers/pci/bus.c | 18 +- drivers/pci/host-bridge.c | 8 +- drivers/pci/host/pci-host-generic.c | 4 +- drivers/pci/host/pci-xgene.c | 4 +- drivers/pci/host/pcie-xilinx.c | 4 +- drivers/pci/probe.c | 10 +- drivers/pnp/pnpacpi/rsparser.c | 4 +- include/acpi/acrestyp.h | 49 ++++-- include/linux/acpi.h | 12 +- include/linux/ioport.h | 25 +++ include/linux/pci.h | 8 +- kernel/resource.c | 48 +++++ 19 files changed, 452 insertions(+), 397 deletions(-)
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [RFC Patch 16/19] ACPI: Introduce helper function acpi_dev_filter_resource_type()
In reply to Jiang LiuQuoted 19 lines · Jiang Liu
Introduce helper function
acpi_dev_filter_resource_type(), which may be used byacpi_dev_get_resources()to filer out resource based on resource type.Signed-off-by Jiang Liu <[email protected]>--- drivers/acpi/resource.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/acpi.h | 1 + 2 files changed, 55 insertions(+)drivers/acpi/resource.c +1
-0@@ -570,3 +570,57 @@ int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list,return c.count; }EXPORT_SYMBOL_GPL (acpi_dev_get_resources); +
drivers/acpi/resource.c int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list, · line 583
Quoted 10 lines
drivers/acpi/resource.c +10
-0+/** +* acpi_dev_filter_resource_type - Filter ACPI resource according to resource +* types +* @ares: Input ACPI resource object. +* @arg: Valid resource types of IORESOURCE_XXX +* +* This is a hepler function to support acpi_dev_get_resources(), which filters +* ACPI resource objects according to resource types. +*/ +int acpi_dev_filter_resource_type (struct acpi_resource *ares,void *arg)
Why is the filter a void pointer instead of an simple unsigned long? That does not make any sense as you convert it to unsigned long right away:
drivers/acpi/resource.c int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list, · line 585
Quoted 2 lines
drivers/acpi/resource.c +2
-0+{ +unsigned long type =0 , types = (unsigned long )arg;
So this should be:
int acpi_dev_filter_resource_type(struct acpi_resource *ares, unsigned long type_mask)
or something like that.
Thanks,
tglx
Re: [RFC Patch 16/19] ACPI: Introduce helper function acpi_dev_filter_resource_type()
Quoted 35 lines · Thomas Gleixner
Quoted 19 lines · Jiang Liu
Introduce helper function
acpi_dev_filter_resource_type(), which may be used byacpi_dev_get_resources()to filer out resource based on resource type.Signed-off-by Jiang Liu <[email protected]>--- drivers/acpi/resource.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/acpi.h | 1 + 2 files changed, 55 insertions(+)drivers/acpi/resource.c +1
-0@@ -570,3 +570,57 @@ int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list,return c.count; }EXPORT_SYMBOL_GPL (acpi_dev_get_resources); +drivers/acpi/resource.c int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list, · line 583
Quoted 10 lines
drivers/acpi/resource.c +10
-0+/** +* acpi_dev_filter_resource_type - Filter ACPI resource according to resource +* types +* @ares: Input ACPI resource object. +* @arg: Valid resource types of IORESOURCE_XXX +* +* This is a hepler function to support acpi_dev_get_resources(), which filters +* ACPI resource objects according to resource types. +*/ +int acpi_dev_filter_resource_type (struct acpi_resource *ares,void *arg)Why is the filter a void pointer instead of an simple unsigned long? That does not make any sense as you convert it to unsigned long right away:
Quoted 8 lines
drivers/acpi/resource.c int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list, · line 585
Quoted 2 lines
drivers/acpi/resource.c +2
-0+{ +unsigned long type =0 , types = (unsigned long )arg;So this should be:
int
acpi_dev_filter_resource_type(struct acpi_resource *ares, unsigned long type_mask)or something like that.
Hi Thomas,
I used void * instead of unsigned long for type_mask soacpi_dev_filter_resource_type() could directly used by acpi_dev_get_resources(). Otherwise we need to use something like acpi_dev_get_resources(..., (void *)acpi_dev_filter_resource_type, ...). I will find a way to solve this:)
Regards!
Gerry
Quoted 5 lines
Thanks,
tglx
Quoted 7 lines · Rafael J. Wysocki
Quoted 6 lines · Jiang Liu
During enabling ACPI based IOAPIC hotplug, Thomas noticed some issues in ACPI resource parsing interfaces. So this is an effort to improve them.
Patch 1-12 improve ACPI resource parsing interfaces and also fixes some bugs.
Quoted 8 lines
Quoted 2 lines
Patch 13-19 try to share the common data structure
resource_list_entrybetween PCI and ACPI. It may also be shared with PNP too.I've looked at the patches briefly.
I like the changes at the general level, but there are some things I'm potentially concerned about in them. Need more time to look at them, I'll do my best to do that this week while at the conference.
Hi Rafael,
Thanks for your time. Any comments about this series?
Regards,
Gerry
Quoted 56 lines
Quoted 55 lines
The patchset is based on v3.19-rc3 and you may get it from:
https://github.com/jiangliu/linux.gitacpires_v1Jiang Liu (11):
ACPI: Fix a bug in parsing ACPI Memroy24 resource
ACPI: Normalize return value of resource parser functions
ACPI: Set flagIORESOURCE_UNSETfor unassigned resources
ACPI: Enforce stricter checks for address space descriptors
ACPI: Return translation offset when parsing ACPI address space
resources
ACPI: Translate resource into master side address for bridge window
resources
ACPI: Add field offset to structresource_list_entry
ACPI: Introduce helper functionacpi_dev_filter_resource_type()
resources: Move structresource_list_entryfrom ACPI into resource
core
PCI: Use common resource list management code instead of private
implementation
x86/PCI/ACPI: Use common ACPI resource interfaces to simplify
implementationThomas Gleixner (8):
ACPI: Remove redundant check in function
acpi_dev_resource_address_space()
ACPI: Implement proper length checks for mem resources
ACPI: Use the length check for io resources as well
ACPI: Let the parser return false for disabled resources
ACPI: Provide union foraddress_space64andext_address_space64
ACPI: Unify the parsing ofaddress_spaceandext_address_space
ACPI: Move the window flag logic to the combined parser
ACPI: Add prefetch decoding to the address space parserarch/arm/kernel/bios32.c | 5 +- arch/x86/pci/acpi.c | 297 ++++++++++--------------------- arch/x86/pci/bus_numa.c | 4 +- drivers/acpi/acpi_lpss.c | 6 +- drivers/acpi/acpi_platform.c | 2 +- drivers/acpi/resource.c | 333 ++++++++++++++++++++++------------- drivers/dma/acpi-dma.c | 8 +- drivers/pci/bus.c | 18 +- drivers/pci/host-bridge.c | 8 +- drivers/pci/host/pci-host-generic.c | 4 +- drivers/pci/host/pci-xgene.c | 4 +- drivers/pci/host/pcie-xilinx.c | 4 +- drivers/pci/probe.c | 10 +- drivers/pnp/pnpacpi/rsparser.c | 4 +- include/acpi/acrestyp.h | 49 ++++-- include/linux/acpi.h | 12 +- include/linux/ioport.h | 25 +++ include/linux/pci.h | 8 +- kernel/resource.c | 48 +++++ 19 files changed, 452 insertions(+), 397 deletions(-)
Quoted 11 lines · Jiang Liu
Quoted 10 lines · Rafael J. Wysocki
Quoted 8 lines · Jiang Liu
During enabling ACPI based IOAPIC hotplug, Thomas noticed some issues in ACPI resource parsing interfaces. So this is an effort to improve them.
Patch 1-12 improve ACPI resource parsing interfaces and also fixes some bugs.
Patch 13-19 try to share the common data structure
resource_list_entrybetween PCI and ACPI. It may also be shared with PNP too.
Quoted 7 lines
Quoted 5 lines
I've looked at the patches briefly.
I like the changes at the general level, but there are some things I'm potentially concerned about in them. Need more time to look at them, I'll do my best to do that this week while at the conference.
Hi Rafael,
Thanks for your time. Any comments about this series?
Please give me some more time.
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [RFC Patch 05/19] ACPI: Provide union for address_space64 and ext_address_space64
In reply to Jiang LiuQuoted 9 lines · Jiang Liu
From: Thomas Gleixner <[email protected]>
address_space64andext_address_space64share substracts just at different offsets. To unify the parsing functions implement the two structs as unions of their substructs, so we can extract the shared data.Signed-off-by Thomas Gleixner <[email protected]>Signed-off-by Jiang Liu <[email protected]>
This is ACPICA code, so if we change this, either we'll diverge from the upstream (which is highly undesirable), or we'll have to change it for the majority of OSes on the planet (all except Windows).
Lv, Bob, David, any comments here?
Quoted 69 lines
--- include/acpi/acrestyp.h | 49 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 13 deletions(-)include/acpi/acrestyp.h +36
-13@@ -326,23 +326,46 @@ struct acpi_resource_address32 {struct acpi_resource_source resource_source; }; -struct acpi_resource_address64 { - ACPI_RESOURCE_ADDRESS_COMMON u64 granularity; -u64 minimum; -u64 maximum; -u64 translation_offset; +#define ACPI_RESOURCE_ADDRESS64_COMMON \ + u64 granularity; \ + u64 minimum; \ + u64 maximum; \ + u64 translation_offset; \ u64 address_length; -struct acpi_resource_source resource_source; + +struct acpi_resource_address64_common { +ACPI_RESOURCE_ADDRESS64_COMMON}; + +struct acpi_resource_address64 { +union { +struct { +ACPI_RESOURCE_ADDRESS_COMMON + ACPI_RESOURCE_ADDRESS64_COMMON +struct acpi_resource_source resource_source; + }; +struct { +struct acpi_resource_address base; +struct acpi_resource_address64_common addr; +struct acpi_resource_source resource_source; + } common; + }; };struct acpi_resource_extended_address64 { - ACPI_RESOURCE_ADDRESS_COMMON u8 revision_ID; -u64 granularity; -u64 minimum; -u64 maximum; -u64 translation_offset; -u64 address_length; -u64 type_specific; +union { +struct { +ACPI_RESOURCE_ADDRESS_COMMON + u8 revision_ID; +ACPI_RESOURCE_ADDRESS64_COMMON + u64 type_specific; + }; +struct { +struct acpi_resource_address base; +u8 revision_ID; +struct acpi_resource_address64_common addr; +u64 type_specific; + } common; + }; }; struct acpi_resource_extended_irq {
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [RFC Patch 08/19] ACPI: Add prefetch decoding to the address space parser
In reply to Jiang LiuQuoted 4 lines · Jiang Liu
From: Thomas Gleixner <[email protected]>
Add support of PREFETCH attributre to ACPI address space and extended address space parser.
This potentially enables untested configurations which tends to uncover bugs, so I'm concerned.
What's the possible impact of this?
Quoted 21 lines
Signed-off-by Thomas Gleixner <[email protected]>Signed-off-by Jiang Liu <[email protected]>--- drivers/acpi/resource.c | 3 +++ 1 file changed, 3 insertions(+)drivers/acpi/resource.c +3
-0@@ -200,6 +200,9 @@ static bool acpi_decode_space(struct resource *res,if (base->producer_consumer ==ACPI_PRODUCER ) res->flags |=IORESOURCE_WINDOW ; +if (base->info.mem.caching ==ACPI_PREFETCHABLE_MEMORY ) + res->flags |=IORESOURCE_PREFETCH ; +return !(res->flags &IORESOURCE_DISABLED ); }
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [RFC Patch 09/19] ACPI: Fix a bug in parsing ACPI Memroy24 resource
In reply to Jiang LiuQuoted 3 lines · Jiang Liu
According to ACPI spec 5, section 6.4.3.1 "24-Bit Memory Range Descriptor", minimum, maximum and
address_lengthfield in structacpi_resource_memory24is in granularity of 256-bytes. So shift 8-bit left to get correct address.
Are you sure about this?
I'm reading ACPI 5.1 ATM and (on page 316) it only says about the range length being in 256 byte blocks.
Quoted 21 lines
Signed-off-by Jiang Liu <[email protected]>--- drivers/acpi/resource.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/acpi/resource.c +2
-2@@ -90,8 +90,8 @@ bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res)switch (ares->type) {case ACPI_RESOURCE_TYPE_MEMORY24 : memory24 = &ares->data.memory24; -acpi_dev_get_memresource (res, memory24->minimum, - memory24->address_length, +acpi_dev_get_memresource (res, memory24->minimum <<8 , + memory24->address_length <<8 , memory24->write_protect);break ;case ACPI_RESOURCE_TYPE_MEMORY32 :
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [RFC Patch 12/19] ACPI: Enforce stricter checks for address space descriptors
In reply to Jiang LiuQuoted 2 lines · Jiang Liu
Enforce stricter checks for address space descriptors according to ACPI spec.
So is the spec the only reason for doing this? If so, I'd say don't.
Quoted 25 lines
Signed-off-by Jiang Liu <[email protected]>--- drivers/acpi/resource.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/acpi/resource.c +8
-0@@ -192,6 +192,14 @@ static bool acpi_decode_space(struct resource *res,bool wp = base->info.mem.write_protect;u64 len = addr->address_length; +/* +* Filter out invalid descriptor according to ACPI Spec 5.0, section +* 6.4.3.5 Address Space Resource Descriptors. +*/ +if ((base->min_address_fixed != base->max_address_fixed && len) || + (base->min_address_fixed && base->max_address_fixed && !len)) +return false; + res->start = addr->minimum; res->end = addr->maximum;
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [RFC Patch 14/19] ACPI: Translate resource into master side address for bridge window resources
In reply to Jiang LiuQuoted 18 lines · Jiang Liu
Add
translation_offsetinto the result address for bridge window resources to form the master side address.Currently acpi_dev_resource_{ext_}address_space() are only used for devices instead of bridges, so it won't break current users. Later it will be used to support PCI host bridge drivers.
Signed-off-by Jiang Liu <[email protected]>--- drivers/acpi/resource.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)drivers/acpi/resource.c +0
-0@@ -203,6 +203,20 @@ static bool acpi_decode_space(struct resource *res, resource_size_t *offset, res->start = addr->minimum;
drivers/acpi/resource.c static bool acpi_decode_space(struct resource *res, resource_size_t *offset, · line 213
Quoted 10 lines
drivers/acpi/resource.c +8
-0res->end = addr->maximum; +/* +* For bridges that translate addresses across the bridge, +* translation_offset is the offset that must be added to the +* address on the secondary side to obtain the address on the +* primary side. Non-bridge devices must list 0 for all Address +* Translation offset bits. +*/ +if (base->producer_consumer ==ACPI_PRODUCER ) {
OK, so the assumption is that this check is never true in the current code, right?
drivers/acpi/resource.c static bool acpi_decode_space(struct resource *res, resource_size_t *offset, · line 216
Quoted 3 lines
drivers/acpi/resource.c +3
-0+ res->start += addr->translation_offset; + res->end += addr->translation_offset; + }else if (addr->translation_offset) {
And won't this break anything even if so?
Quoted 7 lines
drivers/acpi/resource.c +3
-0+return false; + } +switch (base->resource_type) {case ACPI_MEMORY_RANGE :acpi_dev_memresource_flags (res, len, wp);
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [RFC Patch 15/19] ACPI: Add field offset to struct resource_list_entry
In reply to Jiang LiuQuoted 63 lines · Jiang Liu
Add field offset to struct
resource_list_entryto host address space translation offset so it could be used to represent bridge resources.Signed-off-by Jiang Liu <[email protected]>--- drivers/acpi/resource.c | 13 ++++++++----- include/linux/acpi.h | 1 + 2 files changed, 9 insertions(+), 5 deletions(-)drivers/acpi/resource.c +8
-5@@ -462,7 +462,8 @@ struct res_proc_context { };static acpi_status acpi_dev_new_resource_entry (struct resource *r, -struct res_proc_context *c) +struct res_proc_context *c, +resource_size_t offset) {struct resource_list_entry *rentry;@@ -472,6 +473,7 @@ static acpi_status acpi_dev_new_resource_entry(struct resource *r,return AE_NO_MEMORY ; } rentry->res = *r; + rentry->offset = offset;list_add_tail (&rentry->node, c->list); c->count++;return AE_OK ;@@ -480,6 +482,7 @@ static acpi_status acpi_dev_new_resource_entry(struct resource *r,static acpi_status acpi_dev_process_resource (struct acpi_resource *ares,void *context) { +resource_size_t offset =0 ;struct res_proc_context *c = context;struct resource r;int i;@@ -500,14 +503,14 @@ static acpi_status acpi_dev_process_resource(struct acpi_resource *ares,if (acpi_dev_resource_memory (ares, &r) ||acpi_dev_resource_io (ares, &r) - ||acpi_dev_resource_address_space (ares, &r,NULL ) - ||acpi_dev_resource_ext_address_space (ares, &r,NULL )) -return acpi_dev_new_resource_entry (&r, c); + ||acpi_dev_resource_address_space (ares, &r, &offset) + ||acpi_dev_resource_ext_address_space (ares, &r, &offset)) +return acpi_dev_new_resource_entry (&r, c, offset);for (i =0 ;acpi_dev_resource_interrupt (ares, i, &r); i++) {acpi_status status; - status =acpi_dev_new_resource_entry (&r, c); + status =acpi_dev_new_resource_entry (&r, c,0 );if (ACPI_FAILURE (status))return status; }include/linux/acpi.h +0
-0
include/linux/acpi.h bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index, · line 303
Quoted 4 lines
include/linux/acpi.h +1
-0@@ -300,6 +300,7 @@ bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index,struct resource_list_entry {struct list_head node;struct resource res; +resource_size_t offset;
Well, so instead of adding the offset thing here and there, wouldn't it be cleaner to introduce something like
struct ext_resource {
sturct resource res;
resource_size_t offset;
};and use struct ext_resource instead of struct resource where an offset is needed?
Just a thought ...
Quoted 4 lines
include/linux/acpi.h +0
-0};void acpi_dev_free_resource_list (struct list_head *list);
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [RFC Patch 17/19] resources: Move struct resource_list_entry from ACPI into resource core
In reply to Jiang LiuQuoted 171 lines · Jiang Liu
Currently ACPI, PCI and pnp all implement the same resource list management with different data structure. We need to transfer from one data structure into another when passing resources from one subsystem into another subsystem. Sp move struct
resource_list_entryfrom ACPI into resource core, so it could be reused by different subystems and avoid the data structure conversion.Signed-off-by Jiang Liu <[email protected]>--- drivers/acpi/acpi_lpss.c | 6 +++--- drivers/acpi/acpi_platform.c | 2 +- drivers/acpi/resource.c | 13 ++++-------- drivers/dma/acpi-dma.c | 8 +++---- include/linux/acpi.h | 6 ------ include/linux/ioport.h | 25 ++++++++++++++++++++++ kernel/resource.c | 48 ++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 85 insertions(+), 23 deletions(-)drivers/acpi/acpi_lpss.c +3
-3@@ -333,12 +333,12 @@ static int acpi_lpss_create_device(struct acpi_device *adev, goto err_out;list_for_each_entry (rentry, &resource_list, node) -if (resource_type (&rentry->res) ==IORESOURCE_MEM ) { +if (resource_type (rentry->res) ==IORESOURCE_MEM ) {if (dev_desc->prv_size_override) pdata->mmio_size = dev_desc->prv_size_override;else - pdata->mmio_size =resource_size (&rentry->res); - pdata->mmio_base =ioremap (rentry->res.start, + pdata->mmio_size =resource_size (rentry->res); + pdata->mmio_base =ioremap (rentry->res->start, pdata->mmio_size);break ; }drivers/acpi/acpi_platform.c +1
-1@@ -71,7 +71,7 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev) } count =0 ;list_for_each_entry (rentry, &resource_list, node) - resources[count++] = rentry->res; + resources[count++] = *rentry->res;acpi_dev_free_resource_list (&resource_list); }drivers/acpi/resource.c +4
-9@@ -444,12 +444,7 @@ EXPORT_SYMBOL_GPL(acpi_dev_resource_interrupt);*/ void acpi_dev_free_resource_list (struct list_head *list) { -struct resource_list_entry *rentry, *re; - -list_for_each_entry_safe (rentry, re, list, node) { -list_del (&rentry->node); -kfree (rentry); - } +resource_list_free_list (list); }EXPORT_SYMBOL_GPL (acpi_dev_free_resource_list);@@ -467,14 +462,14 @@ static acpi_status acpi_dev_new_resource_entry(struct resource *r, {struct resource_list_entry *rentry; - rentry =kmalloc (sizeof (*rentry),GFP_KERNEL ); + rentry =resource_list_alloc (NULL ,0 );if (!rentry) { c->error = -ENOMEM ;return AE_NO_MEMORY ; } - rentry->res = *r; + *rentry->res = *r; rentry->offset = offset; -list_add_tail (&rentry->node, c->list); +resource_list_insert (c->list, rentry, true); c->count++;return AE_OK ; }drivers/dma/acpi-dma.c +4
-4@@ -56,10 +56,10 @@ static int acpi_dma_parse_resource_group(const struct acpi_csrt_group *grp,return 0 ;list_for_each_entry (rentry, &resource_list, node) { -if (resource_type (&rentry->res) ==IORESOURCE_MEM ) - mem = rentry->res.start; -else if (resource_type (&rentry->res) ==IORESOURCE_IRQ ) - irq = rentry->res.start; +if (resource_type (rentry->res) ==IORESOURCE_MEM ) + mem = rentry->res->start; +else if (resource_type (rentry->res) ==IORESOURCE_IRQ ) + irq = rentry->res->start; }acpi_dev_free_resource_list (&resource_list);include/linux/acpi.h +0
-6@@ -297,12 +297,6 @@ 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); -struct resource_list_entry { -struct list_head node; -struct resource res; -resource_size_t offset; -}; -void acpi_dev_free_resource_list (struct list_head *list); int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list, int (*preproc)(struct acpi_resource *, void *),include/linux/ioport.h +25
-0@@ -11,6 +11,7 @@#ifndef __ASSEMBLY__#include <linux/compiler.h> #include <linux/types.h> +/* * Resources are tree-like, allowing * nesting etc.. @@ -255,6 +256,30 @@ static inline bool resource_overlaps(struct resource *r1, struct resource *r2)return (r1->start <= r2->end && r1->end >= r2->start); } +/* +* Common resource list management data structure and interfaces to support +* ACPI, PNP and PCI host bridge etc. +*/ +struct resource_list_entry { +struct list_head node; +struct resource *res;/* In master (CPU) address space */ +resource_size_t offset;/* Translation offset for bridge */ +struct resource __res;/* Default storage for res */ +}; + +extern struct resource_list_entry *resource_list_alloc (struct resource *res, +size_t extra_size); +extern void resource_list_free (struct resource_list_entry *entry); +extern void resource_list_insert (struct list_head *head, +struct resource_list_entry *entry,bool tail); +extern void resource_list_delete (struct resource_list_entry *entry); +extern void resource_list_free_list (struct list_head *head); + +#define resource_list_for_each_entry (entry, list) \ + list_for_each_entry((entry), (list), node) + +#define resource_list_for_each_entry_safe (entry, tmp, list) \ + list_for_each_entry_safe((entry), (tmp), (list), node)#endif /* __ASSEMBLY__ */ #endif /* _LINUX_IOPORT_H */ kernel/resource.c +0
-0
kernel/resource.c int iomem_is_exclusive(u64 addr) · line 1533
Quoted 5 lines
kernel/resource.c +2
-0@@ -1529,6 +1529,54 @@ int iomem_is_exclusive(u64 addr)return err; } +struct resource_list_entry *resource_list_alloc (struct resource *res, +size_t extra_size)
What about create_resource_list_entry()? Less confusing surely.
Quoted 8 lines
kernel/resource.c +8
-0+{ +struct resource_list_entry *entry; + + entry =kzalloc (sizeof (*entry) + extra_size,GFP_KERNEL ); +if (entry) { +INIT_LIST_HEAD (&entry->node); + entry->res = res ? res : &entry->__res; + }
kernel/resource.c int iomem_is_exclusive(u64 addr) · line 1551
Quoted 10 lines
kernel/resource.c +10
-0+ +return entry; +} +EXPORT_SYMBOL (resource_list_alloc); + +void resource_list_free (struct resource_list_entry *entry) +{ +kfree (entry); +} +EXPORT_SYMBOL (resource_list_free);
Well, I'm not sure I like this. The name suggests that it would free the entire list and what's wrong with using kfree() directly on "entry" anyway?
kernel/resource.c int iomem_is_exclusive(u64 addr) · line 1554
Quoted 3 lines
kernel/resource.c +3
-0+ +void resource_list_insert (struct list_head *head, +struct resource_list_entry *entry,bool tail)
I would call this resource_list_add() if anything.
Also it may be better to have two helpers, one for "add" and one for "add_tail" (and perhaps define them as static inline?).
And why change the ordering between "head" and "entry". That's alomost guaranteed to confuse people.
kernel/resource.c int iomem_is_exclusive(u64 addr) · line 1567
Quoted 13 lines
kernel/resource.c +13
-0+{ +if (tail) +list_add_tail (&entry->node, head); +else +list_add (&entry->node, head); +} +EXPORT_SYMBOL (resource_list_insert); + +void resource_list_delete (struct resource_list_entry *entry) +{ +list_del (&entry->node); +} +EXPORT_SYMBOL (resource_list_delete);
Couldn't this be a static inline)?
Or maybe we can combine the "list_del" with "kfree" in one function?
Quoted 16 lines
kernel/resource.c +12
-0+ +void resource_list_free_list (struct list_head *head) +{ +struct resource_list_entry *entry, *tmp; + +list_for_each_entry_safe (entry, tmp, head, node) { +list_del (&entry->node); +resource_list_free (entry); + } +} +EXPORT_SYMBOL (resource_list_free_list); +static int __init strict_iomem (char *str) {if (strstr (str,"relaxed" ))
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [RFC Patch 09/19] ACPI: Fix a bug in parsing ACPI Memroy24 resource
In reply to Rafael J. WysockiQuoted 9 lines · Rafael J. Wysocki
Quoted 3 lines · Jiang Liu
According to ACPI spec 5, section 6.4.3.1 "24-Bit Memory Range Descriptor", minimum, maximum and
address_lengthfield in structacpi_resource_memory24is in granularity of 256-bytes. So shift 8-bit left to get correct address.Are you sure about this?
I'm reading ACPI 5.1 ATM and (on page 316) it only says about the range length being in 256 byte blocks.
Hi Rafael,
According to ACPI spec 5.a sec 6.4.3.1,
Byte 4, "Range minimum base address, _MIN, bits[7:0]", "Address bits[15:8] of the minimum base memory address for which
the card may be configured."
Byte 5, "Range minimum base address, _MIN, bits[15:8]", "Address bits[23:16] of the minimum base memory address for
which the card may be configured".
Byte 10, "Range length, _LEN, bits[7:0]", "This field contains the lower eight bits of the memory range length. The range length provides the length of the memory range in 256 byte blocks."
Byte 11, "Range length, _LEN, bits[15:8]", "This field contains the upper eight bits of the memory range length. The range length field provides the length of the memory range in 256 byte blocks."
That means _MIN defines bits[23:8] of the minimal address, and _LEN is in granularity of 256 bytes, so shift them left by 8 bits. Regards,
Gerry
Quoted 23 lines
Quoted 22 lines
Signed-off-by Jiang Liu <[email protected]>--- drivers/acpi/resource.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/acpi/resource.c +2
-2@@ -90,8 +90,8 @@ bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res)switch (ares->type) {case ACPI_RESOURCE_TYPE_MEMORY24 : memory24 = &ares->data.memory24; -acpi_dev_get_memresource (res, memory24->minimum, - memory24->address_length, +acpi_dev_get_memresource (res, memory24->minimum <<8 , + memory24->address_length <<8 , memory24->write_protect);break ;case ACPI_RESOURCE_TYPE_MEMORY32 :
Re: [RFC Patch 12/19] ACPI: Enforce stricter checks for address space descriptors
In reply to Rafael J. WysockiQuoted 5 lines · Rafael J. Wysocki
Quoted 2 lines · Jiang Liu
Enforce stricter checks for address space descriptors according to ACPI spec.
So is the spec the only reason for doing this? If so, I'd say don't.
Hi Rafael,
Yes, it's just for spec. I will drop this patch to avoid
regressions.
Regards!
Gerry
Quoted 27 lines
Quoted 26 lines
Signed-off-by Jiang Liu <[email protected]>--- drivers/acpi/resource.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/acpi/resource.c +8
-0@@ -192,6 +192,14 @@ static bool acpi_decode_space(struct resource *res,bool wp = base->info.mem.write_protect;u64 len = addr->address_length; +/* +* Filter out invalid descriptor according to ACPI Spec 5.0, section +* 6.4.3.5 Address Space Resource Descriptors. +*/ +if ((base->min_address_fixed != base->max_address_fixed && len) || + (base->min_address_fixed && base->max_address_fixed && !len)) +return false; + res->start = addr->minimum; res->end = addr->maximum;
Re: [RFC Patch 09/19] ACPI: Fix a bug in parsing ACPI Memroy24 resource
In reply to Jiang LiuQuoted 10 lines · Jiang Liu
Quoted 9 lines · Rafael J. Wysocki
Quoted 3 lines · Jiang Liu
According to ACPI spec 5, section 6.4.3.1 "24-Bit Memory Range Descriptor", minimum, maximum and
address_lengthfield in structacpi_resource_memory24is in granularity of 256-bytes. So shift 8-bit left to get correct address.Are you sure about this?
I'm reading ACPI 5.1 ATM and (on page 316) it only says about the range length being in 256 byte blocks.
Quoted 8 lines
Hi Rafael,
According to ACPI spec 5.a sec 6.4.3.1,Byte 4, "Range minimum base address,
_MIN, bits[7:0]", "Address bits[15:8] of the minimum base memory address for which the card may be configured."
Byte 5, "Range minimum base address,_MIN, bits[15:8]", "Address bits[23:16] of the minimum base memory address for which the card may be configured".
Ah, OK.
So bits [15:0] of the _MIN field are bits [23:8] of the address. Tricky that.
I wonder why no problems with that have ever been reported ...
Quoted 40 lines
Byte 10, "Range length,
_LEN, bits[7:0]", "This field contains the lower eight bits of the memory range length. The range length provides the length of the memory range in 256 byte blocks."
Byte 11, "Range length,_LEN, bits[15:8]", "This field contains the upper eight bits of the memory range length. The range length field provides the length of the memory range in 256 byte blocks."That means
_MINdefines bits[23:8] of the minimal address, and_LENis in granularity of 256 bytes, so shift them left by 8 bits. Regards,
GerryQuoted 6 lines
Quoted 6 lines
Signed-off-by Jiang Liu <[email protected]>--- drivers/acpi/resource.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Quoted 17 lines
Quoted 6 lines
drivers/acpi/resource.c +0
-0drivers/acpi/resource.c bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res) · line 97
Quoted 10 lines
drivers/acpi/resource.c +2
-2@@ -90,8 +90,8 @@ bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res)switch (ares->type) {case ACPI_RESOURCE_TYPE_MEMORY24 : memory24 = &ares->data.memory24; -acpi_dev_get_memresource (res, memory24->minimum, - memory24->address_length, +acpi_dev_get_memresource (res, memory24->minimum <<8 , + memory24->address_length <<8 , memory24->write_protect);break ;case ACPI_RESOURCE_TYPE_MEMORY32 :--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [RFC Patch 12/19] ACPI: Enforce stricter checks for address space descriptors
In reply to Jiang LiuQuoted 9 lines · Jiang Liu
Quoted 5 lines · Rafael J. Wysocki
Quoted 2 lines · Jiang Liu
Enforce stricter checks for address space descriptors according to ACPI spec.
So is the spec the only reason for doing this? If so, I'd say don't.
Hi Rafael,
Yes, it's just for spec. I will drop this patch to avoid
regressions.
A debug message covering that may be useful, though, in case things don't work and this is the reason.
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [RFC Patch 09/19] ACPI: Fix a bug in parsing ACPI Memroy24 resource
In reply to Rafael J. WysockiQuoted 20 lines · Rafael J. Wysocki
Quoted 10 lines · Jiang Liu
Quoted 9 lines · Rafael J. Wysocki
Quoted 3 lines · Jiang Liu
According to ACPI spec 5, section 6.4.3.1 "24-Bit Memory Range Descriptor", minimum, maximum and
address_lengthfield in structacpi_resource_memory24is in granularity of 256-bytes. So shift 8-bit left to get correct address.Are you sure about this?
I'm reading ACPI 5.1 ATM and (on page 316) it only says about the range length being in 256 byte blocks.
Quoted 8 lines
Hi Rafael,
According to ACPI spec 5.a sec 6.4.3.1,Byte 4, "Range minimum base address,
_MIN, bits[7:0]", "Address bits[15:8] of the minimum base memory address for which the card may be configured."
Byte 5, "Range minimum base address,_MIN, bits[15:8]", "Address bits[23:16] of the minimum base memory address for which the card may be configured".
Quoted 5 lines
Ah, OK.
So bits [15:0] of the
_MINfield are bits [23:8] of the address. Tricky that.I wonder why no problems with that have ever been reported ...
I guess nobody really makes use of this structure:(
Quoted 42 lines
Quoted 41 lines
Byte 10, "Range length,
_LEN, bits[7:0]", "This field contains the lower eight bits of the memory range length. The range length provides the length of the memory range in 256 byte blocks."
Byte 11, "Range length,_LEN, bits[15:8]", "This field contains the upper eight bits of the memory range length. The range length field provides the length of the memory range in 256 byte blocks."That means
_MINdefines bits[23:8] of the minimal address, and_LENis in granularity of 256 bytes, so shift them left by 8 bits. Regards,
GerryQuoted 6 lines
Quoted 6 lines
Signed-off-by Jiang Liu <[email protected]>--- drivers/acpi/resource.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Quoted 17 lines
Quoted 6 lines
drivers/acpi/resource.c +0
-0drivers/acpi/resource.c bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res) · line 97
Quoted 10 lines
drivers/acpi/resource.c +2
-2@@ -90,8 +90,8 @@ bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res)switch (ares->type) {case ACPI_RESOURCE_TYPE_MEMORY24 : memory24 = &ares->data.memory24; -acpi_dev_get_memresource (res, memory24->minimum, - memory24->address_length, +acpi_dev_get_memresource (res, memory24->minimum <<8 , + memory24->address_length <<8 , memory24->write_protect);break ;case ACPI_RESOURCE_TYPE_MEMORY32 :--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC Patch 08/19] ACPI: Add prefetch decoding to the address space parser
In reply to Rafael J. WysockiQuoted 10 lines · Rafael J. Wysocki
Quoted 4 lines · Jiang Liu
From: Thomas Gleixner <[email protected]>
Add support of PREFETCH attributre to ACPI address space and extended address space parser.
This potentially enables untested configurations which tends to uncover bugs, so I'm concerned.
What's the possible impact of this?
Hi Rafael,
I have analyzed all call sites related to this change, most
users just care about resource type(IO, MEM, IRQ etc) and ignore the prefetch property. Seems only PCI subsystem cares about PREFETCH. Regards,
Gerry
Quoted 23 lines
Quoted 22 lines
Signed-off-by Thomas Gleixner <[email protected]>Signed-off-by Jiang Liu <[email protected]>--- drivers/acpi/resource.c | 3 +++ 1 file changed, 3 insertions(+)drivers/acpi/resource.c +3
-0@@ -200,6 +200,9 @@ static bool acpi_decode_space(struct resource *res,if (base->producer_consumer ==ACPI_PRODUCER ) res->flags |=IORESOURCE_WINDOW ; +if (base->info.mem.caching ==ACPI_PREFETCHABLE_MEMORY ) + res->flags |=IORESOURCE_PREFETCH ; +return !(res->flags &IORESOURCE_DISABLED ); }
Re: [RFC Patch 14/19] ACPI: Translate resource into master side address for bridge window resources
In reply to Rafael J. WysockiQuoted 21 lines · Rafael J. Wysocki
Quoted 20 lines · Jiang Liu
Add
translation_offsetinto the result address for bridge window resources to form the master side address.Currently acpi_dev_resource_{ext_}address_space() are only used for devices instead of bridges, so it won't break current users. Later it will be used to support PCI host bridge drivers.
Signed-off-by Jiang Liu <[email protected]>--- drivers/acpi/resource.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)drivers/acpi/resource.c +0
-0@@ -203,6 +203,20 @@ static bool acpi_decode_space(struct resource *res, resource_size_t *offset, res->start = addr->minimum; res->end = addr->maximum;
Quoted 10 lines
drivers/acpi/resource.c static bool acpi_decode_space(struct resource *res, resource_size_t *offset, · line 213
Quoted 8 lines
drivers/acpi/resource.c +8
-0+/* +* For bridges that translate addresses across the bridge, +* translation_offset is the offset that must be added to the +* address on the secondary side to obtain the address on the +* primary side. Non-bridge devices must list 0 for all Address +* Translation offset bits. +*/ +if (base->producer_consumer ==ACPI_PRODUCER ) {OK, so the assumption is that this check is never true in the current code, right?
Yes.
Quoted 6 lines
drivers/acpi/resource.c static bool acpi_decode_space(struct resource *res, resource_size_t *offset, · line 216
Quoted 4 lines
drivers/acpi/resource.c +3
-0+ res->start += addr->translation_offset; + res->end += addr->translation_offset; + }else if (addr->translation_offset) {And won't this break anything even if so?
I'm trying to follow the spec, how about giving a warning here instead of failure?
Regards!
Gerry
Quoted 9 lines
Quoted 8 lines
drivers/acpi/resource.c +3
-0+return false; + } +switch (base->resource_type) {case ACPI_MEMORY_RANGE :acpi_dev_memresource_flags (res, len, wp);
Re: [RFC Patch 15/19] ACPI: Add field offset to struct resource_list_entry
In reply to Rafael J. WysockiQuoted 72 lines · Rafael J. Wysocki
Quoted 63 lines · Jiang Liu
Add field offset to struct
resource_list_entryto host address space translation offset so it could be used to represent bridge resources.Signed-off-by Jiang Liu <[email protected]>--- drivers/acpi/resource.c | 13 ++++++++----- include/linux/acpi.h | 1 + 2 files changed, 9 insertions(+), 5 deletions(-)drivers/acpi/resource.c +8
-5@@ -462,7 +462,8 @@ struct res_proc_context { };static acpi_status acpi_dev_new_resource_entry (struct resource *r, -struct res_proc_context *c) +struct res_proc_context *c, +resource_size_t offset) {struct resource_list_entry *rentry;@@ -472,6 +473,7 @@ static acpi_status acpi_dev_new_resource_entry(struct resource *r,return AE_NO_MEMORY ; } rentry->res = *r; + rentry->offset = offset;list_add_tail (&rentry->node, c->list); c->count++;return AE_OK ;@@ -480,6 +482,7 @@ static acpi_status acpi_dev_new_resource_entry(struct resource *r,static acpi_status acpi_dev_process_resource (struct acpi_resource *ares,void *context) { +resource_size_t offset =0 ;struct res_proc_context *c = context;struct resource r;int i;@@ -500,14 +503,14 @@ static acpi_status acpi_dev_process_resource(struct acpi_resource *ares,if (acpi_dev_resource_memory (ares, &r) ||acpi_dev_resource_io (ares, &r) - ||acpi_dev_resource_address_space (ares, &r,NULL ) - ||acpi_dev_resource_ext_address_space (ares, &r,NULL )) -return acpi_dev_new_resource_entry (&r, c); + ||acpi_dev_resource_address_space (ares, &r, &offset) + ||acpi_dev_resource_ext_address_space (ares, &r, &offset)) +return acpi_dev_new_resource_entry (&r, c, offset);for (i =0 ;acpi_dev_resource_interrupt (ares, i, &r); i++) {acpi_status status; - status =acpi_dev_new_resource_entry (&r, c); + status =acpi_dev_new_resource_entry (&r, c,0 );if (ACPI_FAILURE (status))return status; }include/linux/acpi.h +0
-0include/linux/acpi.h bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index, · line 303
Quoted 4 lines
include/linux/acpi.h +1
-0@@ -300,6 +300,7 @@ bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index,struct resource_list_entry {struct list_head node;struct resource res; +resource_size_t offset;Well, so instead of adding the offset thing here and there, wouldn't it be cleaner to introduce something like
Quoted 8 lines
struct ext_resource { sturct resource res; resource_size_t offset; };and use struct
ext_resourceinstead of struct resource where an offset is needed?Just a thought ...
Hi Rafael,
Following patches will achieve this by sharing struct resource_list_entry.
Regards!
Gerry
Quoted 6 lines
Quoted 5 lines
include/linux/acpi.h +0
-0};void acpi_dev_free_resource_list (struct list_head *list);
Re: [RFC Patch 17/19] resources: Move struct resource_list_entry from ACPI into resource core
In reply to Rafael J. WysockiQuoted 1 line · Rafael J. Wysocki
On Thursday, January 08, 2015 10:33:04 AM Jiang Liu wrote:
<snit>
Quoted 8 lines
Quoted 8 lines
kernel/resource.c +0
-0@@ -1529,6 +1529,54 @@ int iomem_is_exclusive(u64 addr)return err; }
Quoted 4 lines
kernel/resource.c int iomem_is_exclusive(u64 addr) · line 1533
Quoted 2 lines
kernel/resource.c +2
-0+struct resource_list_entry *resource_list_alloc (struct resource *res, +size_t extra_size)What about
create_resource_list_entry()? Less confusing surely.
Sure, I will rename it as resource_list_create_entry().
Quoted 14 lines
Quoted 14 lines
kernel/resource.c +13
-0+{ +struct resource_list_entry *entry; + + entry =kzalloc (sizeof (*entry) + extra_size,GFP_KERNEL ); +if (entry) { +INIT_LIST_HEAD (&entry->node); + entry->res = res ? res : &entry->__res; + } + +return entry; +} +EXPORT_SYMBOL (resource_list_alloc); +
Quoted 8 lines
kernel/resource.c int iomem_is_exclusive(u64 addr) · line 1551
Quoted 5 lines
kernel/resource.c +5
-0+void resource_list_free (struct resource_list_entry *entry) +{ +kfree (entry); +} +EXPORT_SYMBOL (resource_list_free);Well, I'm not sure I like this. The name suggests that it would free the entire list and what's wrong with using
kfree()directly on "entry" anyway?
I just want to make interface symmetric. We may also support some type of callback when freeing resources in future.
Quoted 9 lines
kernel/resource.c int iomem_is_exclusive(u64 addr) · line 1554
Quoted 4 lines
kernel/resource.c +3
-0+ +void resource_list_insert (struct list_head *head, +struct resource_list_entry *entry,bool tail)I would call this
resource_list_add()if anything.Also it may be better to have two helpers, one for "add" and one for "
add_tail" (and perhaps define them as static inline?).
We can't use inline functions here because that needs pulling list.h into ioport.h, then causing building issues to header inclusion order.
Quoted 3 lines
And why change the ordering between "head" and "entry". That's alomost guaranteed to confuse people.
My fault, will change in next version.
Quoted 16 lines
Quoted 4 lines
kernel/resource.c +3
-0+{ +if (tail) +list_add_tail (&entry->node, head);kernel/resource.c int iomem_is_exclusive(u64 addr) · line 1567
Quoted 10 lines
kernel/resource.c +10
-0+else +list_add (&entry->node, head); +} +EXPORT_SYMBOL (resource_list_insert); + +void resource_list_delete (struct resource_list_entry *entry) +{ +list_del (&entry->node); +} +EXPORT_SYMBOL (resource_list_delete);Couldn't this be a static inline)?
Inline will cause header file inclusion order issue:(
Quoted 2 lines
Or maybe we can combine the "
list_del" with "kfree" in one function?
There are callers which need separating list_del from kfree, so exported two interfaces here. Will add another helper interface resource_list_destroy_entry().
Regards!
Gerry
Quoted 18 lines
Quoted 17 lines
kernel/resource.c +12
-0+ +void resource_list_free_list (struct list_head *head) +{ +struct resource_list_entry *entry, *tmp; + +list_for_each_entry_safe (entry, tmp, head, node) { +list_del (&entry->node); +resource_list_free (entry); + } +} +EXPORT_SYMBOL (resource_list_free_list); +static int __init strict_iomem (char *str) {if (strstr (str,"relaxed" ))
Re: [RFC Patch 17/19] resources: Move struct resource_list_entry from ACPI into resource core
Quoted 11 lines · Jiang Liu
Quoted 8 lines · Rafael J. Wysocki
kernel/resource.c int iomem_is_exclusive(u64 addr) · line 1554
Quoted 3 lines
kernel/resource.c +3
-0+ +void resource_list_insert (struct list_head *head, +struct resource_list_entry *entry,bool tail)I would call this
resource_list_add()if anything.Also it may be better to have two helpers, one for "add" and one for "
add_tail" (and perhaps define them as static inline?).We can't use inline functions here because that needs pulling
list.hintoioport.h, then causing building issues to header inclusion order.
Create a new header file to avoid the circular dependencies then.
Thanks,
tglx
Re: [RFC Patch 17/19] resources: Move struct resource_list_entry from ACPI into resource core
Quoted 8 lines · Thomas Gleixner
Quoted 7 lines · Jiang Liu
Quoted 6 lines · Rafael J. Wysocki
kernel/resource.c int iomem_is_exclusive(u64 addr) · line 1554
Quoted 3 lines
kernel/resource.c +3
-0+ +void resource_list_insert (struct list_head *head, +struct resource_list_entry *entry,bool tail)I would call this
resource_list_add()if anything.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Also it may be better to have two helpers, one for "add" and one for "
add_tail" (and perhaps define them as static inline?).We can't use inline functions here because that needs pulling
list.hintoioport.h, then causing building issues to header inclusion order.Create a new header file to avoid the circular dependencies then.
Great, create include/linux/resource_list.h for it so we could inline those simple functions.
Regards,
Gerry
Quoted 10 lines
Thanks,
tglx
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC Patch 15/19] ACPI: Add field offset to struct resource_list_entry
In reply to Jiang LiuQuoted 78 lines · Jiang Liu
Quoted 77 lines · Rafael J. Wysocki
Quoted 63 lines · Jiang Liu
Add field offset to struct
resource_list_entryto host address space translation offset so it could be used to represent bridge resources.Signed-off-by Jiang Liu <[email protected]>--- drivers/acpi/resource.c | 13 ++++++++----- include/linux/acpi.h | 1 + 2 files changed, 9 insertions(+), 5 deletions(-)drivers/acpi/resource.c +8
-5@@ -462,7 +462,8 @@ struct res_proc_context { };static acpi_status acpi_dev_new_resource_entry (struct resource *r, -struct res_proc_context *c) +struct res_proc_context *c, +resource_size_t offset) {struct resource_list_entry *rentry;@@ -472,6 +473,7 @@ static acpi_status acpi_dev_new_resource_entry(struct resource *r,return AE_NO_MEMORY ; } rentry->res = *r; + rentry->offset = offset;list_add_tail (&rentry->node, c->list); c->count++;return AE_OK ;@@ -480,6 +482,7 @@ static acpi_status acpi_dev_new_resource_entry(struct resource *r,static acpi_status acpi_dev_process_resource (struct acpi_resource *ares,void *context) { +resource_size_t offset =0 ;struct res_proc_context *c = context;struct resource r;int i;@@ -500,14 +503,14 @@ static acpi_status acpi_dev_process_resource(struct acpi_resource *ares,if (acpi_dev_resource_memory (ares, &r) ||acpi_dev_resource_io (ares, &r) - ||acpi_dev_resource_address_space (ares, &r,NULL ) - ||acpi_dev_resource_ext_address_space (ares, &r,NULL )) -return acpi_dev_new_resource_entry (&r, c); + ||acpi_dev_resource_address_space (ares, &r, &offset) + ||acpi_dev_resource_ext_address_space (ares, &r, &offset)) +return acpi_dev_new_resource_entry (&r, c, offset);for (i =0 ;acpi_dev_resource_interrupt (ares, i, &r); i++) {acpi_status status; - status =acpi_dev_new_resource_entry (&r, c); + status =acpi_dev_new_resource_entry (&r, c,0 );if (ACPI_FAILURE (status))return status; }include/linux/acpi.h +0
-0include/linux/acpi.h bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index, · line 303
Quoted 4 lines
include/linux/acpi.h +1
-0@@ -300,6 +300,7 @@ bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index,struct resource_list_entry {struct list_head node;struct resource res; +resource_size_t offset;Well, so instead of adding the offset thing here and there, wouldn't it be cleaner to introduce something like
struct ext_resource { sturct resource res; resource_size_t offset; };
Quoted 5 lines
Quoted 3 lines
and use struct
ext_resourceinstead of struct resource where an offset is needed?Just a thought ...
Hi Rafael,
Following patches will achieve this by sharing structresource_list_entry.
Well, yes, they will partially, but that still won't avoid the need to pass offset (or pointers to that) to several functions separately if I'm not mistaken. Which is kind of ugly.
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [RFC Patch 14/19] ACPI: Translate resource into master side address for bridge window resources
In reply to Jiang LiuQuoted 34 lines · Jiang Liu
Quoted 21 lines · Rafael J. Wysocki
Quoted 20 lines · Jiang Liu
Add
translation_offsetinto the result address for bridge window resources to form the master side address.Currently acpi_dev_resource_{ext_}address_space() are only used for devices instead of bridges, so it won't break current users. Later it will be used to support PCI host bridge drivers.
Signed-off-by Jiang Liu <[email protected]>--- drivers/acpi/resource.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)drivers/acpi/resource.c +0
-0@@ -203,6 +203,20 @@ static bool acpi_decode_space(struct resource *res, resource_size_t *offset, res->start = addr->minimum; res->end = addr->maximum;Quoted 10 lines
drivers/acpi/resource.c static bool acpi_decode_space(struct resource *res, resource_size_t *offset, · line 213
Quoted 8 lines
drivers/acpi/resource.c +8
-0+/* +* For bridges that translate addresses across the bridge, +* translation_offset is the offset that must be added to the +* address on the secondary side to obtain the address on the +* primary side. Non-bridge devices must list 0 for all Address +* Translation offset bits. +*/ +if (base->producer_consumer ==ACPI_PRODUCER ) {OK, so the assumption is that this check is never true in the current code, right?
Yes.
Quoted 1 line
Quoted 7 lines
Quoted 5 lines
drivers/acpi/resource.c static bool acpi_decode_space(struct resource *res, resource_size_t *offset, · line 216
Quoted 3 lines
drivers/acpi/resource.c +3
-0+ res->start += addr->translation_offset; + res->end += addr->translation_offset; + }else if (addr->translation_offset) {And won't this break anything even if so?
I'm trying to follow the spec, how about giving a warning here instead of failure?
Yes, that would be safer IMO.
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [RFC Patch 08/19] ACPI: Add prefetch decoding to the address space parser
In reply to Jiang LiuQuoted 7 lines · Jiang Liu
Quoted 6 lines · Rafael J. Wysocki
Quoted 4 lines · Jiang Liu
From: Thomas Gleixner <[email protected]>
Add support of PREFETCH attributre to ACPI address space and extended address space parser.
Quoted 8 lines
Quoted 4 lines
This potentially enables untested configurations which tends to uncover bugs, so I'm concerned.
What's the possible impact of this?
Hi Rafael,
I have analyzed all call sites related to this change, most
users just care about resourcetype(IO, MEM, IRQ etc)and ignore the prefetch property. Seems only PCI subsystem cares about PREFETCH.
OK
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [RFC Patch 15/19] ACPI: Add field offset to struct resource_list_entry
In reply to Rafael J. WysockiQuoted 81 lines · Rafael J. Wysocki
Quoted 80 lines · Jiang Liu
Quoted 79 lines · Rafael J. Wysocki
Quoted 63 lines · Jiang Liu
Add field offset to struct
resource_list_entryto host address space translation offset so it could be used to represent bridge resources.Signed-off-by Jiang Liu <[email protected]>--- drivers/acpi/resource.c | 13 ++++++++----- include/linux/acpi.h | 1 + 2 files changed, 9 insertions(+), 5 deletions(-)drivers/acpi/resource.c +8
-5@@ -462,7 +462,8 @@ struct res_proc_context { };static acpi_status acpi_dev_new_resource_entry (struct resource *r, -struct res_proc_context *c) +struct res_proc_context *c, +resource_size_t offset) {struct resource_list_entry *rentry;@@ -472,6 +473,7 @@ static acpi_status acpi_dev_new_resource_entry(struct resource *r,return AE_NO_MEMORY ; } rentry->res = *r; + rentry->offset = offset;list_add_tail (&rentry->node, c->list); c->count++;return AE_OK ;@@ -480,6 +482,7 @@ static acpi_status acpi_dev_new_resource_entry(struct resource *r,static acpi_status acpi_dev_process_resource (struct acpi_resource *ares,void *context) { +resource_size_t offset =0 ;struct res_proc_context *c = context;struct resource r;int i;@@ -500,14 +503,14 @@ static acpi_status acpi_dev_process_resource(struct acpi_resource *ares,if (acpi_dev_resource_memory (ares, &r) ||acpi_dev_resource_io (ares, &r) - ||acpi_dev_resource_address_space (ares, &r,NULL ) - ||acpi_dev_resource_ext_address_space (ares, &r,NULL )) -return acpi_dev_new_resource_entry (&r, c); + ||acpi_dev_resource_address_space (ares, &r, &offset) + ||acpi_dev_resource_ext_address_space (ares, &r, &offset)) +return acpi_dev_new_resource_entry (&r, c, offset);for (i =0 ;acpi_dev_resource_interrupt (ares, i, &r); i++) {acpi_status status; - status =acpi_dev_new_resource_entry (&r, c); + status =acpi_dev_new_resource_entry (&r, c,0 );if (ACPI_FAILURE (status))return status; }include/linux/acpi.h +0
-0include/linux/acpi.h bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index, · line 303
Quoted 4 lines
include/linux/acpi.h +1
-0@@ -300,6 +300,7 @@ bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index,struct resource_list_entry {struct list_head node;struct resource res; +resource_size_t offset;Well, so instead of adding the offset thing here and there, wouldn't it be cleaner to introduce something like
struct ext_resource { sturct resource res; resource_size_t offset; };and use struct
ext_resourceinstead of struct resource where an offset is needed?
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Just a thought ...
Hi Rafael,
Following patches will achieve this by sharing structresource_list_entry.Well, yes, they will partially, but that still won't avoid the need to pass offset (or pointers to that) to several functions separately if I'm not mistaken. Which is kind of ugly.
Hi Rafael,
Sorry, I missed your point with last reply. I have the basic
idea about how to follow your suggestion now, will do it in next version.
Regards,
Gerry
RE: [RFC Patch 05/19] ACPI: Provide union for address_space64 and ext_address_space64
In reply to Jiang LiuHi, Thomas and Jiang
Quoted 37 lines
From: Jiang Liu [mailto:[email protected]]
Sent: Thursday, January 08, 2015 10:33 AMFrom: Thomas Gleixner <[email protected]>
address_space64andext_address_space64share substracts just at different offsets. To unify the parsing functions implement the two structs as unions of their substructs, so we can extract the shared data.Signed-off-by Thomas Gleixner <[email protected]>Signed-off-by Jiang Liu <[email protected]>--- include/acpi/acrestyp.h | 49 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 13 deletions(-)include/acpi/acrestyp.h +6
-6@@ -326,23 +326,46 @@ struct acpi_resource_address32 {struct acpi_resource_source resource_source; }; -struct acpi_resource_address64 { - ACPI_RESOURCE_ADDRESS_COMMON u64 granularity; -u64 minimum; -u64 maximum; -u64 translation_offset; +#define ACPI_RESOURCE_ADDRESS64_COMMON \ + u64 granularity; \ + u64 minimum; \ + u64 maximum; \ + u64 translation_offset; \ u64 address_length; -struct acpi_resource_source resource_source; +
include/acpi/acrestyp.h struct acpi_resource_address32 { · line 345
Quoted 10 lines
include/acpi/acrestyp.h +10
-0+struct acpi_resource_address64_common { +ACPI_RESOURCE_ADDRESS64_COMMON}; + +struct acpi_resource_address64 { + union { + struct { + ACPI_RESOURCE_ADDRESS_COMMON + ACPI_RESOURCE_ADDRESS64_COMMON + struct acpi_resource_source resource_source; + };
This looks wrong to ACPICA upstream.
include/acpi/acrestyp.h struct acpi_resource_address32 { · line 352
Quoted 7 lines
include/acpi/acrestyp.h +6
-0+struct { +struct acpi_resource_address base; +struct acpi_resource_address64_common addr; +struct acpi_resource_source resource_source; + } common; + }; };
And this.
Though anonymous structs/unions are now C11 standard, I still didn't see it used in the ACPICA upstream. It could be a problem if someone still compiles ACPICA using old compilers.
Quoted 6 lines
include/acpi/acrestyp.h +0
-4struct acpi_resource_extended_address64 { - ACPI_RESOURCE_ADDRESS_COMMON u8 revision_ID; -u64 granularity; -u64 minimum; -u64 maximum;
include/acpi/acrestyp.h struct acpi_resource_address32 { · line 361
Quoted 10 lines
include/acpi/acrestyp.h +7
-3-u64 translation_offset; -u64 address_length; -u64 type_specific; +union { +struct { +ACPI_RESOURCE_ADDRESS_COMMON + u8 revision_ID; +ACPI_RESOURCE_ADDRESS64_COMMON + u64 type_specific; + };
Ditto.
include/acpi/acrestyp.h struct acpi_resource_address32 { · line 368
Quoted 7 lines
include/acpi/acrestyp.h +7
-0+struct { +struct acpi_resource_address base; +u8 revision_ID; +struct acpi_resource_address64_common addr; +u64 type_specific; + } common; + };
Ditto.
I think what you want is the ability to access common.addr and common.base from different resource address64 types. So we can achieve this directly in the ACPICA upstream without using the union.
I tried this in the ACPICA upstream and the result is:
https://github.com/zetalog/acpica/commit/0f4ed510
Let me send its linuxized version after this email.
Thanks and best regards
-Lv
Quoted 5 lines
include/acpi/acrestyp.h +0
-1};struct acpi_resource_extended_irq { --1.7.10.4
Lv Zheng
RFC PATCH 1/1 ACPICA: Resources: Provide common part for struct acpi_resource_address structures.
In reply to Jiang Liustruct acpi_resource_address and struct acpi_resource_extended_address64 share substracts just at different offsets. To unify the parsing functions, OSPMs like Linux need a new ACPI_ADDRESS64_ATTRIBUTE as their substructs, so they can extract the shared data.
Original-by: Thomas Gleixner <tglx(a)linutronix.de>
Original-by: Jiang Liu <jiang.liu(a)linux.intel.com>
Signed-off-by: Lv Zheng <lv.zheng(a)intel.com>
--- drivers/acpi/acpica/rsaddr.c | 9 +++--- drivers/acpi/acpica/rsdumpinfo.c | 59 +++++++++++++++++++------------------- drivers/acpi/acpica/rsxface.c | 10 +++---- include/acpi/acrestyp.h | 40 +++++++++++++++----------- 4 files changed, 64 insertions(+), 54 deletions(-)
drivers/acpi/acpica/rsaddr.c +5 -4
@@ -74,7 +74,7 @@ struct acpi_rsconvert_info acpi_rs_convert_address16[5] = {* Address Translation Offset * Address Length */ - {ACPI_RSC_MOVE16 ,ACPI_RS_OFFSET (data.address16.granularity), + {ACPI_RSC_MOVE16 ,ACPI_RS_OFFSET (data.address16.address.granularity),AML_OFFSET (address16.granularity), 5},
@@ -112,7 +112,7 @@ struct acpi_rsconvert_info acpi_rs_convert_address32[5] = {* Address Translation Offset * Address Length */ - {ACPI_RSC_MOVE32 ,ACPI_RS_OFFSET (data.address32.granularity), + {ACPI_RSC_MOVE32 ,ACPI_RS_OFFSET (data.address32.address.granularity),AML_OFFSET (address32.granularity), 5},
@@ -150,7 +150,7 @@ struct acpi_rsconvert_info acpi_rs_convert_address64[5] = {* Address Translation Offset * Address Length */ - {ACPI_RSC_MOVE64 ,ACPI_RS_OFFSET (data.address64.granularity), + {ACPI_RSC_MOVE64 ,ACPI_RS_OFFSET (data.address64.address.granularity),AML_OFFSET (address64.granularity), 5},
@@ -194,7 +194,8 @@ struct acpi_rsconvert_info acpi_rs_convert_ext_address64[5] = {* Address Length * Type-Specific Attribute */ - {ACPI_RSC_MOVE64 ,ACPI_RS_OFFSET (data.ext_address64.granularity), + {ACPI_RSC_MOVE64 , +ACPI_RS_OFFSET (data.ext_address64.address.granularity),AML_OFFSET (ext_address64.granularity), 6} };
drivers/acpi/acpica/rsdumpinfo.c +30 -29
90 lines not on this page · raw message
drivers/acpi/acpica/rsxface.c +5 -5
@@ -60,11 +60,11 @@ ACPI_MODULE_NAME("rsxface")ACPI_COPY_FIELD (out, in, min_address_fixed); \ACPI_COPY_FIELD (out, in, max_address_fixed); \ACPI_COPY_FIELD (out, in, info); \ -ACPI_COPY_FIELD (out, in, granularity); \ -ACPI_COPY_FIELD (out, in, minimum); \ -ACPI_COPY_FIELD (out, in, maximum); \ -ACPI_COPY_FIELD (out, in, translation_offset); \ -ACPI_COPY_FIELD (out, in, address_length); \ +ACPI_COPY_FIELD (out, in, address.granularity); \ +ACPI_COPY_FIELD (out, in, address.minimum); \ +ACPI_COPY_FIELD (out, in, address.maximum); \ +ACPI_COPY_FIELD (out, in, address.translation_offset); \ +ACPI_COPY_FIELD (out, in, address.address_length); \ACPI_COPY_FIELD (out, in, resource_source);/* Local prototypes */ static acpi_status
include/acpi/acrestyp.h +24 -16
@@ -305,43 +305,51 @@ struct acpi_resource_source {u8 max_address_fixed; \union acpi_resource_attribute info; -struct acpi_resource_address { -ACPI_RESOURCE_ADDRESS_COMMON}; - -struct acpi_resource_address16 { - ACPI_RESOURCE_ADDRESS_COMMON u16 granularity; +struct acpi_address16_attribute { +u16 granularity;u16 minimum;u16 maximum;u16 translation_offset;u16 address_length; - struct acpi_resource_source resource_source; }; -struct acpi_resource_address32 { - ACPI_RESOURCE_ADDRESS_COMMON u32 granularity; +struct acpi_address32_attribute { +u32 granularity;u32 minimum;u32 maximum;u32 translation_offset;u32 address_length; - struct acpi_resource_source resource_source; }; -struct acpi_resource_address64 { - ACPI_RESOURCE_ADDRESS_COMMON u64 granularity; +struct acpi_address64_attribute { +u64 granularity;u64 minimum;u64 maximum;u64 translation_offset;u64 address_length; +}; + +struct acpi_resource_address { +ACPI_RESOURCE_ADDRESS_COMMON}; + +struct acpi_resource_address16 { + ACPI_RESOURCE_ADDRESS_COMMON ACPI_ADDRESS16_ATTRIBUTE address; + struct acpi_resource_source resource_source; +}; + +struct acpi_resource_address32 { + ACPI_RESOURCE_ADDRESS_COMMON ACPI_ADDRESS32_ATTRIBUTE address; + struct acpi_resource_source resource_source; +}; + +struct acpi_resource_address64 { + ACPI_RESOURCE_ADDRESS_COMMON ACPI_ADDRESS64_ATTRIBUTE address; struct acpi_resource_source resource_source; }; struct acpi_resource_extended_address64 { ACPI_RESOURCE_ADDRESS_COMMON u8 revision_ID; - u64 granularity; - u64 minimum; - u64 maximum; - u64 translation_offset; - u64 address_length; + ACPI_ADDRESS64_ATTRIBUTE address; u64 type_specific; };
Signature · 1 line
1.7.10
Re: [RFC Patch 05/19] ACPI: Provide union for address_space64 and ext_address_space64
In reply to Zheng, LvQuoted 93 lines · Lv
Hi, Thomas and Jiang
Quoted 37 lines
From: Jiang Liu [mailto:[email protected]]
Sent: Thursday, January 08, 2015 10:33 AMFrom: Thomas Gleixner <[email protected]>
address_space64andext_address_space64share substracts just at different offsets. To unify the parsing functions implement the two structs as unions of their substructs, so we can extract the shared data.Signed-off-by Thomas Gleixner <[email protected]>Signed-off-by Jiang Liu <[email protected]>--- include/acpi/acrestyp.h | 49 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 13 deletions(-)include/acpi/acrestyp.h +6
-6@@ -326,23 +326,46 @@ struct acpi_resource_address32 {struct acpi_resource_source resource_source; }; -struct acpi_resource_address64 { - ACPI_RESOURCE_ADDRESS_COMMON u64 granularity; -u64 minimum; -u64 maximum; -u64 translation_offset; +#define ACPI_RESOURCE_ADDRESS64_COMMON \ + u64 granularity; \ + u64 minimum; \ + u64 maximum; \ + u64 translation_offset; \ u64 address_length; -struct acpi_resource_source resource_source; +include/acpi/acrestyp.h struct acpi_resource_address32 { · line 345
Quoted 10 lines
include/acpi/acrestyp.h +10
-0+struct acpi_resource_address64_common { +ACPI_RESOURCE_ADDRESS64_COMMON}; + +struct acpi_resource_address64 { + union { + struct { + ACPI_RESOURCE_ADDRESS_COMMON + ACPI_RESOURCE_ADDRESS64_COMMON + struct acpi_resource_source resource_source; + };This looks wrong to ACPICA upstream.
include/acpi/acrestyp.h struct acpi_resource_address32 { · line 352
Quoted 7 lines
include/acpi/acrestyp.h +6
-0+struct { +struct acpi_resource_address base; +struct acpi_resource_address64_common addr; +struct acpi_resource_source resource_source; + } common; + }; };And this.
Though anonymous structs/unions are now C11 standard, I still didn't see it used in the ACPICA upstream. It could be a problem if someone still compiles ACPICA using old compilers.Quoted 6 lines
include/acpi/acrestyp.h +0
-4struct acpi_resource_extended_address64 { - ACPI_RESOURCE_ADDRESS_COMMON u8 revision_ID; -u64 granularity; -u64 minimum; -u64 maximum;include/acpi/acrestyp.h struct acpi_resource_address32 { · line 361
Quoted 10 lines
include/acpi/acrestyp.h +7
-3-u64 translation_offset; -u64 address_length; -u64 type_specific; +union { +struct { +ACPI_RESOURCE_ADDRESS_COMMON + u8 revision_ID; +ACPI_RESOURCE_ADDRESS64_COMMON + u64 type_specific; + };Ditto.
include/acpi/acrestyp.h struct acpi_resource_address32 { · line 368
Quoted 7 lines
include/acpi/acrestyp.h +7
-0+struct { +struct acpi_resource_address base; +u8 revision_ID; +struct acpi_resource_address64_common addr; +u64 type_specific; + } common; + };Ditto.
Quoted 6 lines
I think what you want is the ability to access common.addr and common.base from different resource address64 types. So we can achieve this directly in the ACPICA upstream without using the union.
I tried this in the ACPICA upstream and the result is:
https://github.com/zetalog/acpica/commit/0f4ed510
Let me send its linuxized version after this email.
Hi Lv,
Thanks for your great support:)
What's the normal process to propagate this patch into
linux kernel? Or how long will it take? We have another hotplug patch set which depends on this patch set, then depends on this ACPICA core change.
Regards!
Gerry
Quoted 10 lines
Thanks and best regards
-LvQuoted 5 lines
include/acpi/acrestyp.h +0
-1};struct acpi_resource_extended_irq { --1.7.10.4
RE: [RFC Patch 05/19] ACPI: Provide union for address_space64 and ext_address_space64
Hi, Gerry
Quoted 103 lines
From: Jiang Liu [mailto:[email protected]]
Sent: Thursday, January 22, 2015 10:58 AMQuoted 93 lines · Lv
Hi, Thomas and Jiang
Quoted 37 lines
From: Jiang Liu [mailto:[email protected]]
Sent: Thursday, January 08, 2015 10:33 AMFrom: Thomas Gleixner <[email protected]>
address_space64andext_address_space64share substracts just at different offsets. To unify the parsing functions implement the two structs as unions of their substructs, so we can extract the shared data.Signed-off-by Thomas Gleixner <[email protected]>Signed-off-by Jiang Liu <[email protected]>--- include/acpi/acrestyp.h | 49 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 13 deletions(-)include/acpi/acrestyp.h +6
-6@@ -326,23 +326,46 @@ struct acpi_resource_address32 {struct acpi_resource_source resource_source; }; -struct acpi_resource_address64 { - ACPI_RESOURCE_ADDRESS_COMMON u64 granularity; -u64 minimum; -u64 maximum; -u64 translation_offset; +#define ACPI_RESOURCE_ADDRESS64_COMMON \ + u64 granularity; \ + u64 minimum; \ + u64 maximum; \ + u64 translation_offset; \ u64 address_length; -struct acpi_resource_source resource_source; +include/acpi/acrestyp.h struct acpi_resource_address32 { · line 345
Quoted 10 lines
include/acpi/acrestyp.h +10
-0+struct acpi_resource_address64_common { +ACPI_RESOURCE_ADDRESS64_COMMON}; + +struct acpi_resource_address64 { + union { + struct { + ACPI_RESOURCE_ADDRESS_COMMON + ACPI_RESOURCE_ADDRESS64_COMMON + struct acpi_resource_source resource_source; + };This looks wrong to ACPICA upstream.
include/acpi/acrestyp.h struct acpi_resource_address32 { · line 352
Quoted 7 lines
include/acpi/acrestyp.h +6
-0+struct { +struct acpi_resource_address base; +struct acpi_resource_address64_common addr; +struct acpi_resource_source resource_source; + } common; + }; };And this.
Though anonymous structs/unions are now C11 standard, I still didn't see it used in the ACPICA upstream. It could be a problem if someone still compiles ACPICA using old compilers.Quoted 6 lines
include/acpi/acrestyp.h +0
-4struct acpi_resource_extended_address64 { - ACPI_RESOURCE_ADDRESS_COMMON u8 revision_ID; -u64 granularity; -u64 minimum; -u64 maximum;include/acpi/acrestyp.h struct acpi_resource_address32 { · line 361
Quoted 10 lines
include/acpi/acrestyp.h +7
-3-u64 translation_offset; -u64 address_length; -u64 type_specific; +union { +struct { +ACPI_RESOURCE_ADDRESS_COMMON + u8 revision_ID; +ACPI_RESOURCE_ADDRESS64_COMMON + u64 type_specific; + };Ditto.
include/acpi/acrestyp.h struct acpi_resource_address32 { · line 368
Quoted 7 lines
include/acpi/acrestyp.h +7
-0+struct { +struct acpi_resource_address base; +u8 revision_ID; +struct acpi_resource_address64_common addr; +u64 type_specific; + } common; + };Ditto.
Quoted 6 lines
I think what you want is the ability to access common.addr and common.base from different resource address64 types. So we can achieve this directly in the ACPICA upstream without using the union.
I tried this in the ACPICA upstream and the result is:
https://github.com/zetalog/acpica/commit/0f4ed510
Let me send its linuxized version after this email.
Quoted 6 lines
Hi Lv,
Thanks for your great support:)
What's the normal process to propagate this patch into
linux kernel? Or how long will it take? We have another hotplug patch set which depends on this patch set, then depends on this ACPICA core change.
There won't be divergences if things are proceeded in this way:
If we can reach an agreement on the linuxized version, then it can be merged directly by Rafael. And I'll zap it from the ACPICA release series.
Thanks and best regards
-Lv
Quoted 12 lines
Regards!
GerryQuoted 10 lines
Thanks and best regards
-LvQuoted 5 lines
include/acpi/acrestyp.h +0
-1};struct acpi_resource_extended_irq { --1.7.10.4
RE: [RFC Patch 05/19] ACPI: Provide union for address_space64 and ext_address_space64
Quoted 3 lines · Lv
If we can reach an agreement on the linuxized version, then it can be merged directly by Rafael. And I'll zap it from the ACPICA release series.
Fine with me.
Thanks,
tglx
Re: [RFC PATCH] ACPICA: Resources: Provide common part for struct acpi_resource_address structures.
In reply to Lv ZhengQuoted 4 lines · Lv Zheng
struct
acpi_resource_addressand structacpi_resource_extended_address64share substracts just at different offsets. To unify the parsing functions, OSPMs like Linux need a newACPI_ADDRESS64_ATTRIBUTEas their substructs, so they can extract the shared data.
Looks OK to me.
Quoted 243 lines
Original-by Thomas Gleixner <[email protected]>Original-by Jiang Liu <[email protected]>Signed-off-by Lv Zheng <[email protected]>--- drivers/acpi/acpica/rsaddr.c | 9 +++--- drivers/acpi/acpica/rsdumpinfo.c | 59 +++++++++++++++++++------------------- drivers/acpi/acpica/rsxface.c | 10 +++---- include/acpi/acrestyp.h | 40 +++++++++++++++----------- 4 files changed, 64 insertions(+), 54 deletions(-)drivers/acpi/acpica/rsaddr.c +5
-4@@ -74,7 +74,7 @@ struct acpi_rsconvert_info acpi_rs_convert_address16[5] = {* Address Translation Offset * Address Length */ - {ACPI_RSC_MOVE16 ,ACPI_RS_OFFSET (data.address16.granularity), + {ACPI_RSC_MOVE16 ,ACPI_RS_OFFSET (data.address16.address.granularity),AML_OFFSET (address16.granularity), 5},@@ -112,7 +112,7 @@ struct acpi_rsconvert_info acpi_rs_convert_address32[5] = {* Address Translation Offset * Address Length */ - {ACPI_RSC_MOVE32 ,ACPI_RS_OFFSET (data.address32.granularity), + {ACPI_RSC_MOVE32 ,ACPI_RS_OFFSET (data.address32.address.granularity),AML_OFFSET (address32.granularity), 5},@@ -150,7 +150,7 @@ struct acpi_rsconvert_info acpi_rs_convert_address64[5] = {* Address Translation Offset * Address Length */ - {ACPI_RSC_MOVE64 ,ACPI_RS_OFFSET (data.address64.granularity), + {ACPI_RSC_MOVE64 ,ACPI_RS_OFFSET (data.address64.address.granularity),AML_OFFSET (address64.granularity), 5},@@ -194,7 +194,8 @@ struct acpi_rsconvert_info acpi_rs_convert_ext_address64[5] = {* Address Length * Type-Specific Attribute */ - {ACPI_RSC_MOVE64 ,ACPI_RS_OFFSET (data.ext_address64.granularity), + {ACPI_RSC_MOVE64 , +ACPI_RS_OFFSET (data.ext_address64.address.granularity),AML_OFFSET (ext_address64.granularity), 6} };drivers/acpi/acpica/rsdumpinfo.c +30
-29@@ -183,15 +183,15 @@ struct acpi_rsdump_info acpi_rs_dump_address16[8] = { {ACPI_RSD_TITLE ,ACPI_RSD_TABLE_SIZE (acpi_rs_dump_address16), "16-Bit WORD Address Space", NULL}, {ACPI_RSD_ADDRESS, 0, NULL, NULL}, - {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.granularity), "Granularity", - NULL}, - {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.minimum), "Address Minimum", - NULL}, - {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.maximum), "Address Maximum", - NULL}, - {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.translation_offset), + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address.granularity), + "Granularity", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address.minimum), + "Address Minimum", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address.maximum), + "Address Maximum", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address.translation_offset), "Translation Offset", NULL}, - {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address_length), + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address.address_length), "Address Length", NULL}, {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address16.resource_source), NULL, NULL} };@@ -200,15 +200,15 @@ struct acpi_rsdump_info acpi_rs_dump_address32[8] = { {ACPI_RSD_TITLE ,ACPI_RSD_TABLE_SIZE (acpi_rs_dump_address32), "32-Bit DWORD Address Space", NULL}, {ACPI_RSD_ADDRESS, 0, NULL, NULL}, - {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.granularity), "Granularity", - NULL}, - {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.minimum), "Address Minimum", - NULL}, - {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.maximum), "Address Maximum", - NULL}, - {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.translation_offset), + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address.granularity), + "Granularity", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address.minimum), + "Address Minimum", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address.maximum), + "Address Maximum", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address.translation_offset), "Translation Offset", NULL}, - {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address_length), + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address.address_length), "Address Length", NULL}, {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address32.resource_source), NULL, NULL} };@@ -217,15 +217,15 @@ struct acpi_rsdump_info acpi_rs_dump_address64[8] = { {ACPI_RSD_TITLE ,ACPI_RSD_TABLE_SIZE (acpi_rs_dump_address64), "64-Bit QWORD Address Space", NULL}, {ACPI_RSD_ADDRESS, 0, NULL, NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.granularity), "Granularity", - NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.minimum), "Address Minimum", - NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.maximum), "Address Maximum", - NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.translation_offset), + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address.granularity), + "Granularity", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address.minimum), + "Address Minimum", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address.maximum), + "Address Maximum", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address.translation_offset), "Translation Offset", NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address_length), + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address.address_length), "Address Length", NULL}, {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address64.resource_source), NULL, NULL} };@@ -234,15 +234,16 @@ struct acpi_rsdump_info acpi_rs_dump_ext_address64[8] = { {ACPI_RSD_TITLE ,ACPI_RSD_TABLE_SIZE (acpi_rs_dump_ext_address64), "64-Bit Extended Address Space", NULL}, {ACPI_RSD_ADDRESS, 0, NULL, NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.granularity), + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address.granularity), "Granularity", NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.minimum), + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address.minimum), "Address Minimum", NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.maximum), + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address.maximum), "Address Maximum", NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.translation_offset), + {ACPI_RSD_UINT64, +ACPI_RSD_OFFSET (ext_address64.address.translation_offset), "Translation Offset", NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address_length), + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address.address_length), "Address Length", NULL}, {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.type_specific), "Type-Specific Attribute", NULL}drivers/acpi/acpica/rsxface.c +5
-5@@ -60,11 +60,11 @@ ACPI_MODULE_NAME("rsxface")ACPI_COPY_FIELD (out, in, min_address_fixed); \ACPI_COPY_FIELD (out, in, max_address_fixed); \ACPI_COPY_FIELD (out, in, info); \ -ACPI_COPY_FIELD (out, in, granularity); \ -ACPI_COPY_FIELD (out, in, minimum); \ -ACPI_COPY_FIELD (out, in, maximum); \ -ACPI_COPY_FIELD (out, in, translation_offset); \ -ACPI_COPY_FIELD (out, in, address_length); \ +ACPI_COPY_FIELD (out, in, address.granularity); \ +ACPI_COPY_FIELD (out, in, address.minimum); \ +ACPI_COPY_FIELD (out, in, address.maximum); \ +ACPI_COPY_FIELD (out, in, address.translation_offset); \ +ACPI_COPY_FIELD (out, in, address.address_length); \ACPI_COPY_FIELD (out, in, resource_source);/* Local prototypes */ static acpi_statusinclude/acpi/acrestyp.h +24
-16@@ -305,43 +305,51 @@ struct acpi_resource_source {u8 max_address_fixed; \union acpi_resource_attribute info; -struct acpi_resource_address { -ACPI_RESOURCE_ADDRESS_COMMON}; - -struct acpi_resource_address16 { - ACPI_RESOURCE_ADDRESS_COMMON u16 granularity; +struct acpi_address16_attribute { +u16 granularity;u16 minimum;u16 maximum;u16 translation_offset;u16 address_length; - struct acpi_resource_source resource_source; }; -struct acpi_resource_address32 { - ACPI_RESOURCE_ADDRESS_COMMON u32 granularity; +struct acpi_address32_attribute { +u32 granularity;u32 minimum;u32 maximum;u32 translation_offset;u32 address_length; - struct acpi_resource_source resource_source; }; -struct acpi_resource_address64 { - ACPI_RESOURCE_ADDRESS_COMMON u64 granularity; +struct acpi_address64_attribute { +u64 granularity;u64 minimum;u64 maximum;u64 translation_offset;u64 address_length; +}; + +struct acpi_resource_address { +ACPI_RESOURCE_ADDRESS_COMMON}; + +struct acpi_resource_address16 { + ACPI_RESOURCE_ADDRESS_COMMON ACPI_ADDRESS16_ATTRIBUTE address; + struct acpi_resource_source resource_source; +}; + +struct acpi_resource_address32 { + ACPI_RESOURCE_ADDRESS_COMMON ACPI_ADDRESS32_ATTRIBUTE address; + struct acpi_resource_source resource_source; +}; + +struct acpi_resource_address64 { + ACPI_RESOURCE_ADDRESS_COMMON ACPI_ADDRESS64_ATTRIBUTE address; struct acpi_resource_source resource_source; }; struct acpi_resource_extended_address64 { ACPI_RESOURCE_ADDRESS_COMMON u8 revision_ID; - u64 granularity; - u64 minimum; - u64 maximum; - u64 translation_offset; - u64 address_length; + ACPI_ADDRESS64_ATTRIBUTE address; u64 type_specific; };
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Zheng
Re: [Devel] [RFC PATCH] ACPICA: Resources: Provide common part for struct acpi_resource_address structures.
Hi, Rafael
Quoted 10 lines
From: Rafael J. Wysocki [mailto:[email protected]]
Sent: Friday, January 23, 2015 6:50 AMQuoted 4 lines · Lv Zheng
struct
acpi_resource_addressand structacpi_resource_extended_address64share substracts just at different offsets. To unify the parsing functions, OSPMs like Linux need a newACPI_ADDRESS64_ATTRIBUTEas their substructs, so they can extract the shared data.Looks OK to me.
Could you help to ship it with linux-next directly so that Gerry can re-base his patchset on top of linux-next using this change? I'll take care of remove this patch from ACPICA release cycle.
Thanks and best regards
-Lv
Quoted 248 lines
Quoted 234 lines
Original-by Thomas Gleixner <[email protected]>Original-by Jiang Liu <[email protected]>Signed-off-by Lv Zheng <[email protected]>--- drivers/acpi/acpica/rsaddr.c | 9 +++--- drivers/acpi/acpica/rsdumpinfo.c | 59 +++++++++++++++++++------------------- drivers/acpi/acpica/rsxface.c | 10 +++---- include/acpi/acrestyp.h | 40 +++++++++++++++----------- 4 files changed, 64 insertions(+), 54 deletions(-)drivers/acpi/acpica/rsaddr.c +5
-4@@ -74,7 +74,7 @@ struct acpi_rsconvert_info acpi_rs_convert_address16[5] = {* Address Translation Offset * Address Length */ - {ACPI_RSC_MOVE16 ,ACPI_RS_OFFSET (data.address16.granularity), + {ACPI_RSC_MOVE16 ,ACPI_RS_OFFSET (data.address16.address.granularity),AML_OFFSET (address16.granularity), 5},@@ -112,7 +112,7 @@ struct acpi_rsconvert_info acpi_rs_convert_address32[5] = {* Address Translation Offset * Address Length */ - {ACPI_RSC_MOVE32 ,ACPI_RS_OFFSET (data.address32.granularity), + {ACPI_RSC_MOVE32 ,ACPI_RS_OFFSET (data.address32.address.granularity),AML_OFFSET (address32.granularity), 5},@@ -150,7 +150,7 @@ struct acpi_rsconvert_info acpi_rs_convert_address64[5] = {* Address Translation Offset * Address Length */ - {ACPI_RSC_MOVE64 ,ACPI_RS_OFFSET (data.address64.granularity), + {ACPI_RSC_MOVE64 ,ACPI_RS_OFFSET (data.address64.address.granularity),AML_OFFSET (address64.granularity), 5},@@ -194,7 +194,8 @@ struct acpi_rsconvert_info acpi_rs_convert_ext_address64[5] = {* Address Length * Type-Specific Attribute */ - {ACPI_RSC_MOVE64 ,ACPI_RS_OFFSET (data.ext_address64.granularity), + {ACPI_RSC_MOVE64 , +ACPI_RS_OFFSET (data.ext_address64.address.granularity),AML_OFFSET (ext_address64.granularity), 6} };drivers/acpi/acpica/rsdumpinfo.c +30
-29@@ -183,15 +183,15 @@ struct acpi_rsdump_info acpi_rs_dump_address16[8] = { {ACPI_RSD_TITLE ,ACPI_RSD_TABLE_SIZE (acpi_rs_dump_address16), "16-Bit WORD Address Space", NULL}, {ACPI_RSD_ADDRESS, 0, NULL, NULL}, - {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.granularity), "Granularity", - NULL}, - {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.minimum), "Address Minimum", - NULL}, - {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.maximum), "Address Maximum", - NULL}, - {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.translation_offset), + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address.granularity), + "Granularity", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address.minimum), + "Address Minimum", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address.maximum), + "Address Maximum", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address.translation_offset), "Translation Offset", NULL}, - {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address_length), + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address.address_length), "Address Length", NULL}, {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address16.resource_source), NULL, NULL} };@@ -200,15 +200,15 @@ struct acpi_rsdump_info acpi_rs_dump_address32[8] = { {ACPI_RSD_TITLE ,ACPI_RSD_TABLE_SIZE (acpi_rs_dump_address32), "32-Bit DWORD Address Space", NULL}, {ACPI_RSD_ADDRESS, 0, NULL, NULL}, - {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.granularity), "Granularity", - NULL}, - {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.minimum), "Address Minimum", - NULL}, - {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.maximum), "Address Maximum", - NULL}, - {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.translation_offset), + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address.granularity), + "Granularity", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address.minimum), + "Address Minimum", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address.maximum), + "Address Maximum", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address.translation_offset), "Translation Offset", NULL}, - {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address_length), + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address.address_length), "Address Length", NULL}, {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address32.resource_source), NULL, NULL} };@@ -217,15 +217,15 @@ struct acpi_rsdump_info acpi_rs_dump_address64[8] = { {ACPI_RSD_TITLE ,ACPI_RSD_TABLE_SIZE (acpi_rs_dump_address64), "64-Bit QWORD Address Space", NULL}, {ACPI_RSD_ADDRESS, 0, NULL, NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.granularity), "Granularity", - NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.minimum), "Address Minimum", - NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.maximum), "Address Maximum", - NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.translation_offset), + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address.granularity), + "Granularity", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address.minimum), + "Address Minimum", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address.maximum), + "Address Maximum", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address.translation_offset), "Translation Offset", NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address_length), + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address.address_length), "Address Length", NULL}, {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address64.resource_source), NULL, NULL} };@@ -234,15 +234,16 @@ struct acpi_rsdump_info acpi_rs_dump_ext_address64[8] = { {ACPI_RSD_TITLE ,ACPI_RSD_TABLE_SIZE (acpi_rs_dump_ext_address64), "64-Bit Extended Address Space", NULL}, {ACPI_RSD_ADDRESS, 0, NULL, NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.granularity), + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address.granularity), "Granularity", NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.minimum), + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address.minimum), "Address Minimum", NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.maximum), + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address.maximum), "Address Maximum", NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.translation_offset), + {ACPI_RSD_UINT64, +ACPI_RSD_OFFSET (ext_address64.address.translation_offset), "Translation Offset", NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address_length), + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address.address_length), "Address Length", NULL}, {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.type_specific), "Type-Specific Attribute", NULL}drivers/acpi/acpica/rsxface.c +5
-5@@ -60,11 +60,11 @@ ACPI_MODULE_NAME("rsxface")ACPI_COPY_FIELD (out, in, min_address_fixed); \ACPI_COPY_FIELD (out, in, max_address_fixed); \ACPI_COPY_FIELD (out, in, info); \ -ACPI_COPY_FIELD (out, in, granularity); \ -ACPI_COPY_FIELD (out, in, minimum); \ -ACPI_COPY_FIELD (out, in, maximum); \ -ACPI_COPY_FIELD (out, in, translation_offset); \ -ACPI_COPY_FIELD (out, in, address_length); \ +ACPI_COPY_FIELD (out, in, address.granularity); \ +ACPI_COPY_FIELD (out, in, address.minimum); \ +ACPI_COPY_FIELD (out, in, address.maximum); \ +ACPI_COPY_FIELD (out, in, address.translation_offset); \ +ACPI_COPY_FIELD (out, in, address.address_length); \ACPI_COPY_FIELD (out, in, resource_source);/* Local prototypes */ static acpi_statusinclude/acpi/acrestyp.h +23
-11@@ -305,43 +305,51 @@ struct acpi_resource_source {u8 max_address_fixed; \union acpi_resource_attribute info; -struct acpi_resource_address { -ACPI_RESOURCE_ADDRESS_COMMON}; - -struct acpi_resource_address16 { - ACPI_RESOURCE_ADDRESS_COMMON u16 granularity; +struct acpi_address16_attribute { +u16 granularity;u16 minimum;u16 maximum;u16 translation_offset;u16 address_length; -struct acpi_resource_source resource_source; }; -struct acpi_resource_address32 { - ACPI_RESOURCE_ADDRESS_COMMON u32 granularity; +struct acpi_address32_attribute { +u32 granularity;u32 minimum;u32 maximum;u32 translation_offset;u32 address_length; -struct acpi_resource_source resource_source; }; -struct acpi_resource_address64 { - ACPI_RESOURCE_ADDRESS_COMMON u64 granularity; +struct acpi_address64_attribute { +u64 granularity;u64 minimum;u64 maximum;u64 translation_offset;u64 address_length; +}; + +struct acpi_resource_address { +ACPI_RESOURCE_ADDRESS_COMMON}; + +struct acpi_resource_address16 { + ACPI_RESOURCE_ADDRESS_COMMON ACPI_ADDRESS16_ATTRIBUTE address; +struct acpi_resource_source resource_source; +}; + +struct acpi_resource_address32 { + ACPI_RESOURCE_ADDRESS_COMMON ACPI_ADDRESS32_ATTRIBUTE address; +struct acpi_resource_source resource_source; +}; + +struct acpi_resource_address64 { + ACPI_RESOURCE_ADDRESS_COMMON ACPI_ADDRESS64_ATTRIBUTE address;struct acpi_resource_source resource_source; }; struct acpi_resource_extended_address64 {include/acpi/acrestyp.h struct acpi_resource_source { · line 355
Quoted 10 lines
include/acpi/acrestyp.h +1
-5ACPI_RESOURCE_ADDRESS_COMMON u8 revision_ID; -u64 granularity; -u64 minimum; -u64 maximum; -u64 translation_offset; -u64 address_length; +ACPI_ADDRESS64_ATTRIBUTE address;u64 type_specific; };--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [RFC PATCH] ACPICA: Resources: Provide common part for struct acpi_resource_address structures.
Quoted 11 lines · Lv
Hi, Rafael
Quoted 9 lines
From: Rafael J. Wysocki [mailto:[email protected]]
Sent: Friday, January 23, 2015 6:50 AMQuoted 4 lines · Lv Zheng
struct
acpi_resource_addressand structacpi_resource_extended_address64share substracts just at different offsets. To unify the parsing functions, OSPMs like Linux need a newACPI_ADDRESS64_ATTRIBUTEas their substructs, so they can extract the shared data.
Quoted 5 lines
Quoted 1 line
Looks OK to me.
Could you help to ship it with linux-next directly so that Gerry can re-base his patchset on top of linux-next using this change?
I'll take care of remove this patch from ACPICA release cycle.
So do you want me to apply this one directly? I can do that.
Quoted 248 lines
Quoted 247 lines
Quoted 233 lines
Original-by Thomas Gleixner <[email protected]>Original-by Jiang Liu <[email protected]>Signed-off-by Lv Zheng <[email protected]>--- drivers/acpi/acpica/rsaddr.c | 9 +++--- drivers/acpi/acpica/rsdumpinfo.c | 59 +++++++++++++++++++------------------- drivers/acpi/acpica/rsxface.c | 10 +++---- include/acpi/acrestyp.h | 40 +++++++++++++++----------- 4 files changed, 64 insertions(+), 54 deletions(-)drivers/acpi/acpica/rsaddr.c +5
-4@@ -74,7 +74,7 @@ struct acpi_rsconvert_info acpi_rs_convert_address16[5] = {* Address Translation Offset * Address Length */ - {ACPI_RSC_MOVE16 ,ACPI_RS_OFFSET (data.address16.granularity), + {ACPI_RSC_MOVE16 ,ACPI_RS_OFFSET (data.address16.address.granularity),AML_OFFSET (address16.granularity), 5},@@ -112,7 +112,7 @@ struct acpi_rsconvert_info acpi_rs_convert_address32[5] = {* Address Translation Offset * Address Length */ - {ACPI_RSC_MOVE32 ,ACPI_RS_OFFSET (data.address32.granularity), + {ACPI_RSC_MOVE32 ,ACPI_RS_OFFSET (data.address32.address.granularity),AML_OFFSET (address32.granularity), 5},@@ -150,7 +150,7 @@ struct acpi_rsconvert_info acpi_rs_convert_address64[5] = {* Address Translation Offset * Address Length */ - {ACPI_RSC_MOVE64 ,ACPI_RS_OFFSET (data.address64.granularity), + {ACPI_RSC_MOVE64 ,ACPI_RS_OFFSET (data.address64.address.granularity),AML_OFFSET (address64.granularity), 5},@@ -194,7 +194,8 @@ struct acpi_rsconvert_info acpi_rs_convert_ext_address64[5] = {* Address Length * Type-Specific Attribute */ - {ACPI_RSC_MOVE64 ,ACPI_RS_OFFSET (data.ext_address64.granularity), + {ACPI_RSC_MOVE64 , +ACPI_RS_OFFSET (data.ext_address64.address.granularity),AML_OFFSET (ext_address64.granularity), 6} };drivers/acpi/acpica/rsdumpinfo.c +30
-29@@ -183,15 +183,15 @@ struct acpi_rsdump_info acpi_rs_dump_address16[8] = { {ACPI_RSD_TITLE ,ACPI_RSD_TABLE_SIZE (acpi_rs_dump_address16), "16-Bit WORD Address Space", NULL}, {ACPI_RSD_ADDRESS, 0, NULL, NULL}, - {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.granularity), "Granularity", - NULL}, - {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.minimum), "Address Minimum", - NULL}, - {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.maximum), "Address Maximum", - NULL}, - {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.translation_offset), + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address.granularity), + "Granularity", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address.minimum), + "Address Minimum", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address.maximum), + "Address Maximum", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address.translation_offset), "Translation Offset", NULL}, - {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address_length), + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address.address_length), "Address Length", NULL}, {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address16.resource_source), NULL, NULL} };@@ -200,15 +200,15 @@ struct acpi_rsdump_info acpi_rs_dump_address32[8] = { {ACPI_RSD_TITLE ,ACPI_RSD_TABLE_SIZE (acpi_rs_dump_address32), "32-Bit DWORD Address Space", NULL}, {ACPI_RSD_ADDRESS, 0, NULL, NULL}, - {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.granularity), "Granularity", - NULL}, - {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.minimum), "Address Minimum", - NULL}, - {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.maximum), "Address Maximum", - NULL}, - {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.translation_offset), + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address.granularity), + "Granularity", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address.minimum), + "Address Minimum", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address.maximum), + "Address Maximum", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address.translation_offset), "Translation Offset", NULL}, - {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address_length), + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address.address_length), "Address Length", NULL}, {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address32.resource_source), NULL, NULL} };@@ -217,15 +217,15 @@ struct acpi_rsdump_info acpi_rs_dump_address64[8] = { {ACPI_RSD_TITLE ,ACPI_RSD_TABLE_SIZE (acpi_rs_dump_address64), "64-Bit QWORD Address Space", NULL}, {ACPI_RSD_ADDRESS, 0, NULL, NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.granularity), "Granularity", - NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.minimum), "Address Minimum", - NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.maximum), "Address Maximum", - NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.translation_offset), + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address.granularity), + "Granularity", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address.minimum), + "Address Minimum", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address.maximum), + "Address Maximum", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address.translation_offset), "Translation Offset", NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address_length), + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address.address_length), "Address Length", NULL}, {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address64.resource_source), NULL, NULL} };@@ -234,15 +234,16 @@ struct acpi_rsdump_info acpi_rs_dump_ext_address64[8] = { {ACPI_RSD_TITLE ,ACPI_RSD_TABLE_SIZE (acpi_rs_dump_ext_address64), "64-Bit Extended Address Space", NULL}, {ACPI_RSD_ADDRESS, 0, NULL, NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.granularity), + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address.granularity), "Granularity", NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.minimum), + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address.minimum), "Address Minimum", NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.maximum), + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address.maximum), "Address Maximum", NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.translation_offset), + {ACPI_RSD_UINT64, +ACPI_RSD_OFFSET (ext_address64.address.translation_offset), "Translation Offset", NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address_length), + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address.address_length), "Address Length", NULL}, {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.type_specific), "Type-Specific Attribute", NULL}drivers/acpi/acpica/rsxface.c +5
-5@@ -60,11 +60,11 @@ ACPI_MODULE_NAME("rsxface")ACPI_COPY_FIELD (out, in, min_address_fixed); \ACPI_COPY_FIELD (out, in, max_address_fixed); \ACPI_COPY_FIELD (out, in, info); \ -ACPI_COPY_FIELD (out, in, granularity); \ -ACPI_COPY_FIELD (out, in, minimum); \ -ACPI_COPY_FIELD (out, in, maximum); \ -ACPI_COPY_FIELD (out, in, translation_offset); \ -ACPI_COPY_FIELD (out, in, address_length); \ +ACPI_COPY_FIELD (out, in, address.granularity); \ +ACPI_COPY_FIELD (out, in, address.minimum); \ +ACPI_COPY_FIELD (out, in, address.maximum); \ +ACPI_COPY_FIELD (out, in, address.translation_offset); \ +ACPI_COPY_FIELD (out, in, address.address_length); \ACPI_COPY_FIELD (out, in, resource_source);/* Local prototypes */ static acpi_statusinclude/acpi/acrestyp.h +23
-11@@ -305,43 +305,51 @@ struct acpi_resource_source {u8 max_address_fixed; \union acpi_resource_attribute info; -struct acpi_resource_address { -ACPI_RESOURCE_ADDRESS_COMMON}; - -struct acpi_resource_address16 { - ACPI_RESOURCE_ADDRESS_COMMON u16 granularity; +struct acpi_address16_attribute { +u16 granularity;u16 minimum;u16 maximum;u16 translation_offset;u16 address_length; -struct acpi_resource_source resource_source; }; -struct acpi_resource_address32 { - ACPI_RESOURCE_ADDRESS_COMMON u32 granularity; +struct acpi_address32_attribute { +u32 granularity;u32 minimum;u32 maximum;u32 translation_offset;u32 address_length; -struct acpi_resource_source resource_source; }; -struct acpi_resource_address64 { - ACPI_RESOURCE_ADDRESS_COMMON u64 granularity; +struct acpi_address64_attribute { +u64 granularity;u64 minimum;u64 maximum;u64 translation_offset;u64 address_length; +}; + +struct acpi_resource_address { +ACPI_RESOURCE_ADDRESS_COMMON}; + +struct acpi_resource_address16 { + ACPI_RESOURCE_ADDRESS_COMMON ACPI_ADDRESS16_ATTRIBUTE address; +struct acpi_resource_source resource_source; +}; + +struct acpi_resource_address32 { + ACPI_RESOURCE_ADDRESS_COMMON ACPI_ADDRESS32_ATTRIBUTE address; +struct acpi_resource_source resource_source; +}; + +struct acpi_resource_address64 { + ACPI_RESOURCE_ADDRESS_COMMON ACPI_ADDRESS64_ATTRIBUTE address;struct acpi_resource_source resource_source; }; struct acpi_resource_extended_address64 {include/acpi/acrestyp.h struct acpi_resource_source { · line 355
Quoted 10 lines
include/acpi/acrestyp.h +1
-5ACPI_RESOURCE_ADDRESS_COMMON u8 revision_ID; -u64 granularity; -u64 minimum; -u64 maximum; -u64 translation_offset; -u64 address_length; +ACPI_ADDRESS64_ATTRIBUTE address;u64 type_specific; };--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Zheng
Re: [Devel] [RFC PATCH] ACPICA: Resources: Provide common part for struct acpi_resource_address structures.
Hi, Rafael
Quoted 20 lines
-----Original Message-----
From: Rafael J. Wysocki [mailto:[email protected]]
Sent: Friday, January 23, 2015 11:21 PM
To: Zheng, Lv
Cc: Liu, Jiang; Thomas Gleixner ([email protected]); Wysocki, Rafael J; Brown, Len; Moore, Robert; Box, David E; Lv Zheng; linux- [email protected]; [email protected]
Subject: Re: [RFC PATCH] ACPICA: Resources: Provide common part for structacpi_resource_addressstructures.Quoted 11 lines · Lv
Hi, Rafael
Quoted 9 lines
From: Rafael J. Wysocki [mailto:[email protected]]
Sent: Friday, January 23, 2015 6:50 AMQuoted 4 lines · Lv Zheng
struct
acpi_resource_addressand structacpi_resource_extended_address64share substracts just at different offsets. To unify the parsing functions, OSPMs like Linux need a newACPI_ADDRESS64_ATTRIBUTEas their substructs, so they can extract the shared data.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Looks OK to me.
Could you help to ship it with linux-next directly so that Gerry can re-base his patchset on top of linux-next using this change?
I'll take care of remove this patch from ACPICA release cycle.So do you want me to apply this one directly? I can do that.
I noticed that this RFC is just a Linuxized ACPICA commit. Let me sync the structure changes with Linux code base and re-send it.
Thanks and best regards
-Lv
Quoted 254 lines
Quoted 233 lines
Quoted 233 lines
Quoted 233 lines
Original-by Thomas Gleixner <[email protected]>Original-by Jiang Liu <[email protected]>Signed-off-by Lv Zheng <[email protected]>--- drivers/acpi/acpica/rsaddr.c | 9 +++--- drivers/acpi/acpica/rsdumpinfo.c | 59 +++++++++++++++++++------------------- drivers/acpi/acpica/rsxface.c | 10 +++---- include/acpi/acrestyp.h | 40 +++++++++++++++----------- 4 files changed, 64 insertions(+), 54 deletions(-)drivers/acpi/acpica/rsaddr.c +5
-4@@ -74,7 +74,7 @@ struct acpi_rsconvert_info acpi_rs_convert_address16[5] = {* Address Translation Offset * Address Length */ - {ACPI_RSC_MOVE16 ,ACPI_RS_OFFSET (data.address16.granularity), + {ACPI_RSC_MOVE16 ,ACPI_RS_OFFSET (data.address16.address.granularity),AML_OFFSET (address16.granularity), 5},@@ -112,7 +112,7 @@ struct acpi_rsconvert_info acpi_rs_convert_address32[5] = {* Address Translation Offset * Address Length */ - {ACPI_RSC_MOVE32 ,ACPI_RS_OFFSET (data.address32.granularity), + {ACPI_RSC_MOVE32 ,ACPI_RS_OFFSET (data.address32.address.granularity),AML_OFFSET (address32.granularity), 5},@@ -150,7 +150,7 @@ struct acpi_rsconvert_info acpi_rs_convert_address64[5] = {* Address Translation Offset * Address Length */ - {ACPI_RSC_MOVE64 ,ACPI_RS_OFFSET (data.address64.granularity), + {ACPI_RSC_MOVE64 ,ACPI_RS_OFFSET (data.address64.address.granularity),AML_OFFSET (address64.granularity), 5},@@ -194,7 +194,8 @@ struct acpi_rsconvert_info acpi_rs_convert_ext_address64[5] = {* Address Length * Type-Specific Attribute */ - {ACPI_RSC_MOVE64 ,ACPI_RS_OFFSET (data.ext_address64.granularity), + {ACPI_RSC_MOVE64 , +ACPI_RS_OFFSET (data.ext_address64.address.granularity),AML_OFFSET (ext_address64.granularity), 6} };drivers/acpi/acpica/rsdumpinfo.c +30
-29@@ -183,15 +183,15 @@ struct acpi_rsdump_info acpi_rs_dump_address16[8] = { {ACPI_RSD_TITLE ,ACPI_RSD_TABLE_SIZE (acpi_rs_dump_address16), "16-Bit WORD Address Space", NULL}, {ACPI_RSD_ADDRESS, 0, NULL, NULL}, - {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.granularity), "Granularity", - NULL}, - {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.minimum), "Address Minimum", - NULL}, - {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.maximum), "Address Maximum", - NULL}, - {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.translation_offset), + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address.granularity), + "Granularity", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address.minimum), + "Address Minimum", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address.maximum), + "Address Maximum", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address.translation_offset), "Translation Offset", NULL}, - {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address_length), + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address.address_length), "Address Length", NULL}, {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address16.resource_source), NULL, NULL} };@@ -200,15 +200,15 @@ struct acpi_rsdump_info acpi_rs_dump_address32[8] = { {ACPI_RSD_TITLE ,ACPI_RSD_TABLE_SIZE (acpi_rs_dump_address32), "32-Bit DWORD Address Space", NULL}, {ACPI_RSD_ADDRESS, 0, NULL, NULL}, - {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.granularity), "Granularity", - NULL}, - {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.minimum), "Address Minimum", - NULL}, - {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.maximum), "Address Maximum", - NULL}, - {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.translation_offset), + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address.granularity), + "Granularity", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address.minimum), + "Address Minimum", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address.maximum), + "Address Maximum", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address.translation_offset), "Translation Offset", NULL}, - {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address_length), + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address.address_length), "Address Length", NULL}, {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address32.resource_source), NULL, NULL} };@@ -217,15 +217,15 @@ struct acpi_rsdump_info acpi_rs_dump_address64[8] = { {ACPI_RSD_TITLE ,ACPI_RSD_TABLE_SIZE (acpi_rs_dump_address64), "64-Bit QWORD Address Space", NULL}, {ACPI_RSD_ADDRESS, 0, NULL, NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.granularity), "Granularity", - NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.minimum), "Address Minimum", - NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.maximum), "Address Maximum", - NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.translation_offset), + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address.granularity), + "Granularity", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address.minimum), + "Address Minimum", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address.maximum), + "Address Maximum", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address.translation_offset), "Translation Offset", NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address_length), + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address.address_length), "Address Length", NULL}, {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address64.resource_source), NULL, NULL} };@@ -234,15 +234,16 @@ struct acpi_rsdump_info acpi_rs_dump_ext_address64[8] = { {ACPI_RSD_TITLE ,ACPI_RSD_TABLE_SIZE (acpi_rs_dump_ext_address64), "64-Bit Extended Address Space", NULL}, {ACPI_RSD_ADDRESS, 0, NULL, NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.granularity), + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address.granularity), "Granularity", NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.minimum), + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address.minimum), "Address Minimum", NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.maximum), + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address.maximum), "Address Maximum", NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.translation_offset), + {ACPI_RSD_UINT64, +ACPI_RSD_OFFSET (ext_address64.address.translation_offset), "Translation Offset", NULL}, - {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address_length), + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address.address_length), "Address Length", NULL}, {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.type_specific), "Type-Specific Attribute", NULL}drivers/acpi/acpica/rsxface.c +5
-5@@ -60,11 +60,11 @@ ACPI_MODULE_NAME("rsxface")ACPI_COPY_FIELD (out, in, min_address_fixed); \ACPI_COPY_FIELD (out, in, max_address_fixed); \ACPI_COPY_FIELD (out, in, info); \ -ACPI_COPY_FIELD (out, in, granularity); \ -ACPI_COPY_FIELD (out, in, minimum); \ -ACPI_COPY_FIELD (out, in, maximum); \ -ACPI_COPY_FIELD (out, in, translation_offset); \ -ACPI_COPY_FIELD (out, in, address_length); \ +ACPI_COPY_FIELD (out, in, address.granularity); \ +ACPI_COPY_FIELD (out, in, address.minimum); \ +ACPI_COPY_FIELD (out, in, address.maximum); \ +ACPI_COPY_FIELD (out, in, address.translation_offset); \ +ACPI_COPY_FIELD (out, in, address.address_length); \ACPI_COPY_FIELD (out, in, resource_source);/* Local prototypes */ static acpi_statusinclude/acpi/acrestyp.h +23
-11@@ -305,43 +305,51 @@ struct acpi_resource_source {u8 max_address_fixed; \union acpi_resource_attribute info; -struct acpi_resource_address { -ACPI_RESOURCE_ADDRESS_COMMON}; - -struct acpi_resource_address16 { - ACPI_RESOURCE_ADDRESS_COMMON u16 granularity; +struct acpi_address16_attribute { +u16 granularity;u16 minimum;u16 maximum;u16 translation_offset;u16 address_length; - struct acpi_resource_source resource_source; }; -struct acpi_resource_address32 { - ACPI_RESOURCE_ADDRESS_COMMON u32 granularity; +struct acpi_address32_attribute { +u32 granularity;u32 minimum;u32 maximum;u32 translation_offset;u32 address_length; - struct acpi_resource_source resource_source; }; -struct acpi_resource_address64 { - ACPI_RESOURCE_ADDRESS_COMMON u64 granularity; +struct acpi_address64_attribute { +u64 granularity;u64 minimum;u64 maximum;u64 translation_offset;u64 address_length; +}; + +struct acpi_resource_address { +ACPI_RESOURCE_ADDRESS_COMMON}; + +struct acpi_resource_address16 { + ACPI_RESOURCE_ADDRESS_COMMON ACPI_ADDRESS16_ATTRIBUTE address; + struct acpi_resource_source resource_source; +}; + +struct acpi_resource_address32 { + ACPI_RESOURCE_ADDRESS_COMMON ACPI_ADDRESS32_ATTRIBUTE address; + struct acpi_resource_source resource_source; +}; + +struct acpi_resource_address64 { + ACPI_RESOURCE_ADDRESS_COMMON ACPI_ADDRESS64_ATTRIBUTE address; struct acpi_resource_source resource_source; };Quoted 17 lines
Quoted 8 lines
Quoted 8 lines
include/acpi/acrestyp.h +1
-5struct acpi_resource_extended_address64 { ACPI_RESOURCE_ADDRESS_COMMON u8 revision_ID; -u64 granularity; -u64 minimum; -u64 maximum; -u64 translation_offset; -u64 address_length; +ACPI_ADDRESS64_ATTRIBUTE address;Quoted 8 lines
include/acpi/acrestyp.h struct acpi_resource_source { · line 355
Quoted 4 lines
include/acpi/acrestyp.h +0
-0u64 type_specific; };--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.