From nobody Mon Oct 6 17:57:02 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4cgRmZ4Rqtz6BGwr; Mon, 06 Oct 2025 17:57:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cgRmZ3r9Cz40T6; Mon, 06 Oct 2025 17:57:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1759773422; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=O+Uc9FpGz6Cygi4vUsINBp8Nc9TqWvwZ+lGBtc85BxU=; b=GwucuDM3x3GLrOKNLfSrqHeGd2dZt0YzIwhfz4uIGtSOffQZ3fND9WruXuJ/Pt887h1X5v ewvyiEjkUmdg3U8eCoXH3DKFJ5SgOr10BAkqfKwwJ7GxctkOIYywGwno528pGrofL0gJAp hxLmSrich9nAFgOC/qdUaLEiyy3KiIop5i6IAnmBoPtPRPMswPLNv9/+1xFrQFb3sXfBO0 sSwvHtyRhwVJoODCTVn5l61zvcT4sB/gUODljqu3cP0UngzvS7fexXowvuGFyJ3MHs+1Ek VRdbgnilGIf3H+ZVCw/yHoGclCpaMfDkVMpv9+qum+Zl70Jr3ACeMffFyAPOag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1759773422; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=O+Uc9FpGz6Cygi4vUsINBp8Nc9TqWvwZ+lGBtc85BxU=; b=qo8h37p90XTxF8TnMhpNGuJHMA+Vt6gsWwLNIIBq7V1hQfry7tHFoTVKr3knBs/DvYYqsm n1fWTCwq20mN84umh2Fqb84tWgHp37W36Gs2Cz8iC0LJ0jVcRMXLObKaFrBNIGDydSTG3P zoXp13+J95QXQTFCUa2SzIY+q3/JRivVv0KXMnCrVnW48P0cJnSr077DvpFoYdob1pzNxT A5VUsEOsOuO9Xuxs36aZ0QV2yotXGcvPo8bqokjjJB40PaEGQ/n8SHK3hhOLiaD/0w0ong F2oLQKkTxtb0LBSlyKJM/ktYDor9wRxmqWZ0FWgHgCNRcaBP6yYy3CKzLdFWGQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1759773422; a=rsa-sha256; cv=none; b=xgfJn5wSdD1k+HcSoLpI8eY7T0sD1RImENFo4eo2S2zKzAbj4lmK+1wIrTr+fdgOU4oE9x WXFuEb0yHAWeA585Kg5F+S5L64BHL0dyLYBRMCuXKV2yinv28IC0kZJ2zqO2c7LRly4X3r WAEF6avfEGcRHDT/FaTSfEbYzYkwrjdFsquIDoRk6ra/QFX9K705oORk+6aF0E+GSW2RS8 bPQu5SFedxm1B4Aces6acA4Ko2zKU7L1rn6lmXmmvLKtvu1IVjjFVwcyYLSXFXzX0BZir6 Xhkj0EtgJyCqVFnYOCgIIUGGVXQNmF1S5wz9ML/whw9pQnwYq62V8a2cvdzQVg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4cgRmZ3Q91z17Nh; Mon, 06 Oct 2025 17:57:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 596Hv2HC029009; Mon, 6 Oct 2025 17:57:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 596Hv23l029006; Mon, 6 Oct 2025 17:57:02 GMT (envelope-from git) Date: Mon, 6 Oct 2025 17:57:02 GMT Message-Id: <202510061757.596Hv23l029006@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 762f1c7c6cde - main - ahci: Use pci_msix_*_bar instead of reading config registers directly List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 762f1c7c6cded9242956c2c35c772dff9b5d155b Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=762f1c7c6cded9242956c2c35c772dff9b5d155b commit 762f1c7c6cded9242956c2c35c772dff9b5d155b Author: John Baldwin AuthorDate: 2025-10-06 17:56:47 +0000 Commit: John Baldwin CommitDate: 2025-10-06 17:56:47 +0000 ahci: Use pci_msix_*_bar instead of reading config registers directly Reported by: avg Reviewed by: avg, imp Differential Revision: https://reviews.freebsd.org/D52888 --- sys/dev/ahci/ahci_pci.c | 38 +++----------------------------------- 1 file changed, 3 insertions(+), 35 deletions(-) diff --git a/sys/dev/ahci/ahci_pci.c b/sys/dev/ahci/ahci_pci.c index 82f56fc0d19e..80547d178cd6 100644 --- a/sys/dev/ahci/ahci_pci.c +++ b/sys/dev/ahci/ahci_pci.c @@ -466,28 +466,6 @@ ahci_ata_probe(device_t dev) return (BUS_PROBE_DEFAULT); } -static int -ahci_pci_read_msix_bars(device_t dev, uint8_t *table_bar, uint8_t *pba_bar) -{ - int cap_offset = 0, ret; - uint32_t val; - - if ((table_bar == NULL) || (pba_bar == NULL)) - return (EINVAL); - - ret = pci_find_cap(dev, PCIY_MSIX, &cap_offset); - if (ret != 0) - return (EINVAL); - - val = pci_read_config(dev, cap_offset + PCIR_MSIX_TABLE, 4); - *table_bar = PCIR_BAR(val & PCIM_MSIX_BIR_MASK); - - val = pci_read_config(dev, cap_offset + PCIR_MSIX_PBA, 4); - *pba_bar = PCIR_BAR(val & PCIM_MSIX_BIR_MASK); - - return (0); -} - static int ahci_pci_attach(device_t dev) { @@ -496,7 +474,6 @@ ahci_pci_attach(device_t dev) uint32_t devid = pci_get_devid(dev); uint8_t revid = pci_get_revid(dev); int msi_count, msix_count; - uint8_t table_bar = 0, pba_bar = 0; uint32_t caps, pi; msi_count = pci_msi_count(dev); @@ -584,20 +561,11 @@ ahci_pci_attach(device_t dev) if (ctlr->quirks & AHCI_Q_NOMSIX) msix_count = 0; - /* Read MSI-x BAR IDs if supported */ - if (msix_count > 0) { - error = ahci_pci_read_msix_bars(dev, &table_bar, &pba_bar); - if (error == 0) { - ctlr->r_msix_tab_rid = table_bar; - ctlr->r_msix_pba_rid = pba_bar; - } else { - /* Failed to read BARs, disable MSI-x */ - msix_count = 0; - } - } - /* Allocate resources for MSI-x table and PBA */ if (msix_count > 0) { + ctlr->r_msix_tab_rid = pci_msix_table_bar(dev); + ctlr->r_msix_pba_rid = pci_msix_pba_bar(dev); + /* * Allocate new MSI-x table only if not * allocated before.