Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2836556pxb; Mon, 1 Nov 2021 02:53:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykF3jL4Jll256mpriD9z+6H1uG9g/he3QEiguIQhqmU4ih66BwlmhaCgu0el5cT4wLjk+B X-Received: by 2002:a05:6638:33a8:: with SMTP id h40mr19895509jav.4.1635760419528; Mon, 01 Nov 2021 02:53:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635760419; cv=none; d=google.com; s=arc-20160816; b=PNA0AVEMBDIbcV2hWnWOo4IbbQcTvgcuVYnW2L4wZSFsHoJN/vPVfOKfa3qpv35n/K H99kxgNcupmhLxt/opTcN4X1J6qNWPAUEfvWz3LcGoWlcXV2lpkVX1ebAPxC1BxMCQsO 0s0OUEb2DQPJdn+Zj+JZeIu5JVz+aJGHo7TVeYQFt0rYJ57CWy+U+EVZDCi/pzMy5rJs etp4opkTjPnaczHWNJuNEm1ddR10r0BSGEx+HTeS08sThx/04Kafg1+PujK/xNJDGqlL 59ZsF13F5AWsv3FE+/GI0em4fi+Ac73NO900NRp2g9RD6IG4O8vU9GpYQAkMEo49erQ3 B59Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=w0YWzOjfNz3XLCiL9qY05n31miNu0tvQvddKlkoqiP0=; b=F+MF1eLLuBAgFuV2cKBebhjAyJmHomHE+AZasknK2Ryq0jI3z4dqP7dqVg6kmpkZ/1 ZGdntvBZrD+EUrz8mBtV3tj3i99wMELVG8DGCu27qwIuLV7uY29zMpl1g7t5Y0LV6Ucn OjEjatUUHKR+95pY3oo3Maug3+boIzLgtuyEFktktZHgx64MDf2OJUx+w3LtGWjECuBV Cg8s1yRr4Oq6dpU2slUWUaXZrKiP6wmnMGM1jAlo8x1CAlpD86iwokddorIo8RqyVEPI S73MK6uh4lC8aOLYmD5q2n1vZ4vytfa8sAim6kdKN2njZeU7xL8Ew/g0ayIefL2h4eAO w/5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=K2TS+Fg1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a5si1283191jat.39.2021.11.01.02.53.28; Mon, 01 Nov 2021 02:53:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=K2TS+Fg1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235138AbhKAJxu (ORCPT + 99 others); Mon, 1 Nov 2021 05:53:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:51420 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234786AbhKAJtD (ORCPT ); Mon, 1 Nov 2021 05:49:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6B27C6124B; Mon, 1 Nov 2021 09:31:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1635759103; bh=Ofna1o3ie+n21vpiTSA3lx93tCycHR9DlDgQsRn5+OU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K2TS+Fg1oNHWAcx+IPvdJ7E3WlcKwEFBEZdp1e3Xzn8qj6jtkCTFtQ8vKu5EY9mXK 2J5oTeyMQOJBy4zyV3NTDl5XU4kVwfyOqm+FKIXlqWoRGX9YbyAXTyRYxeMA4Nqpph uzNs6GbT1TMC8UlF3UheX4eyfSiXMT8skTfVaUS0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tyrel Datwyler , Brian King , "Martin K. Petersen" Subject: [PATCH 5.14 117/125] scsi: ibmvfc: Fix up duplicate response detection Date: Mon, 1 Nov 2021 10:18:10 +0100 Message-Id: <20211101082555.193904371@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211101082533.618411490@linuxfoundation.org> References: <20211101082533.618411490@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Brian King commit e20f80b9b163dc402dca115eed0affba6df5ebb5 upstream. Commit a264cf5e81c7 ("scsi: ibmvfc: Fix command state accounting and stale response detection") introduced a regression in detecting duplicate responses. This was observed in test where a command was sent to the VIOS and completed before ibmvfc_send_event() set the active flag to 1, which resulted in the atomic_dec_if_positive() call in ibmvfc_handle_crq() thinking this was a duplicate response, which resulted in scsi_done() not getting called, so we then hit a SCSI command timeout for this command once the timeout expires. This simply ensures the active flag gets set prior to making the hcall to send the command to the VIOS, in order to close this window. Link: https://lore.kernel.org/r/20211019152129.16558-1-brking@linux.vnet.ibm.com Fixes: a264cf5e81c7 ("scsi: ibmvfc: Fix command state accounting and stale response detection") Cc: stable@vger.kernel.org Acked-by: Tyrel Datwyler Signed-off-by: Brian King Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/ibmvscsi/ibmvfc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/scsi/ibmvscsi/ibmvfc.c +++ b/drivers/scsi/ibmvscsi/ibmvfc.c @@ -1696,6 +1696,7 @@ static int ibmvfc_send_event(struct ibmv spin_lock_irqsave(&evt->queue->l_lock, flags); list_add_tail(&evt->queue_list, &evt->queue->sent); + atomic_set(&evt->active, 1); mb(); @@ -1710,6 +1711,7 @@ static int ibmvfc_send_event(struct ibmv be64_to_cpu(crq_as_u64[1])); if (rc) { + atomic_set(&evt->active, 0); list_del(&evt->queue_list); spin_unlock_irqrestore(&evt->queue->l_lock, flags); del_timer(&evt->timer); @@ -1737,7 +1739,6 @@ static int ibmvfc_send_event(struct ibmv evt->done(evt); } else { - atomic_set(&evt->active, 1); spin_unlock_irqrestore(&evt->queue->l_lock, flags); ibmvfc_trc_start(evt); }