svn commit: r350791 - stable/11/sys/dev/ahci

Alexander Motin mav at FreeBSD.org
Thu Aug 8 21:43:01 UTC 2019


Author: mav
Date: Thu Aug  8 21:43:00 2019
New Revision: 350791
URL: https://svnweb.freebsd.org/changeset/base/350791

Log:
  MFC r336760 (by luporl): Fixed endianess issue in AHCI driver
  
  There were some bits that were being set in cmd_flags (a field of AHCI's
  command list structure) after cmd_flags was converted to little endian.
  On a big endian host, such as PowerPC, this would set the wrong bits.
  This was preventing AHCI driver from working on these hosts.

Modified:
  stable/11/sys/dev/ahci/ahci.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/ahci/ahci.c
==============================================================================
--- stable/11/sys/dev/ahci/ahci.c	Thu Aug  8 21:38:53 2019	(r350790)
+++ stable/11/sys/dev/ahci/ahci.c	Thu Aug  8 21:43:00 2019	(r350791)
@@ -1528,6 +1528,7 @@ ahci_execute_transaction(struct ahci_slot *slot)
 	int fis_size, i, softreset;
 	uint8_t *fis = ch->dma.rfis + 0x40;
 	uint8_t val;
+	uint16_t cmd_flags;
 
 	/* Get a piece of the workspace for this request */
 	ctp = (struct ahci_cmd_tab *)
@@ -1541,12 +1542,12 @@ ahci_execute_transaction(struct ahci_slot *slot)
 	/* Setup the command list entry */
 	clp = (struct ahci_cmd_list *)
 	    (ch->dma.work + AHCI_CL_OFFSET + (AHCI_CL_SIZE * slot->slot));
-	clp->cmd_flags = htole16(
+	cmd_flags =
 		    (ccb->ccb_h.flags & CAM_DIR_OUT ? AHCI_CMD_WRITE : 0) |
 		    (ccb->ccb_h.func_code == XPT_SCSI_IO ?
 		     (AHCI_CMD_ATAPI | AHCI_CMD_PREFETCH) : 0) |
 		    (fis_size / sizeof(u_int32_t)) |
-		    (port << 12));
+		    (port << 12);
 	clp->prd_length = htole16(slot->dma.nsegs);
 	/* Special handling for Soft Reset command. */
 	if ((ccb->ccb_h.func_code == XPT_ATA_IO) &&
@@ -1557,7 +1558,7 @@ ahci_execute_transaction(struct ahci_slot *slot)
 			ahci_stop(ch);
 			ahci_clo(ch);
 			ahci_start(ch, 0);
-			clp->cmd_flags |= AHCI_CMD_RESET | AHCI_CMD_CLR_BUSY;
+			cmd_flags |= AHCI_CMD_RESET | AHCI_CMD_CLR_BUSY;
 		} else {
 			softreset = 2;
 			/* Prepare FIS receive area for check. */
@@ -1567,6 +1568,7 @@ ahci_execute_transaction(struct ahci_slot *slot)
 	} else
 		softreset = 0;
 	clp->bytecount = 0;
+	clp->cmd_flags = htole16(cmd_flags);
 	clp->cmd_table_phys = htole64(ch->dma.work_bus + AHCI_CT_OFFSET +
 				  (AHCI_CT_SIZE * slot->slot));
 	bus_dmamap_sync(ch->dma.work_tag, ch->dma.work_map,


More information about the svn-src-all mailing list