From nobody Mon Dec 06 17:25:45 2021 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 86BB018C2317; Mon, 6 Dec 2021 17:25:46 +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 4J79Ld4qvrz3Q1l; Mon, 6 Dec 2021 17:25:45 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 43D377D31; Mon, 6 Dec 2021 17:25:45 +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 1B6HPjLb055679; Mon, 6 Dec 2021 17:25:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B6HPjTY055678; Mon, 6 Dec 2021 17:25:45 GMT (envelope-from git) Date: Mon, 6 Dec 2021 17:25:45 GMT Message-Id: <202112061725.1B6HPjTY055678@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 8f07932272c4 - main - 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: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8f07932272c4b34804bc575c4f8bffecd15cd4ef Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638811545; 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=VFZKxGJMymWYh8KzXoff2xDAkcwdPPc6oFkiyfl4JRI=; b=O8ZaQrYwUdyk32bQonw9uGW8o1yFVjRHGkwcWRKNpuBTRVXOctF3SYe5lVsoML4fEhiw+O X5ViOOFBO4qN+KXD16mpyRN2sLhKgE+yu4ppbOiZKmxk0spoN8vNtK2xL9GUlwNTrc7d5U oDxYOe8OTK7888vhkvmz5M+aCRfD7KPynZ+k9sMss27/DtmVbPM9Y2LN1h7A2NqSntgoPg pJ2S6IC/ctlyxfWmYgpTYSsGVxbmr189Ea1JJgrQHXTnNIcOUItZYf8SqEv+uU71mYGBP2 gEms8v7t63yxqqSR4J0QuzHFSw2TrIDlKKXz9ayNxbB5n28REU5+JW+dANpcBg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638811545; a=rsa-sha256; cv=none; b=wccEoD1VcfwMxFv7ia4FI+x7FW/yrMQcE72DiKrNTN/THew38aQbWbDc7u65yed0YtkwAP pjNCPEYpHZYXkP6x5oK3xd3JWoqk3vnEuzBZZcudK/+6d6H1JknRd0SCdYAd0uzN0pB1VG i+amK9wue3kf3ggflUcrf4dKl8bia+LHUJOpRDwXDlGcHu9d5Th5ZiN2acdBuJw/HisyNp m41sK6nopj7SADhoDFCWBJrALknyLK+WT8g9UaSJNrDHJ7hEWEcwnGiDLM33/FdQ0Y+XuE LOqxOfOBgw8zb1zG+t26oT+mdgYaN1FYpUB8vrF5Mct4+rx48hGzS8ytedjZsw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=8f07932272c4b34804bc575c4f8bffecd15cd4ef commit 8f07932272c4b34804bc575c4f8bffecd15cd4ef Author: Warner Losh AuthorDate: 2021-12-06 17:23:23 +0000 Commit: Warner Losh CommitDate: 2021-12-06 17:23:40 +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 --- 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 ? */