Commit dccfafc4e1325dbf90d8ee7b2bc56e6e02eaf4b5
1 parent
111bfab3
This patch fixes two bugs in cuda emulation:
- the CUDA timer is always triggered twice, with current code - SET_TIME command is supposed to send back a 7 bytes packet (Jocelyn Mayer) git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1380 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
7 additions
and
4 deletions
hw/cuda.c
@@ -178,17 +178,20 @@ static int64_t get_next_irq_time(CUDATimer *s, int64_t current_time) | @@ -178,17 +178,20 @@ static int64_t get_next_irq_time(CUDATimer *s, int64_t current_time) | ||
178 | /* current counter value */ | 178 | /* current counter value */ |
179 | d = muldiv64(current_time - s->load_time, | 179 | d = muldiv64(current_time - s->load_time, |
180 | CUDA_TIMER_FREQ, ticks_per_sec); | 180 | CUDA_TIMER_FREQ, ticks_per_sec); |
181 | - if (d <= s->counter_value) { | 181 | + if (d < s->counter_value) { |
182 | next_time = s->counter_value + 1; | 182 | next_time = s->counter_value + 1; |
183 | - } else { | ||
184 | - base = ((d - s->counter_value) / s->latch); | 183 | + } else |
184 | + { | ||
185 | + base = ((d - s->counter_value + 1) / s->latch); | ||
185 | base = (base * s->latch) + s->counter_value; | 186 | base = (base * s->latch) + s->counter_value; |
186 | next_time = base + s->latch; | 187 | next_time = base + s->latch; |
187 | } | 188 | } |
189 | +#if 0 | ||
188 | #ifdef DEBUG_CUDA | 190 | #ifdef DEBUG_CUDA |
189 | printf("latch=%d counter=%lld delta_next=%lld\n", | 191 | printf("latch=%d counter=%lld delta_next=%lld\n", |
190 | s->latch, d, next_time - d); | 192 | s->latch, d, next_time - d); |
191 | #endif | 193 | #endif |
194 | +#endif | ||
192 | next_time = muldiv64(next_time, ticks_per_sec, CUDA_TIMER_FREQ) + | 195 | next_time = muldiv64(next_time, ticks_per_sec, CUDA_TIMER_FREQ) + |
193 | s->load_time; | 196 | s->load_time; |
194 | if (next_time <= current_time) | 197 | if (next_time <= current_time) |
@@ -505,6 +508,7 @@ static void cuda_receive_packet(CUDAState *s, | @@ -505,6 +508,7 @@ static void cuda_receive_packet(CUDAState *s, | ||
505 | cuda_send_packet_to_host(s, obuf, 2); | 508 | cuda_send_packet_to_host(s, obuf, 2); |
506 | break; | 509 | break; |
507 | case CUDA_GET_TIME: | 510 | case CUDA_GET_TIME: |
511 | + case CUDA_SET_TIME: | ||
508 | /* XXX: add time support ? */ | 512 | /* XXX: add time support ? */ |
509 | ti = time(NULL) + RTC_OFFSET; | 513 | ti = time(NULL) + RTC_OFFSET; |
510 | obuf[0] = CUDA_PACKET; | 514 | obuf[0] = CUDA_PACKET; |
@@ -516,7 +520,6 @@ static void cuda_receive_packet(CUDAState *s, | @@ -516,7 +520,6 @@ static void cuda_receive_packet(CUDAState *s, | ||
516 | obuf[6] = ti; | 520 | obuf[6] = ti; |
517 | cuda_send_packet_to_host(s, obuf, 7); | 521 | cuda_send_packet_to_host(s, obuf, 7); |
518 | break; | 522 | break; |
519 | - case CUDA_SET_TIME: | ||
520 | case CUDA_FILE_SERVER_FLAG: | 523 | case CUDA_FILE_SERVER_FLAG: |
521 | case CUDA_SET_DEVICE_LIST: | 524 | case CUDA_SET_DEVICE_LIST: |
522 | case CUDA_SET_AUTO_RATE: | 525 | case CUDA_SET_AUTO_RATE: |