From nobody Fri Oct 10 21:05:05 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 4cjzlj3n1Yz6C092; Fri, 10 Oct 2025 21:05:05 +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 4cjzlj1ZXMz3Cw7; Fri, 10 Oct 2025 21:05:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1760130305; 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=N9AhQFZCG8azuYdifgQDZRN3uc7dFGvKgo2Q7npbQoo=; b=nb4pes0fes2RplJpkkoOLJ5EmKnDBEbnZRxQ0EdBLLLG+NlYWfRbP/chA139agKmzwrDNg UqCYg91bXV/uJJA+Glu89tm6mWkk7fG7M/mXmCV8Qeh/7+LpdlDuuQqTGp5xR+febzmFnr DDB+1NhnBfeytj8kDCDPXRfW6oVtadCpZe0sQSFDkBavV4KJeTjQKlDT5DEpOZC4GgVK4Y 46HNDz461ikFZl0U2DZJNKrALf0xvd+nR94ZX3/oEjhWHYpgN5hanA4caAs7/mrpKh2rPT IOscumLdfWDoZPBWIL0jLjo9AYyvwfVFRVTleKdIUcR/hlBgnWghEaKDvU3tbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1760130305; 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=N9AhQFZCG8azuYdifgQDZRN3uc7dFGvKgo2Q7npbQoo=; b=VZYVEjl2YRC0qDJfjyNIQp6VS9zKwiIpPruLMnxGRtRSGkzkcQps0IGfrNBwN4c+3H/wuX BSsh0zyta1xUCOyCrjLgshhfQRLq4Fizz8uc/P7eBbz3J2BxGgzJsEkKji+hMVNHoLbxRd yibbIPxkLh6UZiMfPXNTjBrvQ5gWvQtmRe2nkLGgwhdiRUBqgj18YnluoU2uBKfC0E4Pu8 FH+a1sGSSpxXhTL9gPOjQKi+ifRDWh2YZ1kI38qzRxV51NA86/J8QQ5YlCjGQXOagCqwXE PYHfg0fvrJQCbGvqA0Fj1qsbS0o5qF0i+tUoWdS8ANeHB8bCEYV6+QJLYtCI9w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1760130305; a=rsa-sha256; cv=none; b=P6jcXto9C9LAdrxXMIhZf9sUM6EPq2i49DPy81BZVr5N6iMnXlQ5hwnrD87W2CLySj0B9g OSbizqqf3bv2FODOb5HXnY9FfmIaHS4wTvCthtTq2uDFGpaP0V9AuCFT3/35OC7bsHvRnw aLcIvEso8fuxxGyT4fj8LDzhKR2ctWb/BqrpcCMg0TYvZDpLRXmOe37RDqMREKhWBu5Sfo +wrKL2rmP1ysV70Nd0l9v8i3hdiD+xvcl4hNBPbSGsPn5MQsV33rrx1IM5M1nbcGYHDPSw 61PxGUy8T/Uo76fV/eQ+VJRXhJTnRNaG/m71/nVWPoMCBZKBIh3LMXmhsEdS9w== 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 4cjzlj0rQgz1Jf2; Fri, 10 Oct 2025 21:05:05 +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 59AL55Fj043307; Fri, 10 Oct 2025 21:05:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 59AL55RW043304; Fri, 10 Oct 2025 21:05:05 GMT (envelope-from git) Date: Fri, 10 Oct 2025 21:05:05 GMT Message-Id: <202510102105.59AL55RW043304@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: ec598fa915ee - stable/15 - 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/stable/15 X-Git-Reftype: branch X-Git-Commit: ec598fa915ee61ca56f89d4db99ac001c4ccdf4d Auto-Submitted: auto-generated The branch stable/15 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=ec598fa915ee61ca56f89d4db99ac001c4ccdf4d commit ec598fa915ee61ca56f89d4db99ac001c4ccdf4d Author: John Baldwin AuthorDate: 2025-10-06 17:56:47 +0000 Commit: John Baldwin CommitDate: 2025-10-10 21:04:02 +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 (cherry picked from commit 762f1c7c6cded9242956c2c35c772dff9b5d155b) --- 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 f29d803e99a8..78de098efbb8 100644 --- a/sys/dev/ahci/ahci_pci.c +++ b/sys/dev/ahci/ahci_pci.c @@ -465,28 +465,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) { @@ -495,7 +473,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); @@ -583,20 +560,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.