From patchwork Mon Oct 23 09:14:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 737764 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3152CDB474 for ; Mon, 23 Oct 2023 09:15:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232773AbjJWJPW (ORCPT ); Mon, 23 Oct 2023 05:15:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229689AbjJWJPQ (ORCPT ); Mon, 23 Oct 2023 05:15:16 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E70A3E5 for ; Mon, 23 Oct 2023 02:15:12 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 364F021AC6; Mon, 23 Oct 2023 09:15:11 +0000 (UTC) Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id C3AA32CF4E; Mon, 23 Oct 2023 09:15:10 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id F144551EC325; Mon, 23 Oct 2023 11:15:10 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 03/16] aha152x: look for stuck command when resetting device Date: Mon, 23 Oct 2023 11:14:54 +0200 Message-Id: <20231023091507.120828-4-hare@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20231023091507.120828-1-hare@suse.de> References: <20231023091507.120828-1-hare@suse.de> MIME-Version: 1.0 X-Spamd-Bar: ++++ Authentication-Results: smtp-out1.suse.de; dkim=none; dmarc=none; spf=softfail (smtp-out1.suse.de: 149.44.160.134 is neither permitted nor denied by domain of hare@suse.de) smtp.mailfrom=hare@suse.de X-Rspamd-Server: rspamd2 X-Spamd-Result: default: False [4.18 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; NEURAL_HAM_LONG(-3.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.20)[suse.de]; BROKEN_CONTENT_TYPE(1.50)[]; R_SPF_SOFTFAIL(0.60)[~all:c]; RCPT_COUNT_FIVE(0.00)[5]; TO_MATCH_ENVRCPT_SOME(0.00)[]; VIOLATED_DIRECT_SPF(3.50)[]; MX_GOOD(-0.01)[]; NEURAL_HAM_SHORT(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; RWL_MAILSPIKE_GOOD(0.00)[149.44.160.134:from]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.20)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; BAYES_HAM(-1.31)[90.16%] X-Rspamd-Queue-Id: 364F021AC6 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The LLDD needs a command to send the reset with, so look at the list of outstanding commands to get one. Signed-off-by: Hannes Reinecke Reviewed-by: Christoph Hellwig --- drivers/scsi/aha152x.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c index 055adb349b0e..936c9f5c6f23 100644 --- a/drivers/scsi/aha152x.c +++ b/drivers/scsi/aha152x.c @@ -1070,24 +1070,28 @@ static int aha152x_abort(struct scsi_cmnd *SCpnt) */ static int aha152x_device_reset(struct scsi_cmnd * SCpnt) { - struct Scsi_Host *shpnt = SCpnt->device->host; + struct scsi_device *sdev = SCpnt->device; + struct Scsi_Host *shpnt = sdev->host; DECLARE_COMPLETION(done); int ret, issued, disconnected; - unsigned char old_cmd_len = SCpnt->cmd_len; + unsigned char old_cmd_len; unsigned long flags; unsigned long timeleft; - if(CURRENT_SC==SCpnt) { - scmd_printk(KERN_ERR, SCpnt, "cannot reset current device\n"); - return FAILED; - } - DO_LOCK(flags); - issued = remove_SC(&ISSUE_SC, SCpnt) == NULL; - disconnected = issued && remove_SC(&DISCONNECTED_SC, SCpnt); + /* Look for the stuck command */ + SCpnt = remove_lun_SC(&ISSUE_SC, sdev->id, sdev->lun); + if (SCpnt) + issued = 1; + else + SCpnt = remove_lun_SC(&DISCONNECTED_SC, sdev->id, sdev->lun); + if (!issued && SCpnt) + disconnected = 1; DO_UNLOCK(flags); - - SCpnt->cmd_len = 0; + if (!SCpnt) + return FAILED; + old_cmd_len = SCpnt->cmd_len; + SCpnt->cmd_len = 0; aha152x_internal_queue(SCpnt, &done, resetting);