From owner-freebsd-current@FreeBSD.ORG Thu Jan 8 16:09:32 2015 Return-Path: Delivered-To: freebsd-current@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 8B784687 for ; Thu, 8 Jan 2015 16:09:32 +0000 (UTC) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com [209.85.215.46]) (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 1ECE6254 for ; Thu, 8 Jan 2015 16:09:32 +0000 (UTC) Received: by mail-la0-f46.google.com with SMTP id q1so10024833lam.5 for ; Thu, 08 Jan 2015 08:09:23 -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=lpBopkcDGRJdUc22by4jbqsea6mzmDyImPtdF1ZjkOY=; b=FOR/YKY98exDMtgUvFxjzoVsNISyJYpGlSG4LFV6Ny9j5OlgRDiV1luVPyRP83/isg ut++6r50k23O4W72XQii2EE+ZOSXDflKHZtHSUyHzn1LC05WRuXLeUu9asUwxKAvxkEt pPWmoWzXnM8s5Qu3cGYVXa9/rpXsFNV5idpyVR4XCW2KQyBUp+XShGySyxqfo5wvHbk3 +m9WfjI6C1lCAo7K9qUZg2WPkeF7bzDN9L3NFv9gf0Q5m4Ce900B+LzjVpogquf74R2Z FCYzfYFNwQn9sU4cMbTyuj8+moaoVp3s4ivE/fxIpGHxgNRxmkTk1NGsHsrupuVEC7Qf hxMw== X-Gm-Message-State: ALoCoQlRquL+Dh20ftVgF2REMj+mkCZ8TrOzawdFzFl3VjrrPXYUCyFX8kHtaz561B0GjihMugI/ MIME-Version: 1.0 X-Received: by 10.112.170.132 with SMTP id am4mr14666786lbc.74.1420733363671; Thu, 08 Jan 2015 08:09:23 -0800 (PST) Received: by 10.25.14.208 with HTTP; Thu, 8 Jan 2015 08:09:23 -0800 (PST) Date: Thu, 8 Jan 2015 17:09:23 +0100 Message-ID: Subject: [PATCH] Add support for 64-bit AHCI BAR. From: =?UTF-8?Q?Micha=C5=82_Stanek?= To: freebsd-current@freebsd.org Content-Type: multipart/mixed; boundary=001a11c37818767c02050c264381 X-Mailman-Approved-At: Thu, 08 Jan 2015 16:29:36 +0000 X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 Cc: freebsd-embedded@freebsd.org X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jan 2015 16:09:32 -0000 --001a11c37818767c02050c264381 Content-Type: text/plain; charset=UTF-8 Hello all, I ran into an issue with AHCI BAR allocation on arm64. The AHCI PCI driver in sys/dev/ahci/ahci_pci.c assumes that ABAR (AHCI Base Address) register is located at offset 0x24 (BAR5) in the PCI header. Specification for AHCI confirms this is indeed the default address of the main BAR. 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. 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. Thanks, Michal Stanek --001a11c37818767c02050c264381 Content-Type: text/x-patch; charset=US-ASCII; name="ahci_64bit_bar.patch" Content-Disposition: attachment; filename="ahci_64bit_bar.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_i4obv96a0 RnJvbSBjYWI2MGNkN2ZjNWE1MTdkZjRkOGM1NWRhNWU4NzI4OGM0MWE5ODVhIE1vbiBTZXAgMTcg MDA6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