From nobody Fri Jan 21 02:27:08 2022 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 5CF831969253; Fri, 21 Jan 2022 02:27:16 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Jg3Db0SvCz4p8K; Fri, 21 Jan 2022 02:27:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642732032; 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=9e3zYs7qBY8Y8kH92BO6ktCFWefYMm+a74LaxaV3pq4=; b=ynJolrYUl5bCEVivM0rIZrWAqHHVCWSvk7LewiKFrMI/3zmGyulxogFLy9BUgqKgZqTDxX lAC0P7hRYYTBjnf7qgZNIWqB/feV20kChypOPDNiCiiVs8A4TTWBGCHVswclSqJd1xTnyH pn0dkl+p7rvVsqdIApLRdqZrT+TkwXpoknme9TmJk4l78xssLEyrva79nonmWe8TClkrSd gbIU8ErKJ++QjzyGzCp0zAz+J2JbZvr/JZaXTXSokTEyk1JV8oMhJzXukxFa6qnIXtXY4I vn0YU0WQYwE1wX8RPeIsD6nEQfrLtn3LfnSU9QDtwePeRm/gWyqS2+FvLvcmGg== 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 AD7B1138ED; Fri, 21 Jan 2022 02:27:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20L2R8xe001584; Fri, 21 Jan 2022 02:27:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20L2R8Hs001583; Fri, 21 Jan 2022 02:27:08 GMT (envelope-from git) Date: Fri, 21 Jan 2022 02:27:08 GMT Message-Id: <202201210227.20L2R8Hs001583@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: f102ae715949 - stable/13 - nvme_sim: Only report PCI related stats when we can 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f102ae715949b99e3b9ac296517005e440adf713 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642732032; 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=9e3zYs7qBY8Y8kH92BO6ktCFWefYMm+a74LaxaV3pq4=; b=hjxgKgWygqHIDmoo9j6AoXelwtIPaej3KaTBCGNQazAKFprotmPP/viWmOY4VAt6zSKHWI p/RW9KY0uz8dWQfl6UiyTcK0jRMeerzRQhhg9Wig5a/tLndp8qv0Ezv4SyxBniiPCD5RLA WyWhJ6oDYj0Rd71CLF/uf/2NV0CIRoslao13MdBWT0uHqmaIhgdPkWCf4uOIl6VyhoZtUn BSFlNZQTnUJm+3uGJF5AKAe8Uhlrs2zOawJGhsOADmmKicCImMb2JZfuUP2wt72ncNLTzd GmK05fPpYmI2zIXy6zjNOiuA4/72qvxH8/b5xYRgpY1rt1sgU5wMCKR6tGBwQg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642732032; a=rsa-sha256; cv=none; b=VXK/XWXOeznQnEsAkcFhIVDkuzwuFf4/r/9H5fp7IyGuFOjljDGXePULWN8l1NQIkUNt0h ulUTza1Kp78d+N9JQvqukTwn+N3hCQvmOm0CXwvau3MkbWeSI4H1mYE2j0n63fmONFg+8I nf0BAiFjt24NqXZH4ZWV5VeUDBSGZwgBGDQ9LDtvMJBfwby4gevS+MsbFw5zRpf6ELqTlD s4E1IpiBHOuJSL3kUHis1T85hDNTEBPibnBaPE3zBef9AYonYIzXuHvAFdHunTRddubNaw 6clM0syQSWYxrmWykJu4ghKd4KviBLQxGuk0cv4Yi5/33vagxTK6wjqKCIP9sQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=f102ae715949b99e3b9ac296517005e440adf713 commit f102ae715949b99e3b9ac296517005e440adf713 Author: Warner Losh AuthorDate: 2021-12-06 17:23:23 +0000 Commit: Alexander Motin CommitDate: 2022-01-21 02:07:31 +0000 nvme_sim: Only report PCI related stats when we can For AHCI attached devices, we report the location and identification information of the AHCI controller that we're attached to. We also don't reprot link speed in that case, since we can't get to the PCIe config space registers to find that out. Sponsored by: Netflix Reviewed by: mav Differential Revision: https://reviews.freebsd.org/D33287 (cherry picked from commit 8f07932272c4b34804bc575c4f8bffecd15cd4ef) --- sys/dev/nvme/nvme_sim.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/sys/dev/nvme/nvme_sim.c b/sys/dev/nvme/nvme_sim.c index 06e645ebdf90..9a191d3042be 100644 --- a/sys/dev/nvme/nvme_sim.c +++ b/sys/dev/nvme/nvme_sim.c @@ -172,6 +172,13 @@ nvme_sim_action(struct cam_sim *sim, union ccb *ccb) struct ccb_pathinq *cpi = &ccb->cpi; device_t dev = ctrlr->dev; + /* + * For devices that are reported as children of the AHCI + * controller, which has no access to the config space for this + * controller, report the AHCI controller's data. + */ + if (ctrlr->quirks & QUIRK_AHCI) + dev = device_get_parent(dev); cpi->version_num = 1; cpi->hba_inquiry = 0; cpi->target_sprt = 0; @@ -219,17 +226,20 @@ nvme_sim_action(struct cam_sim *sim, union ccb *ccb) nvmex = &cts->xport_specific.nvme; nvmep = &cts->proto_specific.nvme; - status = pcie_read_config(dev, PCIER_LINK_STA, 2); - caps = pcie_read_config(dev, PCIER_LINK_CAP, 2); - flags = pcie_read_config(dev, PCIER_FLAGS, 2); nvmex->spec = nvme_mmio_read_4(ctrlr, vs); nvmex->valid = CTS_NVME_VALID_SPEC; - if ((flags & PCIEM_FLAGS_TYPE) == PCIEM_TYPE_ENDPOINT) { - nvmex->valid |= CTS_NVME_VALID_LINK; - nvmex->speed = status & PCIEM_LINK_STA_SPEED; - nvmex->lanes = (status & PCIEM_LINK_STA_WIDTH) >> 4; - nvmex->max_speed = caps & PCIEM_LINK_CAP_MAX_SPEED; - nvmex->max_lanes = (caps & PCIEM_LINK_CAP_MAX_WIDTH) >> 4; + if ((ctrlr->quirks & QUIRK_AHCI) == 0) { + /* AHCI redirect makes it impossible to query */ + status = pcie_read_config(dev, PCIER_LINK_STA, 2); + caps = pcie_read_config(dev, PCIER_LINK_CAP, 2); + flags = pcie_read_config(dev, PCIER_FLAGS, 2); + if ((flags & PCIEM_FLAGS_TYPE) == PCIEM_TYPE_ENDPOINT) { + nvmex->valid |= CTS_NVME_VALID_LINK; + nvmex->speed = status & PCIEM_LINK_STA_SPEED; + nvmex->lanes = (status & PCIEM_LINK_STA_WIDTH) >> 4; + nvmex->max_speed = caps & PCIEM_LINK_CAP_MAX_SPEED; + nvmex->max_lanes = (caps & PCIEM_LINK_CAP_MAX_WIDTH) >> 4; + } } /* XXX these should be something else maybe ? */