From owner-freebsd-embedded@FreeBSD.ORG Mon Jan 12 16:21:32 2015 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id AF58A486 for ; Mon, 12 Jan 2015 16:21:32 +0000 (UTC) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com [209.85.217.180]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2143F216 for ; Mon, 12 Jan 2015 16:21:31 +0000 (UTC) Received: by mail-lb0-f180.google.com with SMTP id l4so18430571lbv.11 for ; Mon, 12 Jan 2015 08:21:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=lkuS+gxNiKyMEGAKYAiOncdcGq1sPqgWuo0zLsMysI4=; b=gfZxaxQ9Jg5PsDq+w9ejMzNrEU/7EAxP7ymJrC1aN++RWN/5y7RVpSKPlB0mtkbpSH X9OGXlmMl0rSXFb9PEayuuHj0mx53nUgWsyGj1NSIC4ZFxcXu4iB3f5YerVo+eklQC2s C78QCrjT7J4WQb/rTkiwbgp3VU2HrPvAavTuUuPkmCImvr52tM3RPqagy1egWJHrYLV0 godRVTglOiVxe6fchff+Grbl+qmj0w3bJKGUjp0QSDZ24kUlUgfbIr06E27PmKJwScWK dvUL+As6cTDP8/hfO3s6ZcQ4TbPtXlp++vWOjOlfF/O3db/X6z/xbIKSHcSSS57V8J/F JPWA== X-Gm-Message-State: ALoCoQnkng/VtwpnfCOul6tQZeK0WxW6pAkdczC6fYfFL5sugWYoYYvy/HBOrregiCZfZnly1GeJ MIME-Version: 1.0 X-Received: by 10.112.55.199 with SMTP id u7mr11336887lbp.74.1421079684261; Mon, 12 Jan 2015 08:21:24 -0800 (PST) Received: by 10.25.14.208 with HTTP; Mon, 12 Jan 2015 08:21:24 -0800 (PST) In-Reply-To: <20150109172715.GU42409@kib.kiev.ua> References: <20150108203959.GR42409@kib.kiev.ua> <20150109172715.GU42409@kib.kiev.ua> Date: Mon, 12 Jan 2015 17:21:24 +0100 Message-ID: Subject: Re: [PATCH] Add support for 64-bit AHCI BAR. From: =?UTF-8?Q?Micha=C5=82_Stanek?= To: Konstantin Belousov Content-Type: multipart/mixed; boundary=001a1133fa76c74e71050c76e541 X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 Cc: freebsd-current@freebsd.org, freebsd-embedded@freebsd.org X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Jan 2015 16:21:32 -0000 --001a1133fa76c74e71050c76e541 Content-Type: text/plain; charset=UTF-8 2015-01-09 18:27 GMT+01:00 Konstantin Belousov : > On Fri, Jan 09, 2015 at 06:07:39PM +0100, Micha?? Stanek wrote: > > 2015-01-08 21:40 GMT+01:00 Konstantin Belousov : > > > > > > However, if > > > > AHCI uses 64-bit base addresses, then this register consists of two > > > dwords > > > > starting at offset 0x20 - BAR4 and BAR5. This is the case on our > arm64 > > > > target and possibly other platforms using 64-bit BARs for AHCI. > > > Is it specified anywhere, or just a quirk of the specific > implementation ? > > > If it is a quirk, would it make sense to also check the vendor or > device > > > id before applying the logic ? > > > > > > > > Yes, indeed it is a quirk as I just found out that our platform vendor > > actually uses BAR(0) as AHCI ABAR, while BAR(4) is used for something > else. > > I found it implemented as a quirk in Linux AHCI code. > > The BAR is still 64-bit but in a different position than AHCI spec > stated. > > I changed it as you suggested, the new patch is in the attachment. Please > > take a look. > This is probably technically correct (I am not AHCI code author), but note > that we have more structured quirks mechanism than directly checking vendor > and device id. Look at the ahci_ids table and the quirks member. > > Add a bit declaring the need of the quirk and test the bit, instead of > the vendor/devid. > OK, I added AHCI_Q_ABAR0 as a new quirk and test the bit in ahci_pci_attach. It works the same. New patch is in the attachment. > > > > > > > > > The following patch adds a check for the extended BAR in > > > ahci_pci_attach() > > > > and sets the 'rid' in bus_alloc_resource_any accordingly. It fixes > the > > > > allocation error on our platform. > > > > > > > > Please review and test this patch on other platforms. If there are no > > > > issues then it will be committed in a week. > > > > > > > > > > From b6220884d9e71d7c4fc1c2a22ade374fc023c831 Mon Sep 17 00:00:00 2001 > > From: Michal Stanek > > Date: Fri, 9 Jan 2015 17:20:38 +0100 > > Subject: [PATCH] Add quirk for Cavium AHCI BAR location > > > > --- > > sys/dev/ahci/ahci_pci.c | 9 +++------ > > 1 file changed, 3 insertions(+), 6 deletions(-) > > > > diff --git a/sys/dev/ahci/ahci_pci.c b/sys/dev/ahci/ahci_pci.c > > index 43723a6..dce4acb 100644 > > --- a/sys/dev/ahci/ahci_pci.c > > +++ b/sys/dev/ahci/ahci_pci.c > > @@ -373,7 +373,6 @@ ahci_pci_attach(device_t dev) > > int error, i; > > uint32_t devid = pci_get_devid(dev); > > uint8_t revid = pci_get_revid(dev); > > - struct pci_map *map; > > > > i = 0; > > while (ahci_ids[i].id != 0 && > > @@ -392,11 +391,9 @@ ahci_pci_attach(device_t dev) > > ctlr->subvendorid = pci_get_subvendor(dev); > > ctlr->subdeviceid = pci_get_subdevice(dev); > > > > - /* AHCI Base Address is BAR(5) by default, unless BARs are 64-bit > */ > > - map = pci_find_bar(dev, PCIR_BAR(4)); > > - if (map != NULL && > > - ((map->pm_value & PCIM_BAR_MEM_TYPE) == PCIM_BAR_MEM_64)) > > - ctlr->r_rid = PCIR_BAR(4); > > + /* Default AHCI Base Address is BAR(5), Cavium uses BAR(0) */ > > + if (ctlr->vendorid == 0x177d && ctlr->deviceid == 0xa01c) > > + ctlr->r_rid = PCIR_BAR(0); > > else > > ctlr->r_rid = PCIR_BAR(5); > > if (!(ctlr->r_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, > > -- > > 2.2.1 > > > > --001a1133fa76c74e71050c76e541 Content-Type: text/x-patch; charset=US-ASCII; name="0001-Add-quirk-for-Cavium-AHCI-BAR-location.patch" Content-Disposition: attachment; filename="0001-Add-quirk-for-Cavium-AHCI-BAR-location.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_i4u1x6su0 RnJvbSA1MDA2ZTNkZmY0MzQ2ZTRhNDliNGVkYmJlMzk4Nzk5Yjk0ZGE2NTZmIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBNaWNoYWwgU3RhbmVrIDxtc3RAc2VtaWhhbGYuY29tPgpEYXRl OiBXZWQsIDcgSmFuIDIwMTUgMTg6Mjg6MTggKzAxMDAKU3ViamVjdDogW1BBVENIXSBBZGQgcXVp cmsgZm9yIENhdml1bSBBSENJIEJBUiBsb2NhdGlvbgoKUXVpcmsgYWRkZWQgdG8gb3ZlcnJpZGUg ZGVmYXVsdCBCQVIoNSkgcmlkIGZvciBBSENJLgotLS0KIHN5cy9kZXYvYWhjaS9haGNpLmggICAg IHwgMSArCiBzeXMvZGV2L2FoY2kvYWhjaV9wY2kuYyB8IDkgKysrKysrKy0tCiAyIGZpbGVzIGNo YW5nZWQsIDggaW5zZXJ0aW9ucygrKSwgMiBkZWxldGlvbnMoLSkKCmRpZmYgLS1naXQgYS9zeXMv ZGV2L2FoY2kvYWhjaS5oIGIvc3lzL2Rldi9haGNpL2FoY2kuaAppbmRleCA0NjJmMjA0Li5mZThm Yzk1IDEwMDY0NAotLS0gYS9zeXMvZGV2L2FoY2kvYWhjaS5oCisrKyBiL3N5cy9kZXYvYWhjaS9h aGNpLmgKQEAgLTU3Miw2ICs1NzIsNyBAQCBlbnVtIGFoY2lfZXJyX3R5cGUgewogI2RlZmluZSBB SENJX1FfQVRJX1BNUF9CVUcJMHgyMDAwC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BhbiBBSENJIHBhcnQgKi8KIAljdGxyLT52ZW5kb3JpZCA9 IHBjaV9nZXRfdmVuZG9yKGRldik7CiAJY3Rsci0+ZGV2aWNlaWQgPSBwY2lfZ2V0X2RldmljZShk ZXYpOwogCWN0bHItPnN1YnZlbmRvcmlkID0gcGNpX2dldF9zdWJ2ZW5kb3IoZGV2KTsKIAljdGxy LT5zdWJkZXZpY2VpZCA9IHBjaV9nZXRfc3ViZGV2aWNlKGRldik7Ci0JY3Rsci0+cl9yaWQgPSBQ Q0lSX0JBUig1KTsKKworCS8qIERlZmF1bHQgQUhDSSBCYXNlIEFkZHJlc3MgaXMgQkFSKDUpLCBD YXZpdW0gdXNlcyBCQVIoMCkgKi8KKwlpZiAoY3Rsci0+cXVpcmtzICYgQUhDSV9RX0FCQVIwKQor CQljdGxyLT5yX3JpZCA9IFBDSVJfQkFSKDApOworCWVsc2UKKwkJY3Rsci0+cl9yaWQgPSBQQ0lS X0JBUig1KTsKIAlpZiAoIShjdGxyLT5yX21lbSA9IGJ1c19hbGxvY19yZXNvdXJjZV9hbnkoZGV2 LCBTWVNfUkVTX01FTU9SWSwKIAkgICAgJmN0bHItPnJfcmlkLCBSRl9BQ1RJVkUpKSkKIAkJcmV0 dXJuIEVOWElPOwotLSAKMi4yLjEKCg== --001a1133fa76c74e71050c76e541-- From owner-freebsd-embedded@FreeBSD.ORG Mon Jan 12 19:57:28 2015 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 348C8984 for ; Mon, 12 Jan 2015 19:57:28 +0000 (UTC) Received: from mail-yk0-f173.google.com (mail-yk0-f173.google.com [209.85.160.173]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EF7AB342 for ; Mon, 12 Jan 2015 19:57:27 +0000 (UTC) Received: by mail-yk0-f173.google.com with SMTP id 19so10137581ykq.4 for ; Mon, 12 Jan 2015 11:57:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to:cc :content-type; bh=Q2my3OeSS+Usl39E0Q+pG8LrFeid9wQx2xkr8AdACIw=; b=I8mkPuP/Czt7b/KEu650hmn8YJdJY+8zg47EVY6/IvxCLaKe0dFdRzHenT/Bf2WOJR qxg1jGZ5EWwx1kZJX7YVPLgCX5B/OtW2e+n6rBVHTt1/PYdmzEssLp99K8cE61Em7kSk PYGincfGhpnOOmaQMXRVph3Jc/A7Ct+CUprJ9Camzd7qXZOL5mzVE9Ab9agvgr0Z9PGi UAdzVnq073lxrprMVf9HxUtXLFvGDkROnYcdQqYU5NFqHVvzarqueJMBGvpQoR/aFiFW iij/FCwMnIoOC21uQufam5Mw+1vPgh8ZFYt4CjWxHtI21kiw+XwP+2QaPZLY1qNGb7mi 3TpQ== X-Gm-Message-State: ALoCoQn7v7S2z55wTBdtcwX9zu6KofRFw03CTv/G8o6fVmUxzsZg/axVZD1U43bv8eofcLpupQBf MIME-Version: 1.0 X-Received: by 10.236.32.8 with SMTP id n8mr24206450yha.74.1421090905935; Mon, 12 Jan 2015 11:28:25 -0800 (PST) Received: by 10.170.35.20 with HTTP; Mon, 12 Jan 2015 11:28:25 -0800 (PST) Date: Mon, 12 Jan 2015 20:28:25 +0100 Message-ID: Subject: Patch to replace part of common bus code with one function. From: Zbigniew Bodek To: Nathan Whitehorn , Ian Lepore Content-Type: text/plain; charset=UTF-8 Cc: freebsd-current@freebsd.org, freebsd-embedded@freebsd.org X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Jan 2015 19:57:28 -0000 Hello all, I would like to share a patch that groups some portion of common bus code into one function that can be then reused. You can check it out in Phabricator https://reviews.freebsd.org/D1504 Feel free to test the patch and send your comments as well as remarks. Best regards zbb From owner-freebsd-embedded@FreeBSD.ORG Tue Jan 13 00:12:31 2015 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D9146CD5; Tue, 13 Jan 2015 00:12:31 +0000 (UTC) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6222F37D; Tue, 13 Jan 2015 00:12:31 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.9/8.14.9) with ESMTP id t0D0CQU8012251 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 13 Jan 2015 02:12:26 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.9.2 kib.kiev.ua t0D0CQU8012251 Received: (from kostik@localhost) by tom.home (8.14.9/8.14.9/Submit) id t0D0CQ6d012250; Tue, 13 Jan 2015 02:12:26 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 13 Jan 2015 02:12:26 +0200 From: Konstantin Belousov To: Micha?? Stanek Subject: Re: [PATCH] Add support for 64-bit AHCI BAR. Message-ID: <20150113001225.GG42409@kib.kiev.ua> References: <20150108203959.GR42409@kib.kiev.ua> <20150109172715.GU42409@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on tom.home Cc: freebsd-current@freebsd.org, freebsd-embedded@freebsd.org X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jan 2015 00:12:31 -0000 On Mon, Jan 12, 2015 at 05:21:24PM +0100, Micha?? Stanek wrote: > OK, I added AHCI_Q_ABAR0 as a new quirk and test the bit in > ahci_pci_attach. It works the same. New patch is in the attachment. > Committed as r277100. Thank you.