ahci: properly reset PxCMD on HBA reset

While testing q35, I found that windows 7 (specifically, windows 7 ultimate
with sp1 x64), wouldn't install because it can't find the cdrom or disk drive.
The failure message is: 'A required cd/dvd device driver is missing. If you
have a driver floppy disk, CD, DVD, or USB flash drive, please insert it now.'
This can also be reproduced on piix by adding an ahci controller, and
observing that windows 7 does not see any devices behind it.

The problem is that when windows issues a HBA reset, qemu does not reset the
individual ports' PxCMD register. Windows 7 then reads back the PxCMD register
and presumably assumes that the ahci controller has already been initialized.
Windows then never sets up the PxIE register to enable interrupts, and thus it
never gets irqs back when it sends ata device inquiry commands.

This change brings qemu into ahci 1.3 specification compliance.

Section 10.4.3 HBA Reset:

"
When GHC.HR is set to '1', GHC.AE, GHC.IE, the IS register, and all port
register fields (except PxFB/PxFBU/PxCLB/PxCLBU) that are not HwInit in the
HBA's register memory space are reset.
"

I've also re-tested Fedora 16 and 17 to verify that they continue to work with
this change.

Signed-off-by: Jason Baron <jbaron@redhat.com>
Acked-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
1 file changed
tree: b8f83e1fcce32cc5f9710efe64fd761c8873e771
  1. audio/
  2. block/
  3. bsd-user/
  4. default-configs/
  5. docs/
  6. fpu/
  7. fsdev/
  8. gdb-xml/
  9. hw/
  10. include/
  11. libcacard/
  12. linux-headers/
  13. linux-user/
  14. net/
  15. pc-bios/
  16. qapi/
  17. qga/
  18. QMP/
  19. qom/
  20. roms/
  21. scripts/
  22. slirp/
  23. sysconfigs/
  24. target-alpha/
  25. target-arm/
  26. target-cris/
  27. target-i386/
  28. target-lm32/
  29. target-m68k/
  30. target-microblaze/
  31. target-mips/
  32. target-openrisc/
  33. target-ppc/
  34. target-s390x/
  35. target-sh4/
  36. target-sparc/
  37. target-unicore32/
  38. target-xtensa/
  39. tcg/
  40. tests/
  41. trace/
  42. ui/
  43. .exrc
  44. .gitignore
  45. .gitmodules
  46. .mailmap
  47. a.out.h
  48. acl.c
  49. acl.h
  50. aes.c
  51. aes.h
  52. aio.c
  53. alpha-dis.c
  54. alpha.ld
  55. arch_init.c
  56. arch_init.h
  57. arm-dis.c
  58. arm.ld
  59. async.c
  60. balloon.c
  61. balloon.h
  62. bitmap.c
  63. bitmap.h
  64. bitops.c
  65. bitops.h
  66. block-migration.c
  67. block-migration.h
  68. block.c
  69. block.h
  70. block_int.h
  71. blockdev.c
  72. blockdev.h
  73. bswap.h
  74. bt-host.c
  75. bt-host.h
  76. bt-vhci.c
  77. buffered_file.c
  78. buffered_file.h
  79. cache-utils.c
  80. cache-utils.h
  81. Changelog
  82. cmd.c
  83. cmd.h
  84. CODING_STYLE
  85. compatfd.c
  86. compatfd.h
  87. compiler.h
  88. config.h
  89. configure
  90. console.c
  91. console.h
  92. COPYING
  93. COPYING.LIB
  94. coroutine-gthread.c
  95. coroutine-sigaltstack.c
  96. coroutine-ucontext.c
  97. coroutine-win32.c
  98. cpu-all.h
  99. cpu-common.h
  100. cpu-defs.h
  101. cpu-exec.c
  102. cpus.c
  103. cpus.h
  104. cputlb.c
  105. cputlb.h
  106. cris-dis.c
  107. cursor.c
  108. cursor_hidden.xpm
  109. cursor_left_ptr.xpm
  110. cutils.c
  111. def-helper.h
  112. device_tree.c
  113. device_tree.h
  114. dis-asm.h
  115. disas.c
  116. disas.h
  117. dma-helpers.c
  118. dma.h
  119. dump-stub.c
  120. dump.c
  121. dump.h
  122. dyngen-exec.h
  123. elf.h
  124. envlist.c
  125. envlist.h
  126. error.c
  127. error.h
  128. event_notifier.c
  129. event_notifier.h
  130. exec-all.h
  131. exec-memory.h
  132. exec-obsolete.h
  133. exec.c
  134. gdbstub.c
  135. gdbstub.h
  136. gen-icount.h
  137. HACKING
  138. hmp-commands.hx
  139. hmp.c
  140. hmp.h
  141. host-utils.c
  142. host-utils.h
  143. hppa-dis.c
  144. hppa.ld
  145. i386-dis.c
  146. i386.ld
  147. ia64-dis.c
  148. ia64.ld
  149. input.c
  150. int128.h
  151. iohandler.c
  152. ioport.c
  153. ioport.h
  154. iorange.h
  155. iov.c
  156. iov.h
  157. json-lexer.c
  158. json-lexer.h
  159. json-parser.c
  160. json-parser.h
  161. json-streamer.c
  162. json-streamer.h
  163. kvm-all.c
  164. kvm-stub.c
  165. kvm.h
  166. libfdt_env.h
  167. LICENSE
  168. linux-aio.c
  169. lm32-dis.c
  170. m68k-dis.c
  171. m68k.ld
  172. main-loop.c
  173. main-loop.h
  174. MAINTAINERS
  175. Makefile
  176. Makefile.dis
  177. Makefile.hw
  178. Makefile.objs
  179. Makefile.target
  180. Makefile.user
  181. memory.c
  182. memory.h
  183. memory_mapping-stub.c
  184. memory_mapping.c
  185. memory_mapping.h
  186. microblaze-dis.c
  187. migration-exec.c
  188. migration-fd.c
  189. migration-tcp.c
  190. migration-unix.c
  191. migration.c
  192. migration.h
  193. mips-dis.c
  194. mips.ld
  195. module.c
  196. module.h
  197. monitor.c
  198. monitor.h
  199. nbd.c
  200. nbd.h
  201. net.c
  202. net.h
  203. notify.c
  204. notify.h
  205. os-posix.c
  206. os-win32.c
  207. osdep.c
  208. osdep.h
  209. oslib-posix.c
  210. oslib-win32.c
  211. page_cache.c
  212. path.c
  213. pci-ids.txt
  214. pflib.c
  215. pflib.h
  216. poison.h
  217. posix-aio-compat.c
  218. ppc-dis.c
  219. ppc.ld
  220. ppc64.ld
  221. qapi-schema-guest.json
  222. qapi-schema-test.json
  223. qapi-schema.json
  224. qbool.c
  225. qbool.h
  226. qdict-test-data.txt
  227. qdict.c
  228. qdict.h
  229. qemu-aio.h
  230. qemu-barrier.h
  231. qemu-bridge-helper.c
  232. qemu-char.c
  233. qemu-char.h
  234. qemu-common.h
  235. qemu-config.c
  236. qemu-config.h
  237. qemu-coroutine-int.h
  238. qemu-coroutine-io.c
  239. qemu-coroutine-lock.c
  240. qemu-coroutine-sleep.c
  241. qemu-coroutine.c
  242. qemu-coroutine.h
  243. qemu-doc.texi
  244. qemu-error.c
  245. qemu-error.h
  246. qemu-file.h
  247. qemu-ga.c
  248. qemu-img-cmds.hx
  249. qemu-img.c
  250. qemu-img.texi
  251. qemu-io.c
  252. qemu-lock.h
  253. qemu-log.c
  254. qemu-log.h
  255. qemu-nbd.c
  256. qemu-nbd.texi
  257. qemu-objects.h
  258. qemu-option-internal.h
  259. qemu-option.c
  260. qemu-option.h
  261. qemu-options-wrapper.h
  262. qemu-options.h
  263. qemu-options.hx
  264. qemu-os-posix.h
  265. qemu-os-win32.h
  266. qemu-progress.c
  267. qemu-queue.h
  268. qemu-seccomp.c
  269. qemu-seccomp.h
  270. qemu-sockets.c
  271. qemu-tech.texi
  272. qemu-thread-posix.c
  273. qemu-thread-posix.h
  274. qemu-thread-win32.c
  275. qemu-thread-win32.h
  276. qemu-thread.h
  277. qemu-timer-common.c
  278. qemu-timer.c
  279. qemu-timer.h
  280. qemu-tls.h
  281. qemu-tool.c
  282. qemu-user.c
  283. qemu-x509.h
  284. qemu-xattr.h
  285. qemu.sasl
  286. qemu_socket.h
  287. qerror.c
  288. qerror.h
  289. qfloat.c
  290. qfloat.h
  291. qint.c
  292. qint.h
  293. qjson.c
  294. qjson.h
  295. qlist.c
  296. qlist.h
  297. qmp-commands.hx
  298. qmp.c
  299. qobject.h
  300. qstring.c
  301. qstring.h
  302. qtest.c
  303. qtest.h
  304. range.h
  305. readline.c
  306. readline.h
  307. README
  308. rules.mak
  309. s390-dis.c
  310. s390.ld
  311. savevm.c
  312. sh4-dis.c
  313. softmmu-semi.h
  314. softmmu_defs.h
  315. softmmu_exec.h
  316. softmmu_header.h
  317. softmmu_template.h
  318. sparc-dis.c
  319. sparc.ld
  320. sparc64.ld
  321. spice-qemu-char.c
  322. sysemu.h
  323. targphys.h
  324. tcg-runtime.c
  325. tci-dis.c
  326. tci.c
  327. thunk.c
  328. thunk.h
  329. TODO
  330. trace-events
  331. translate-all.c
  332. uboot_image.h
  333. user-exec.c
  334. VERSION
  335. version.rc
  336. vgafont.h
  337. vl.c
  338. vmstate.h
  339. x86_64.ld
  340. xen-all.c
  341. xen-mapcache.c
  342. xen-mapcache.h
  343. xen-stub.c