Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1744416lqa; Mon, 29 Apr 2024 19:18:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUswf/q0G0MDUZ4ORXvs2HP5Cc2Da2MERw/K6SxNTeTVqTpoBDuMO/Xk9oB8vlZKTL+J+2HAQuphnwTS0egG8+RXMUI3nE0RZB5xixM2w== X-Google-Smtp-Source: AGHT+IFW4xdUWS6lh8RcaZZltWPVEgfFHiDK5fc6lksHhSsEpSt/xgTSsa6cbDdBVb+sZZknoWNY X-Received: by 2002:a05:6214:d08:b0:699:49d3:fe3a with SMTP id 8-20020a0562140d0800b0069949d3fe3amr13120415qvh.44.1714443482138; Mon, 29 Apr 2024 19:18:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714443482; cv=pass; d=google.com; s=arc-20160816; b=0IcC7AE0aX4JsV7Kf6XpF3Nswa+noHvJ0w42hpnKuz/BaLNH/20sSzzuW9IWatu9t8 rvk1CWCn+Qk+CUotiT87je6E5P3OrE1WipAM4BIv2HNemQz6eAmhL95H9nKqUTubLPdy C07ZY5oLxWLnWYbSSzN82wXtv0l+c3p72Qh9zh9wgAfN2NPQ4hL6LMakatcWKNxu+j1L W7Vj97aCP7UZ35afZZlh5IjngqObRyF02uSs/DcmF4NWUu+7Me3Ko/dNp9R6KlM/h5/W Uz4FmO3Dn/+QVn/X6+m7AlB8xBCxfGtVRcwm2gc/cK5J6o24dCwNXS3Up7G9iisI1Hst M/CQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=Cchrfa8eIXWEq/fb8YAhdNX//HQqlhIwVZ6NSv/uTAM=; fh=+MrrA5A6ynOJlIlckPDinAnrbwDx26hVAJ7JASgdd5U=; b=OB4A8Eb/c2b8dR4qtbqbmWAwT+gZtwM9+TPLX/EBymhviSnaiSs7fLW9O7WwkmAL4f mOLOpHQHLCDUgYG1mU3mOqTTxOdDpRHPbFD0hxXgx5+BrLupRwTrXoyVxTejA6uTJ3av UuVAa5Q/9tbzYKPdkFjCYM4rwRdfUKflX30D367rDahhKt3E3v4ztg4/gyEq2Ka30ErG epX1DaD1VzDJ2WY4966gE9twX0U2/Zav4iQsT67z3hWEdROx0Qv74UAKVrWwGhkJeavE V1RQS7PxGvY5tLO96bIzYpx4+lXGJy8ZDcBI+qjHC8w9+m3Q66MSqpgRfXgHVe7Gaese GtLQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=E2FmP045; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-163262-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163262-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id t2-20020a05621421a200b006a0a6b4aac7si10355539qvc.57.2024.04.29.19.18.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 19:18:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-163262-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=E2FmP045; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-163262-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163262-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C76621C22314 for ; Tue, 30 Apr 2024 02:18:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D5AE8F7A; Tue, 30 Apr 2024 02:17:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="E2FmP045" Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 06F4633D5 for ; Tue, 30 Apr 2024 02:17:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714443476; cv=none; b=JNUmeHRjZ9IMHYocIOTr2sFNJZ+7pDh8Hi09Gqrcpn3J7PRCWxZh7AsA8mPnjXFMNyzsPIQ4L0mE6901pbGL2VEu5o3seUPHpQki1CLMqFokjoHz9q7kKMRIYlDFpT192qsP6sMLOPlfm6mbhiFhD5sV186hEbhaPi3BzVzKsRk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714443476; c=relaxed/simple; bh=A+pXMQ7LewpVRbo5DMWA5iHpn7olR3kQXZjLcapHorY=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=D5JcjXpC0hC20eGCj3JWI2PBAbgnnIqtX6aUDxq/VfPdwBEglf6K88oDOh3PVG5fA6w4BqXqX24h03CLIqNvlZvus/TpjXQbt5FvqPxMlGJejVGbVJR5h6fKEUMqpn7iEZEATv2XH2YctX8s99L0Qpq6IqUb3+Y3MpmACVqdk1g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=E2FmP045; arc=none smtp.client-ip=209.85.215.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-5f415fd71f8so4128489a12.3 for ; Mon, 29 Apr 2024 19:17:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714443474; x=1715048274; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Cchrfa8eIXWEq/fb8YAhdNX//HQqlhIwVZ6NSv/uTAM=; b=E2FmP045xwzRDtEtmolF3CqlTtAMs166KJlMSQCc277ZcGUVgOlen6EXfa8oRFnoFz xna9FMqjAjt8dSMqb15VKt8rZSTtOaigjubVKhorZ30PkTDntBGtWDsIqEiPe+5WtVTO VCQEDL6g+f6HaMiUvBqrVYpyVIQSLwgROiAubTDa7SzgChYEkHuS3SruXczG0CZb+C/T DBcBw4hv3fenJ/pe1DS3IgLBV09+HUUOoAcBQmQLH4v7UIAjOlhyezzWIM9ym+bFhjPi P5FnvLtdQpJ7o0CSMTyH+V+W53xxooDjDGbNve+EADQJ7fqAeXU2OuzoscEXCNIrSl73 0Rmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714443474; x=1715048274; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Cchrfa8eIXWEq/fb8YAhdNX//HQqlhIwVZ6NSv/uTAM=; b=uvue6sBEqwuyzck07pmXlbnb614kx9eA+O4g796MSfg2optKow+8v+4IOr9wux5K6G EtGSE73SEfI/1xQzLrjyCEvqkUzMdmFuxJEDAb9+BAbbRKLBaG00ChW6VsGlRe/H5ZP4 egmi6CdpYSq5MoBHIvauUXo4+oYf3ArvN+JlCHTCk/RIAAU1edZGz13HaROMP5CvYEVT A79oy1g6TCBY7BnQPmYv6nY2h0DrJS+rxjrOxH8JuJSX2dbjm0rDiFxt0CFITg/jH46u uSEZ5zJsnyLALjhemhYBaCS5YeQXML2BOplQg6s5wwgCQcTguMayC2rvpYreh7+t3aAU 6Hdw== X-Forwarded-Encrypted: i=1; AJvYcCVXRaERLxHjh7evfKsu1P5ZFsC5HCg74NTXkaOm+kSH9oAxDK/Dlyxkcu5eCCzRnv+EUt6Naq7ZG51Mq9sDnEoofDyG58K1sVBWEFjx X-Gm-Message-State: AOJu0YxTCmeC/DUyGeJXBhIAROc2yIZl3hcsFQM2GUBWKdt7H+4Xx1rR 5NeWQQ7AbH7UVc+/zo+CcvFTuYBy1rBjWC/zawtq3Pej0713aydB X-Received: by 2002:a05:6a20:c70e:b0:1af:3857:e653 with SMTP id hi14-20020a056a20c70e00b001af3857e653mr8338836pzb.12.1714443474145; Mon, 29 Apr 2024 19:17:54 -0700 (PDT) Received: from localhost.localdomain ([143.92.64.17]) by smtp.gmail.com with ESMTPSA id k6-20020a170902694600b001e20afa1038sm21154619plt.8.2024.04.29.19.17.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 19:17:53 -0700 (PDT) From: "brookxu.cn" To: kbusch@kernel.org, axboe@kernel.dk, hch@lst.de, sagi@grimberg.me Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] nvme-fabrics: use reserved tag for reg read/write command Date: Tue, 30 Apr 2024 10:17:53 +0800 Message-Id: <20240430021753.385089-1-brookxu.cn@gmail.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Chunguang Xu In some scenarios, if too many commands are issued by nvme command in the same time by user tasks, this may exhaust all tags of admin_q. If a reset (nvme reset or IO timeout) occurs before these commands finish, reconnect routine may fail to update nvme regs due to insufficient tags, which will cause kernel hang forever. In order to workaround this issue, maybe we can let reg_read32()/reg_read64()/reg_write32() use reserved tags. This maybe safe for nvmf: 1. For the disable ctrl path, we will not issue connect command 2. For the enable ctrl / fw activate path, since connect and reg_xx() are called serially. So the reserved tags may still be enough while reg_xx() use reserved tags. Signed-off-by: Chunguang Xu --- drivers/nvme/host/fabrics.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c index 1f0ea1f32d22..f6416f8553f0 100644 --- a/drivers/nvme/host/fabrics.c +++ b/drivers/nvme/host/fabrics.c @@ -180,7 +180,7 @@ int nvmf_reg_read32(struct nvme_ctrl *ctrl, u32 off, u32 *val) cmd.prop_get.offset = cpu_to_le32(off); ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, &res, NULL, 0, - NVME_QID_ANY, 0); + NVME_QID_ANY, NVME_SUBMIT_RESERVED); if (ret >= 0) *val = le64_to_cpu(res.u64); @@ -226,7 +226,7 @@ int nvmf_reg_read64(struct nvme_ctrl *ctrl, u32 off, u64 *val) cmd.prop_get.offset = cpu_to_le32(off); ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, &res, NULL, 0, - NVME_QID_ANY, 0); + NVME_QID_ANY, NVME_SUBMIT_RESERVED); if (ret >= 0) *val = le64_to_cpu(res.u64); @@ -271,7 +271,7 @@ int nvmf_reg_write32(struct nvme_ctrl *ctrl, u32 off, u32 val) cmd.prop_set.value = cpu_to_le64(val); ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, NULL, NULL, 0, - NVME_QID_ANY, 0); + NVME_QID_ANY, NVME_SUBMIT_RESERVED); if (unlikely(ret)) dev_err(ctrl->device, "Property Set error: %d, offset %#x\n", -- 2.25.1