From patchwork Mon Oct 23 09:14:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 737491 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 7A80AC001E0 for ; Mon, 23 Oct 2023 09:15:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232874AbjJWJP0 (ORCPT ); Mon, 23 Oct 2023 05:15:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231732AbjJWJPS (ORCPT ); Mon, 23 Oct 2023 05:15:18 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FF0DD65 for ; Mon, 23 Oct 2023 02:15:13 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 4FC3F21ACC; 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 03C452CF52; Mon, 23 Oct 2023 09:15:11 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 1E22A51EC32D; Mon, 23 Oct 2023 11:15:11 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 07/16] xen-scsifront: rework scsifront_action_handler() Date: Mon, 23 Oct 2023 11:14:58 +0200 Message-Id: <20231023091507.120828-8-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 [5.49 / 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(-0.00)[37.74%] X-Rspamd-Queue-Id: 4FC3F21ACC Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Rework scsifront_action_handler() to add the SCSI device as the first argument, and select between abort and device reset by checking whether the scsi_cmnd argument is NULL. Signed-off-by: Hannes Reinecke Reviewed-by: Christoph Hellwig --- drivers/scsi/xen-scsifront.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c index a0c13200d53a..5a6cb582e5eb 100644 --- a/drivers/scsi/xen-scsifront.c +++ b/drivers/scsi/xen-scsifront.c @@ -668,11 +668,12 @@ static int scsifront_queuecommand(struct Scsi_Host *shost, * We have to wait until an answer is returned. This answer contains the * result to be returned to the requestor. */ -static int scsifront_action_handler(struct scsi_cmnd *sc, uint8_t act) +static int scsifront_action_handler(struct scsi_device *sdev, + struct scsi_cmnd *sc) { - struct Scsi_Host *host = sc->device->host; + struct Scsi_Host *host = sdev->host; struct vscsifrnt_info *info = shost_priv(host); - struct vscsifrnt_shadow *shadow, *s = scsi_cmd_priv(sc); + struct vscsifrnt_shadow *shadow; int err = 0; if (info->host_active == STATE_ERROR) @@ -682,10 +683,14 @@ static int scsifront_action_handler(struct scsi_cmnd *sc, uint8_t act) if (!shadow) return FAILED; - shadow->act = act; + shadow->act = sc ? VSCSIIF_ACT_SCSI_ABORT : VSCSIIF_ACT_SCSI_RESET; shadow->rslt_reset = RSLT_RESET_WAITING; shadow->sc = sc; - shadow->ref_rqid = s->rqid; + if (sc) { + struct vscsifrnt_shadow *s = scsi_cmd_priv(sc); + + shadow->ref_rqid = s->rqid; + } init_waitqueue_head(&shadow->wq_reset); spin_lock_irq(host->host_lock); @@ -735,13 +740,13 @@ static int scsifront_action_handler(struct scsi_cmnd *sc, uint8_t act) static int scsifront_eh_abort_handler(struct scsi_cmnd *sc) { pr_debug("%s\n", __func__); - return scsifront_action_handler(sc, VSCSIIF_ACT_SCSI_ABORT); + return scsifront_action_handler(sc->device, sc); } static int scsifront_dev_reset_handler(struct scsi_cmnd *sc) { pr_debug("%s\n", __func__); - return scsifront_action_handler(sc, VSCSIIF_ACT_SCSI_RESET); + return scsifront_action_handler(sc->device, NULL); } static int scsifront_sdev_configure(struct scsi_device *sdev)