All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Ajish Koshy <Ajish.Koshy@microchip.com>,
	Jack Wang <jinpu.wang@ionos.com>,
	Viswas G <Viswas.G@microchip.com>,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	Sasha Levin <sashal@kernel.org>,
	jinpu.wang@cloud.ionos.com, jejb@linux.ibm.com,
	linux-scsi@vger.kernel.org
Subject: [PATCH AUTOSEL 5.15 20/36] scsi: pm80xx: Fix double completion for SATA devices
Date: Wed,  9 Feb 2022 13:37:43 -0500	[thread overview]
Message-ID: <20220209183759.47134-20-sashal@kernel.org> (raw)
In-Reply-To: <20220209183759.47134-1-sashal@kernel.org>

From: Ajish Koshy <Ajish.Koshy@microchip.com>

[ Upstream commit c26b85ea16365079be8d206b20556a60a0c69ad4 ]

Current code handles completions for SATA devices in mpi_sata_completion()
and mpi_sata_event().

However, at the time when any SATA event happens, for almost all the event
types, the command is still in the target. It is therefore incorrect to
complete the task in sata_event().

There are some events for which we get sata_completions, some need recovery
procedure and others abort. All the tasks must be completed via
sata_completion() path.

Removed the task done related code from sata_events().  For tasks where we
don't get completions, let top layer call abort() to abort the command post
timeout.

Link: https://lore.kernel.org/r/20220124082255.86223-1-Ajish.Koshy@microchip.com
Acked-by: Jack Wang <jinpu.wang@ionos.com>
Co-developed-by: Viswas G <Viswas.G@microchip.com>
Signed-off-by: Viswas G <Viswas.G@microchip.com>
Signed-off-by: Ajish Koshy <Ajish.Koshy@microchip.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/scsi/pm8001/pm8001_hwi.c | 18 ------------------
 drivers/scsi/pm8001/pm80xx_hwi.c | 26 --------------------------
 2 files changed, 44 deletions(-)

diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c
index 880e1f356defc..5e6b23da4157c 100644
--- a/drivers/scsi/pm8001/pm8001_hwi.c
+++ b/drivers/scsi/pm8001/pm8001_hwi.c
@@ -2695,7 +2695,6 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha, void *piomb)
 	u32 tag = le32_to_cpu(psataPayload->tag);
 	u32 port_id = le32_to_cpu(psataPayload->port_id);
 	u32 dev_id = le32_to_cpu(psataPayload->device_id);
-	unsigned long flags;
 
 	ccb = &pm8001_ha->ccb_info[tag];
 
@@ -2735,8 +2734,6 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha, void *piomb)
 		ts->resp = SAS_TASK_COMPLETE;
 		ts->stat = SAS_DATA_OVERRUN;
 		ts->residual = 0;
-		if (pm8001_dev)
-			atomic_dec(&pm8001_dev->running_req);
 		break;
 	case IO_XFER_ERROR_BREAK:
 		pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_BREAK\n");
@@ -2778,7 +2775,6 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha, void *piomb)
 				IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS);
 			ts->resp = SAS_TASK_COMPLETE;
 			ts->stat = SAS_QUEUE_FULL;
-			pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag);
 			return;
 		}
 		break;
@@ -2864,20 +2860,6 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha, void *piomb)
 		ts->stat = SAS_OPEN_TO;
 		break;
 	}
-	spin_lock_irqsave(&t->task_state_lock, flags);
-	t->task_state_flags &= ~SAS_TASK_STATE_PENDING;
-	t->task_state_flags &= ~SAS_TASK_AT_INITIATOR;
-	t->task_state_flags |= SAS_TASK_STATE_DONE;
-	if (unlikely((t->task_state_flags & SAS_TASK_STATE_ABORTED))) {
-		spin_unlock_irqrestore(&t->task_state_lock, flags);
-		pm8001_dbg(pm8001_ha, FAIL,
-			   "task 0x%p done with io_status 0x%x resp 0x%x stat 0x%x but aborted by upper layer!\n",
-			   t, event, ts->resp, ts->stat);
-		pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
-	} else {
-		spin_unlock_irqrestore(&t->task_state_lock, flags);
-		pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag);
-	}
 }
 
 /*See the comments for mpi_ssp_completion */
diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c
index ed02e1aaf868c..733781018c0ba 100644
--- a/drivers/scsi/pm8001/pm80xx_hwi.c
+++ b/drivers/scsi/pm8001/pm80xx_hwi.c
@@ -2828,7 +2828,6 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha,
 	u32 tag = le32_to_cpu(psataPayload->tag);
 	u32 port_id = le32_to_cpu(psataPayload->port_id);
 	u32 dev_id = le32_to_cpu(psataPayload->device_id);
-	unsigned long flags;
 
 	ccb = &pm8001_ha->ccb_info[tag];
 
@@ -2866,8 +2865,6 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha,
 		ts->resp = SAS_TASK_COMPLETE;
 		ts->stat = SAS_DATA_OVERRUN;
 		ts->residual = 0;
-		if (pm8001_dev)
-			atomic_dec(&pm8001_dev->running_req);
 		break;
 	case IO_XFER_ERROR_BREAK:
 		pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_BREAK\n");
