Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 Jan 2015 17:09:23 +0100
From:      =?UTF-8?Q?Micha=C5=82_Stanek?= <mst@semihalf.com>
To:        freebsd-current@freebsd.org
Cc:        freebsd-embedded@freebsd.org
Subject:   [PATCH] Add support for 64-bit AHCI BAR.
Message-ID:  <CAMiGqYhKn49LrdFGS4DeGSHDOuVO1Ab0mwubyqGXzxFLmNGoEQ@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
--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
MDA6MDA6MDAgMjAwMQpGcm9tOiBNaWNoYWwgU3RhbmVrIDxtc3RAc2VtaWhhbGYuY29tPgpEYXRl
OiBXZWQsIDcgSmFuIDIwMTUgMTg6Mjg6MTggKzAxMDAKU3ViamVjdDogW1BBVENIXSBBZGQgc3Vw
cG9ydCBmb3IgNjQtYml0IEFIQ0kgQkFSLgoKLS0tCiBzeXMvZGV2L2FoY2kvY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