From owner-svn-src-head@freebsd.org Fri Jul 27 13:11:06 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9CBD2104A2B4; Fri, 27 Jul 2018 13:11:06 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 53CF973CF1; Fri, 27 Jul 2018 13:11:06 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 34F9E18517; Fri, 27 Jul 2018 13:11:06 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6RDB6IC050946; Fri, 27 Jul 2018 13:11:06 GMT (envelope-from luporl@FreeBSD.org) Received: (from luporl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6RDB6L9050945; Fri, 27 Jul 2018 13:11:06 GMT (envelope-from luporl@FreeBSD.org) Message-Id: <201807271311.w6RDB6L9050945@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: luporl set sender to luporl@FreeBSD.org using -f From: Leandro Lupori Date: Fri, 27 Jul 2018 13:11:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r336760 - head/sys/dev/ahci X-SVN-Group: head X-SVN-Commit-Author: luporl X-SVN-Commit-Paths: head/sys/dev/ahci X-SVN-Commit-Revision: 336760 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Jul 2018 13:11:06 -0000 Author: luporl Date: Fri Jul 27 13:11:05 2018 New Revision: 336760 URL: https://svnweb.freebsd.org/changeset/base/336760 Log: 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. Reviewed by: jhibbits Approved by: jhibbits (mentor) Modified: head/sys/dev/ahci/ahci.c Modified: head/sys/dev/ahci/ahci.c ============================================================================== --- head/sys/dev/ahci/ahci.c Fri Jul 27 11:35:58 2018 (r336759) +++ head/sys/dev/ahci/ahci.c Fri Jul 27 13:11:05 2018 (r336760) @@ -1523,6 +1523,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 *) @@ -1536,12 +1537,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) && @@ -1552,7 +1553,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. */ @@ -1562,6 +1563,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,