From patchwork Thu Feb 4 21:25:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 579129 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 676711402ED; Fri, 5 Feb 2016 08:26:56 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical-com.20150623.gappssmtp.com header.i=@canonical-com.20150623.gappssmtp.com header.b=cEfD0A+S; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1aRRQS-0000Lm-NF; Thu, 04 Feb 2016 21:26:52 +0000 Received: from mail-pf0-f171.google.com ([209.85.192.171]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.76) (envelope-from ) id 1aRRPk-0008Vg-5l for kernel-team@lists.ubuntu.com; Thu, 04 Feb 2016 21:26:08 +0000 Received: by mail-pf0-f171.google.com with SMTP id w123so56401633pfb.0 for ; Thu, 04 Feb 2016 13:26:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=SojzQTFGtcRqS4YOf45v4fX6WJcEK+8FC6yatt6T++E=; b=cEfD0A+SsbL5BhQULEVTqNaOl3RH5GmsQzWcMCE8Biy0LKotPXTlrqT5uaYqb2gZCz dLQgq6mBb+tpM+S2p0YkhbeY9UI0cxEJXY3iDtMLSbPyonxrJ3k/TyPhFs+YQX/Ediac WW4Jbw1uUwr0iEj5jhQx64dZIHwM2tMd2mAm1feCIWArXiEieMQ4MsewLxJLgG6CCVGV iTM1iRUQYTel9tsWRK4uiATuGOkb7oJQkwt75XjuuMZT7LM0Q5W9flIka/Rvnx5yCxfM i6vFLZ/uiNs77jqt4tsADmQeCOQ40oSSQ6q69RzNZCZ4razk8ISoIxNSt4pF23lAmAOk 2hBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=SojzQTFGtcRqS4YOf45v4fX6WJcEK+8FC6yatt6T++E=; b=aRcF9dLQpgm+FJo4Fn2Mdc7HhCUhMNwfJT0fjE+3i94RHRI24y8oIfTK3XoaZz65e1 FnH+mB83N2t5fUD8yQ7DMWm1Y2IzOXsI7yJSlGruWw4c+oH12YJsi5Qj6fvNuizAhczM N0zXtbvjrSdnIUUIVN67fEdoUvCQlYu6a7HjV9ukYNGdZG7tY1z2TUpEfmw4EgdKKYeB dd59Tm+7Dk+MutElas+VlL0CI550k5iqRZCMa8GZPdYiwOBT4LhcYhca1m2FyxZUN/G4 47kY7o8y8aKl7iWirxKxGAkJuJ7Or/RfQ9hM+dMWrp7BO/wMTa1oENAcDqdRz6wEdX7j Ssig== X-Gm-Message-State: AG10YOTSCTyWCkC3Qnp4/3CZ9iqIRSfC8BttqyTAwFUjOu4aQ8MJnJwtwhB7YubxAOzQTW99 X-Received: by 10.98.42.74 with SMTP id q71mr14249610pfq.18.1454621166860; Thu, 04 Feb 2016 13:26:06 -0800 (PST) Received: from localhost.localdomain (host-98-127-250-84.bln-mt.client.bresnan.net. [98.127.250.84]) by smtp.gmail.com with ESMTPSA id z7sm19316632pfi.19.2016.02.04.13.26.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Feb 2016 13:26:05 -0800 (PST) From: tim.gardner@canonical.com To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/9] cxlflash: Fix to resolve cmd leak after host reset Date: Thu, 4 Feb 2016 14:25:48 -0700 Message-Id: <1454621155-11635-3-git-send-email-tim.gardner@canonical.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1454621155-11635-1-git-send-email-tim.gardner@canonical.com> References: <1454621155-11635-1-git-send-email-tim.gardner@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: Manoj Kumar BugLink: http://bugs.launchpad.net/bugs/1541635 After a few iterations of resetting the card, either during EEH recovery, or a host_reset the following is seen in the logs. cxlflash 0008:00: cxlflash_queuecommand: could not get a free command At every reset of the card, the commands that are outstanding are being leaked. No effort is being made to reap these commands. A few more resets later, the above error message floods the logs and the card is rendered totally unusable as no free commands are available. Iterated through the 'cmd' queue and printed out the 'free' counter and found that on each reset certain commands were in-use and stayed in-use through subsequent resets. To resolve this issue, when the card is reset, reap all the commands that are active/outstanding. Signed-off-by: Manoj N. Kumar Acked-by: Matthew R. Ochs Reviewed-by: Andrew Donnellan Signed-off-by: Martin K. Petersen (cherry picked from commit ee91e332a6e6e9b939f60f6e1bd72fb2def5290d) Signed-off-by: Tim Gardner --- drivers/scsi/cxlflash/main.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index f7f851f..021b526 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -649,15 +649,30 @@ static void free_mem(struct cxlflash_cfg *cfg) * @cfg: Internal structure associated with the host. * * Safe to call with AFU in a partially allocated/initialized state. + * + * Cleans up all state associated with the command queue, and unmaps + * the MMIO space. + * + * - complete() will take care of commands we initiated (they'll be checked + * in as part of the cleanup that occurs after the completion) + * + * - cmd_checkin() will take care of entries that we did not initiate and that + * have not (and will not) complete because they are sitting on a [now stale] + * hardware queue */ static void stop_afu(struct cxlflash_cfg *cfg) { int i; struct afu *afu = cfg->afu; + struct afu_cmd *cmd; if (likely(afu)) { - for (i = 0; i < CXLFLASH_NUM_CMDS; i++) - complete(&afu->cmd[i].cevent); + for (i = 0; i < CXLFLASH_NUM_CMDS; i++) { + cmd = &afu->cmd[i]; + complete(&cmd->cevent); + if (!atomic_read(&cmd->free)) + cmd_checkin(cmd); + } if (likely(afu->afu_map)) { cxl_psa_unmap((void __iomem *)afu->afu_map);