@@ -2916,11 +2913,6 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha,
 				IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS);
 			ts->resp = SAS_TASK_COMPLETE;
 			ts->stat = SAS_QUEUE_FULL;
-			spin_unlock_irqrestore(&circularQ->oq_lock,
-					circularQ->lock_flags);
-			pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag);
-			spin_lock_irqsave(&circularQ->oq_lock,
-					circularQ->lock_flags);
 			return;
 		}
 		break;
@@ -3020,24 +3012,6 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha,
 		ts->stat = SAS_OPEN_TO;
 		break;
 	}
-	spin_lock_irqsave(&t->task_state_lock, flags);
-	t->task_state_flags &= ~SAS_TASK_STATE_PENDING;
-	t->task_state_flags &= ~SAS_TASK_AT_INITIATOR;
-	t->task_state_flags |= SAS_TASK_STATE_DONE;
-	if (unlikely((t->task_state_flags & SAS_TASK_STATE_ABORTED))) {
-		spin_unlock_irqrestore(&t->task_state_lock, flags);
-		pm8001_dbg(pm8001_ha, FAIL,
-			   "task 0x%p done with io_status 0x%x resp 0x%x stat 0x%x but aborted by upper layer!\n",
-			   t, event, ts->resp, ts->stat);
-		pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
-	} else {
-		spin_unlock_irqrestore(&t->task_state_lock, flags);
-		spin_unlock_irqrestore(&circularQ->oq_lock,
-				circularQ->lock_flags);
-		pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag);
-		spin_lock_irqsave(&circularQ->oq_lock,
-				circularQ->lock_flags);
-	}
 }
 
 /*See the comments for mpi_ssp_completion */
-- 
2.34.1


  parent reply	other threads:[~2022-02-09 18:40 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-09 18:37 [PATCH AUTOSEL 5.15 01/36] platform/x86: touchscreen_dmi: Add info for the RWC NANOTE P8 AY07J 2-in-1 Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 02/36] platform/x86: ISST: Fix possible circular locking dependency detected Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 03/36] kunit: tool: Import missing importlib.abc Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 04/36] selftests: rtc: Increase test timeout so that all tests run Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 05/36] kselftest: signal all child processes Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 06/36] selftests: netfilter: check stateless nat udp checksum fixup Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 07/36] net: ieee802154: at86rf230: Stop leaking skb's Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 08/36] selftests/zram: Skip max_comp_streams interface on newer kernel Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 09/36] selftests/zram01.sh: Fix compression ratio calculation Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 10/36] selftests/zram: Adapt the situation that /dev/zram0 is being used Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 11/36] selftests: openat2: Print also errno in failure messages Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 12/36] selftests: openat2: Add missing dependency in Makefile Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 13/36] selftests: openat2: Skip testcases that fail with EOPNOTSUPP Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 14/36] selftests: skip mincore.check_file_mmap when fs lacks needed support Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 15/36] ax25: improve the incomplete fix to avoid UAF and NPD bugs Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 16/36] pinctrl: bcm63xx: fix unmet dependency on REGMAP for GPIO_REGMAP Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 17/36] vfs: make freeze_super abort when sync_filesystem returns error Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 18/36] quota: make dquot_quota_sync return errors from ->sync_fs Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 19/36] iommu: Fix potential use-after-free during probe Sasha Levin
2022-02-09 18:37   ` Sasha Levin
2022-02-09 18:37 ` Sasha Levin [this message]
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 21/36] kselftest: Fix vdso_test_abi return status Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 22/36] scsi: core: Reallocate device's budget map on queue depth change Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 23/36] scsi: pm8001: Fix use-after-free for aborted TMF sas_task Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 24/36] scsi: pm8001: Fix use-after-free for aborted SSP/STP sas_task Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 25/36] drm/amd: Warn users about potential s0ix problems Sasha Levin
2022-02-09 18:37   ` Sasha Levin
2022-02-09 18:37   ` Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 26/36] nvme: fix a possible use-after-free in controller reset during load Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 27/36] nvme-tcp: fix possible use-after-free in transport error_recovery work Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 28/36] nvme-rdma: " Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 29/36] net: sparx5: do not refer to skb after passing it on Sasha Levin
2022-02-09 18:37   ` Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 30/36] drm/amd: add support to check whether the system is set to s3 Sasha Levin
2022-02-09 18:37   ` Sasha Levin
2022-02-09 18:37   ` Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 31/36] drm/amd: Only run s3 or s0ix if system is configured properly Sasha Levin
2022-02-09 18:37   ` Sasha Levin
2022-02-09 18:37   ` Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 32/36] drm/amdgpu: fix logic inversion in check Sasha Levin
2022-02-09 18:37   ` Sasha Levin
2022-02-09 18:37   ` Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 33/36] x86/Xen: streamline (and fix) PV CPU enumeration Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 34/36] Revert "module, async: async_synchronize_full() on module init iff async is used" Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 35/36] gcc-plugins/stackleak: Use noinstr in favor of notrace Sasha Levin
2022-02-09 18:37 ` [PATCH AUTOSEL 5.15 36/36] random: wake up /dev/random writers after zap Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220209183759.47134-20-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=Ajish.Koshy@microchip.com \
    --cc=Viswas.G@microchip.com \
    --cc=jejb@linux.ibm.com \
    --cc=jinpu.wang@cloud.ionos.com \
    --cc=jinpu.wang@ionos.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.