diff options
Diffstat (limited to 'arch/powerpc/platforms/powernv/opal-flash.c')
-rw-r--r-- | arch/powerpc/platforms/powernv/opal-flash.c | 35 |
1 files changed, 8 insertions, 27 deletions
diff --git a/arch/powerpc/platforms/powernv/opal-flash.c b/arch/powerpc/platforms/powernv/opal-flash.c index d8773079ce19..714ef972406b 100644 --- a/arch/powerpc/platforms/powernv/opal-flash.c +++ b/arch/powerpc/platforms/powernv/opal-flash.c | |||
@@ -76,8 +76,8 @@ | |||
76 | /* Validate buffer size */ | 76 | /* Validate buffer size */ |
77 | #define VALIDATE_BUF_SIZE 4096 | 77 | #define VALIDATE_BUF_SIZE 4096 |
78 | 78 | ||
79 | /* XXX: Assume candidate image size is <= 256MB */ | 79 | /* XXX: Assume candidate image size is <= 1GB */ |
80 | #define MAX_IMAGE_SIZE 0x10000000 | 80 | #define MAX_IMAGE_SIZE 0x40000000 |
81 | 81 | ||
82 | /* Flash sg list version */ | 82 | /* Flash sg list version */ |
83 | #define SG_LIST_VERSION (1UL) | 83 | #define SG_LIST_VERSION (1UL) |
@@ -103,27 +103,6 @@ struct image_header_t { | |||
103 | uint32_t size; | 103 | uint32_t size; |
104 | }; | 104 | }; |
105 | 105 | ||
106 | /* Scatter/gather entry */ | ||
107 | struct opal_sg_entry { | ||
108 | void *data; | ||
109 | long length; | ||
110 | }; | ||
111 | |||
112 | /* We calculate number of entries based on PAGE_SIZE */ | ||
113 | #define SG_ENTRIES_PER_NODE ((PAGE_SIZE - 16) / sizeof(struct opal_sg_entry)) | ||
114 | |||
115 | /* | ||
116 | * This struct is very similar but not identical to that | ||
117 | * needed by the opal flash update. All we need to do for | ||
118 | * opal is rewrite num_entries into a version/length and | ||
119 | * translate the pointers to absolute. | ||
120 | */ | ||
121 | struct opal_sg_list { | ||
122 | unsigned long num_entries; | ||
123 | struct opal_sg_list *next; | ||
124 | struct opal_sg_entry entry[SG_ENTRIES_PER_NODE]; | ||
125 | }; | ||
126 | |||
127 | struct validate_flash_t { | 106 | struct validate_flash_t { |
128 | int status; /* Return status */ | 107 | int status; /* Return status */ |
129 | void *buf; /* Candidate image buffer */ | 108 | void *buf; /* Candidate image buffer */ |
@@ -333,7 +312,7 @@ static struct opal_sg_list *image_data_to_sglist(void) | |||
333 | addr = image_data.data; | 312 | addr = image_data.data; |
334 | size = image_data.size; | 313 | size = image_data.size; |
335 | 314 | ||
336 | sg1 = kzalloc((sizeof(struct opal_sg_list)), GFP_KERNEL); | 315 | sg1 = kzalloc(PAGE_SIZE, GFP_KERNEL); |
337 | if (!sg1) | 316 | if (!sg1) |
338 | return NULL; | 317 | return NULL; |
339 | 318 | ||
@@ -351,8 +330,7 @@ static struct opal_sg_list *image_data_to_sglist(void) | |||
351 | 330 | ||
352 | sg1->num_entries++; | 331 | sg1->num_entries++; |
353 | if (sg1->num_entries >= SG_ENTRIES_PER_NODE) { | 332 | if (sg1->num_entries >= SG_ENTRIES_PER_NODE) { |
354 | sg1->next = kzalloc((sizeof(struct opal_sg_list)), | 333 | sg1->next = kzalloc(PAGE_SIZE, GFP_KERNEL); |
355 | GFP_KERNEL); | ||
356 | if (!sg1->next) { | 334 | if (!sg1->next) { |
357 | pr_err("%s : Failed to allocate memory\n", | 335 | pr_err("%s : Failed to allocate memory\n", |
358 | __func__); | 336 | __func__); |
@@ -402,7 +380,10 @@ static int opal_flash_update(int op) | |||
402 | else | 380 | else |
403 | sg->next = NULL; | 381 | sg->next = NULL; |
404 | 382 | ||
405 | /* Make num_entries into the version/length field */ | 383 | /* |
384 | * Convert num_entries to version/length format | ||
385 | * to satisfy OPAL. | ||
386 | */ | ||
406 | sg->num_entries = (SG_LIST_VERSION << 56) | | 387 | sg->num_entries = (SG_LIST_VERSION << 56) | |
407 | (sg->num_entries * sizeof(struct opal_sg_entry) + 16); | 388 | (sg->num_entries * sizeof(struct opal_sg_entry) + 16); |
408 | } | 389 | } |