diff options
Diffstat (limited to 'arch/x86/pci/acpi.c')
-rw-r--r-- | arch/x86/pci/acpi.c | 84 |
1 files changed, 39 insertions, 45 deletions
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c index c7b1ebfb7da7..31930fd30ea9 100644 --- a/arch/x86/pci/acpi.c +++ b/arch/x86/pci/acpi.c | |||
@@ -66,14 +66,44 @@ resource_to_addr(struct acpi_resource *resource, | |||
66 | struct acpi_resource_address64 *addr) | 66 | struct acpi_resource_address64 *addr) |
67 | { | 67 | { |
68 | acpi_status status; | 68 | acpi_status status; |
69 | 69 | struct acpi_resource_memory24 *memory24; | |
70 | status = acpi_resource_to_address64(resource, addr); | 70 | struct acpi_resource_memory32 *memory32; |
71 | if (ACPI_SUCCESS(status) && | 71 | struct acpi_resource_fixed_memory32 *fixed_memory32; |
72 | (addr->resource_type == ACPI_MEMORY_RANGE || | 72 | |
73 | addr->resource_type == ACPI_IO_RANGE) && | 73 | memset(addr, 0, sizeof(*addr)); |
74 | addr->address_length > 0 && | 74 | switch (resource->type) { |
75 | addr->producer_consumer == ACPI_PRODUCER) { | 75 | case ACPI_RESOURCE_TYPE_MEMORY24: |
76 | memory24 = &resource->data.memory24; | ||
77 | addr->resource_type = ACPI_MEMORY_RANGE; | ||
78 | addr->minimum = memory24->minimum; | ||
79 | addr->address_length = memory24->address_length; | ||
80 | addr->maximum = addr->minimum + addr->address_length - 1; | ||
81 | return AE_OK; | ||
82 | case ACPI_RESOURCE_TYPE_MEMORY32: | ||
83 | memory32 = &resource->data.memory32; | ||
84 | addr->resource_type = ACPI_MEMORY_RANGE; | ||
85 | addr->minimum = memory32->minimum; | ||
86 | addr->address_length = memory32->address_length; | ||
87 | addr->maximum = addr->minimum + addr->address_length - 1; | ||
76 | return AE_OK; | 88 | return AE_OK; |
89 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: | ||
90 | fixed_memory32 = &resource->data.fixed_memory32; | ||
91 | addr->resource_type = ACPI_MEMORY_RANGE; | ||
92 | addr->minimum = fixed_memory32->address; | ||
93 | addr->address_length = fixed_memory32->address_length; | ||
94 | addr->maximum = addr->minimum + addr->address_length - 1; | ||
95 | return AE_OK; | ||
96 | case ACPI_RESOURCE_TYPE_ADDRESS16: | ||
97 | case ACPI_RESOURCE_TYPE_ADDRESS32: | ||
98 | case ACPI_RESOURCE_TYPE_ADDRESS64: | ||
99 | status = acpi_resource_to_address64(resource, addr); | ||
100 | if (ACPI_SUCCESS(status) && | ||
101 | (addr->resource_type == ACPI_MEMORY_RANGE || | ||
102 | addr->resource_type == ACPI_IO_RANGE) && | ||
103 | addr->address_length > 0) { | ||
104 | return AE_OK; | ||
105 | } | ||
106 | break; | ||
77 | } | 107 | } |
78 | return AE_ERROR; | 108 | return AE_ERROR; |
79 | } | 109 | } |
@@ -91,30 +121,6 @@ count_resource(struct acpi_resource *acpi_res, void *data) | |||
91 | return AE_OK; | 121 | return AE_OK; |
92 | } | 122 | } |
93 | 123 | ||
94 | static void | ||
95 | align_resource(struct acpi_device *bridge, struct resource *res) | ||
96 | { | ||
97 | int align = (res->flags & IORESOURCE_MEM) ? 16 : 4; | ||
98 | |||
99 | /* | ||
100 | * Host bridge windows are not BARs, but the decoders on the PCI side | ||
101 | * that claim this address space have starting alignment and length | ||
102 | * constraints, so fix any obvious BIOS goofs. | ||
103 | */ | ||
104 | if (!IS_ALIGNED(res->start, align)) { | ||
105 | dev_printk(KERN_DEBUG, &bridge->dev, | ||
106 | "host bridge window %pR invalid; " | ||
107 | "aligning start to %d-byte boundary\n", res, align); | ||
108 | res->start &= ~(align - 1); | ||
109 | } | ||
110 | if (!IS_ALIGNED(res->end + 1, align)) { | ||
111 | dev_printk(KERN_DEBUG, &bridge->dev, | ||
112 | "host bridge window %pR invalid; " | ||
113 | "aligning end to %d-byte boundary\n", res, align); | ||
114 | res->end = ALIGN(res->end, align) - 1; | ||
115 | } | ||
116 | } | ||
117 | |||
118 | static acpi_status | 124 | static acpi_status |
119 | setup_resource(struct acpi_resource *acpi_res, void *data) | 125 | setup_resource(struct acpi_resource *acpi_res, void *data) |
120 | { | 126 | { |
@@ -124,7 +130,7 @@ setup_resource(struct acpi_resource *acpi_res, void *data) | |||
124 | acpi_status status; | 130 | acpi_status status; |
125 | unsigned long flags; | 131 | unsigned long flags; |
126 | struct resource *root, *conflict; | 132 | struct resource *root, *conflict; |
127 | u64 start, end, max_len; | 133 | u64 start, end; |
128 | 134 | ||
129 | status = resource_to_addr(acpi_res, &addr); | 135 | status = resource_to_addr(acpi_res, &addr); |
130 | if (!ACPI_SUCCESS(status)) | 136 | if (!ACPI_SUCCESS(status)) |
@@ -141,19 +147,8 @@ setup_resource(struct acpi_resource *acpi_res, void *data) | |||
141 | } else | 147 | } else |
142 | return AE_OK; | 148 | return AE_OK; |
143 | 149 | ||
144 | max_len = addr.maximum - addr.minimum + 1; | ||
145 | if (addr.address_length > max_len) { | ||
146 | dev_printk(KERN_DEBUG, &info->bridge->dev, | ||
147 | "host bridge window length %#llx doesn't fit in " | ||
148 | "%#llx-%#llx, trimming\n", | ||
149 | (unsigned long long) addr.address_length, | ||
150 | (unsigned long long) addr.minimum, | ||
151 | (unsigned long long) addr.maximum); | ||
152 | addr.address_length = max_len; | ||
153 | } | ||
154 | |||
155 | start = addr.minimum + addr.translation_offset; | 150 | start = addr.minimum + addr.translation_offset; |
156 | end = start + addr.address_length - 1; | 151 | end = addr.maximum + addr.translation_offset; |
157 | 152 | ||
158 | res = &info->res[info->res_num]; | 153 | res = &info->res[info->res_num]; |
159 | res->name = info->name; | 154 | res->name = info->name; |
@@ -161,7 +156,6 @@ setup_resource(struct acpi_resource *acpi_res, void *data) | |||
161 | res->start = start; | 156 | res->start = start; |
162 | res->end = end; | 157 | res->end = end; |
163 | res->child = NULL; | 158 | res->child = NULL; |
164 | align_resource(info->bridge, res); | ||
165 | 159 | ||
166 | if (!pci_use_crs) { | 160 | if (!pci_use_crs) { |
167 | dev_printk(KERN_DEBUG, &info->bridge->dev, | 161 | dev_printk(KERN_DEBUG, &info->bridge->dev, |