From owner-svn-src-head@freebsd.org Thu Jul 7 22:10:11 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 85F54B825FB; Thu, 7 Jul 2016 22:10:11 +0000 (UTC) (envelope-from mav@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 mx1.freebsd.org (Postfix) with ESMTPS id 4F9731ED8; Thu, 7 Jul 2016 22:10:11 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u67MAAX5051860; Thu, 7 Jul 2016 22:10:10 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u67MAAZb051858; Thu, 7 Jul 2016 22:10:10 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201607072210.u67MAAZb051858@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 7 Jul 2016 22:10:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302402 - head/sys/dev/ahci X-SVN-Group: head 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.22 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: Thu, 07 Jul 2016 22:10:11 -0000 Author: mav Date: Thu Jul 7 22:10:10 2016 New Revision: 302402 URL: https://svnweb.freebsd.org/changeset/base/302402 Log: Fix ahci(4) driver attach to controller with 32 ports. Incorrect sign expansion in variables that supposed to be a bit fields caused infinite loop. Fixing this allows system properly detect maximal possible 32 devices configured on AHCI HBA of BHyVe. That case did not happen in a wild before due to lack of hardware AHCI HBAs with 32 ports. Approved by: re (gjb@) MFC after: 1 week Modified: head/sys/dev/ahci/ahci.c head/sys/dev/ahci/ahci.h Modified: head/sys/dev/ahci/ahci.c ============================================================================== --- head/sys/dev/ahci/ahci.c Thu Jul 7 21:44:59 2016 (r302401) +++ head/sys/dev/ahci/ahci.c Thu Jul 7 22:10:10 2016 (r302402) @@ -166,8 +166,8 @@ int ahci_attach(device_t dev) { struct ahci_controller *ctlr = device_get_softc(dev); - int error, i, u, speed, unit; - u_int32_t version; + int error, i, speed, unit; + uint32_t u, version; device_t child; ctlr->dev = dev; Modified: head/sys/dev/ahci/ahci.h ============================================================================== --- head/sys/dev/ahci/ahci.h Thu Jul 7 21:44:59 2016 (r302401) +++ head/sys/dev/ahci/ahci.h Thu Jul 7 22:10:10 2016 (r302402) @@ -474,7 +474,7 @@ struct ahci_enclosure { uint8_t status[AHCI_MAX_PORTS][4]; /* ArrayDev statuses */ int quirks; int channels; - int ichannels; + uint32_t ichannels; }; /* structure describing a AHCI controller */ @@ -509,7 +509,7 @@ struct ahci_controller { int quirks; int numirqs; int channels; - int ichannels; + uint32_t ichannels; int ccc; /* CCC timeout */ int cccv; /* CCC vector */ int direct; /* Direct command completion */