Commit 64a08a9ffc0ff8c9e56b204842a5650c19b48db4
Committed by
Wolfgang Denk
1 parent
67cbbf25c5
Exists in
master
and in
54 other branches
part_mac: dcache: allocate cacheline-aligned buffers
This patch forces the correct alignment for DMA operations of buffers used by part_mac.c. Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com> Cc: Wolfgang Denk <wd@denx.de>
Showing 1 changed file with 34 additions and 34 deletions Side-by-side Diff
disk/part_mac.c
... | ... | @@ -60,23 +60,23 @@ |
60 | 60 | */ |
61 | 61 | int test_part_mac (block_dev_desc_t *dev_desc) |
62 | 62 | { |
63 | - mac_driver_desc_t ddesc; | |
64 | - mac_partition_t mpart; | |
63 | + ALLOC_CACHE_ALIGN_BUFFER(mac_driver_desc_t, ddesc, 1); | |
64 | + ALLOC_CACHE_ALIGN_BUFFER(mac_partition_t, mpart, 1); | |
65 | 65 | ulong i, n; |
66 | 66 | |
67 | - if (part_mac_read_ddb (dev_desc, &ddesc)) { | |
67 | + if (part_mac_read_ddb (dev_desc, ddesc)) { | |
68 | 68 | /* error reading Driver Desriptor Block, or no valid Signature */ |
69 | 69 | return (-1); |
70 | 70 | } |
71 | 71 | |
72 | 72 | n = 1; /* assuming at least one partition */ |
73 | 73 | for (i=1; i<=n; ++i) { |
74 | - if ((dev_desc->block_read(dev_desc->dev, i, 1, (ulong *)&mpart) != 1) || | |
75 | - (mpart.signature != MAC_PARTITION_MAGIC) ) { | |
74 | + if ((dev_desc->block_read(dev_desc->dev, i, 1, (ulong *)mpart) != 1) || | |
75 | + (mpart->signature != MAC_PARTITION_MAGIC) ) { | |
76 | 76 | return (-1); |
77 | 77 | } |
78 | 78 | /* update partition count */ |
79 | - n = mpart.map_count; | |
79 | + n = mpart->map_count; | |
80 | 80 | } |
81 | 81 | return (0); |
82 | 82 | } |
83 | 83 | |
84 | 84 | |
85 | 85 | |
86 | 86 | |
... | ... | @@ -85,20 +85,20 @@ |
85 | 85 | void print_part_mac (block_dev_desc_t *dev_desc) |
86 | 86 | { |
87 | 87 | ulong i, n; |
88 | - mac_driver_desc_t ddesc; | |
89 | - mac_partition_t mpart; | |
88 | + ALLOC_CACHE_ALIGN_BUFFER(mac_driver_desc_t, ddesc, 1); | |
89 | + ALLOC_CACHE_ALIGN_BUFFER(mac_partition_t, mpart, 1); | |
90 | 90 | ldiv_t mb, gb; |
91 | 91 | |
92 | - if (part_mac_read_ddb (dev_desc, &ddesc)) { | |
92 | + if (part_mac_read_ddb (dev_desc, ddesc)) { | |
93 | 93 | /* error reading Driver Desriptor Block, or no valid Signature */ |
94 | 94 | return; |
95 | 95 | } |
96 | 96 | |
97 | - n = ddesc.blk_count; | |
97 | + n = ddesc->blk_count; | |
98 | 98 | |
99 | - mb = ldiv(n, ((1024 * 1024) / ddesc.blk_size)); /* MB */ | |
99 | + mb = ldiv(n, ((1024 * 1024) / ddesc->blk_size)); /* MB */ | |
100 | 100 | /* round to 1 digit */ |
101 | - mb.rem *= 10 * ddesc.blk_size; | |
101 | + mb.rem *= 10 * ddesc->blk_size; | |
102 | 102 | mb.rem += 512 * 1024; |
103 | 103 | mb.rem /= 1024 * 1024; |
104 | 104 | |
105 | 105 | |
... | ... | @@ -112,10 +112,10 @@ |
112 | 112 | "DeviceType=0x%x, DeviceId=0x%x\n\n" |
113 | 113 | " #: type name" |
114 | 114 | " length base (size)\n", |
115 | - ddesc.blk_size, | |
116 | - ddesc.blk_count, | |
115 | + ddesc->blk_size, | |
116 | + ddesc->blk_count, | |
117 | 117 | mb.quot, mb.rem, gb.quot, gb.rem, |
118 | - ddesc.dev_type, ddesc.dev_id | |
118 | + ddesc->dev_type, ddesc->dev_id | |
119 | 119 | ); |
120 | 120 | |
121 | 121 | n = 1; /* assuming at least one partition */ |
122 | 122 | |
123 | 123 | |
124 | 124 | |
125 | 125 | |
... | ... | @@ -124,25 +124,25 @@ |
124 | 124 | char c; |
125 | 125 | |
126 | 126 | printf ("%4ld: ", i); |
127 | - if (dev_desc->block_read (dev_desc->dev, i, 1, (ulong *)&mpart) != 1) { | |
127 | + if (dev_desc->block_read (dev_desc->dev, i, 1, (ulong *)mpart) != 1) { | |
128 | 128 | printf ("** Can't read Partition Map on %d:%ld **\n", |
129 | 129 | dev_desc->dev, i); |
130 | 130 | return; |
131 | 131 | } |
132 | 132 | |
133 | - if (mpart.signature != MAC_PARTITION_MAGIC) { | |
133 | + if (mpart->signature != MAC_PARTITION_MAGIC) { | |
134 | 134 | printf ("** Bad Signature on %d:%ld - " |
135 | 135 | "expected 0x%04x, got 0x%04x\n", |
136 | - dev_desc->dev, i, MAC_PARTITION_MAGIC, mpart.signature); | |
136 | + dev_desc->dev, i, MAC_PARTITION_MAGIC, mpart->signature); | |
137 | 137 | return; |
138 | 138 | } |
139 | 139 | |
140 | 140 | /* update partition count */ |
141 | - n = mpart.map_count; | |
141 | + n = mpart->map_count; | |
142 | 142 | |
143 | 143 | c = 'k'; |
144 | - bytes = mpart.block_count; | |
145 | - bytes /= (1024 / ddesc.blk_size); /* kB; assumes blk_size == 512 */ | |
144 | + bytes = mpart->block_count; | |
145 | + bytes /= (1024 / ddesc->blk_size); /* kB; assumes blk_size == 512 */ | |
146 | 146 | if (bytes >= 1024) { |
147 | 147 | bytes >>= 10; |
148 | 148 | c = 'M'; |
... | ... | @@ -153,10 +153,10 @@ |
153 | 153 | } |
154 | 154 | |
155 | 155 | printf ("%20.32s %-18.32s %10u @ %-10u (%3ld%c)\n", |
156 | - mpart.type, | |
157 | - mpart.name, | |
158 | - mpart.block_count, | |
159 | - mpart.start_block, | |
156 | + mpart->type, | |
157 | + mpart->name, | |
158 | + mpart->block_count, | |
159 | + mpart->start_block, | |
160 | 160 | bytes, c |
161 | 161 | ); |
162 | 162 | } |
163 | 163 | |
164 | 164 | |
165 | 165 | |
166 | 166 | |
... | ... | @@ -231,23 +231,23 @@ |
231 | 231 | |
232 | 232 | int get_partition_info_mac (block_dev_desc_t *dev_desc, int part, disk_partition_t *info) |
233 | 233 | { |
234 | - mac_driver_desc_t ddesc; | |
235 | - mac_partition_t mpart; | |
234 | + ALLOC_CACHE_ALIGN_BUFFER(mac_driver_desc_t, ddesc, 1); | |
235 | + ALLOC_CACHE_ALIGN_BUFFER(mac_partition_t, mpart, 1); | |
236 | 236 | |
237 | - if (part_mac_read_ddb (dev_desc, &ddesc)) { | |
237 | + if (part_mac_read_ddb (dev_desc, ddesc)) { | |
238 | 238 | return (-1); |
239 | 239 | } |
240 | 240 | |
241 | - info->blksz = ddesc.blk_size; | |
241 | + info->blksz = ddesc->blk_size; | |
242 | 242 | |
243 | - if (part_mac_read_pdb (dev_desc, part, &mpart)) { | |
243 | + if (part_mac_read_pdb (dev_desc, part, mpart)) { | |
244 | 244 | return (-1); |
245 | 245 | } |
246 | 246 | |
247 | - info->start = mpart.start_block; | |
248 | - info->size = mpart.block_count; | |
249 | - memcpy (info->type, mpart.type, sizeof(info->type)); | |
250 | - memcpy (info->name, mpart.name, sizeof(info->name)); | |
247 | + info->start = mpart->start_block; | |
248 | + info->size = mpart->block_count; | |
249 | + memcpy (info->type, mpart->type, sizeof(info->type)); | |
250 | + memcpy (info->name, mpart->name, sizeof(info->name)); | |
251 | 251 | |
252 | 252 | return (0); |
253 | 253 | } |