From patchwork Mon Oct 2 15:49:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 729638 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 BDCA8E743C3 for ; Mon, 2 Oct 2023 15:49:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238233AbjJBPti (ORCPT ); Mon, 2 Oct 2023 11:49:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238220AbjJBPtg (ORCPT ); Mon, 2 Oct 2023 11:49:36 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AC94DC for ; Mon, 2 Oct 2023 08:49:32 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id CF5A51F88D; Mon, 2 Oct 2023 15:49:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1696261770; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q5VTlPqATzovuBpUgOixAJ4JWKtwxPGojM6ScIuVCB8=; b=mnfQ5PxxAkm571Z9590eCdWianIhlGk48tZEcxEfg3TniIYq8pzeLUKFdILx37ztN2A03w jR/LDYIWGtZw8cggooM0tJvbni43RBt/8FQ88sBL4eXjrCou0N1W3ijdQWkuIuyr5ve+WQ Rpw3IGSHMQF8MqvCQkxi7CcTGn+h0UY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1696261770; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q5VTlPqATzovuBpUgOixAJ4JWKtwxPGojM6ScIuVCB8=; b=q3iMW9BX0ziUmuZsU+drTB6aX9xjy5YLjqTws0nlSqN/19d1lIL/3zMM653O0FkkSOCKNC WIfYaoV68opAtGBw== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id AFCA62C14E; Mon, 2 Oct 2023 15:49:30 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id C6E1151E7569; Mon, 2 Oct 2023 17:49:30 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: James Bottomley , linux-scsi@vger.kernel.org, Christoph Hellwig , Hannes Reinecke Subject: [PATCH 06/15] xen-scsifront: add scsi device as argument to scsifront_do_request() Date: Mon, 2 Oct 2023 17:49:18 +0200 Message-Id: <20231002154927.68643-7-hare@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20231002154927.68643-1-hare@suse.de> References: <20231002154927.68643-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Add scsi device as argument to scsifront_do_request() so that it will be possible to call it with a NULL command pointer. Signed-off-by: Hannes Reinecke Reviewed-by: Christoph Hellwig --- drivers/scsi/xen-scsifront.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c index 9ec55ddc1204..a0c13200d53a 100644 --- a/drivers/scsi/xen-scsifront.c +++ b/drivers/scsi/xen-scsifront.c @@ -178,7 +178,8 @@ static void scsifront_put_rqid(struct vscsifrnt_info *info, uint32_t id) scsifront_wake_up(info); } -static int scsifront_do_request(struct vscsifrnt_info *info, +static int scsifront_do_request(struct scsi_device *sdev, + struct vscsifrnt_info *info, struct vscsifrnt_shadow *shadow) { struct vscsiif_front_ring *ring = &(info->ring); @@ -205,17 +206,25 @@ static int scsifront_do_request(struct vscsifrnt_info *info, ring_req->ref_rqid = shadow->ref_rqid; ring_req->nr_segments = shadow->nr_segments; - ring_req->id = sc->device->id; - ring_req->lun = sc->device->lun; - ring_req->channel = sc->device->channel; - ring_req->cmd_len = sc->cmd_len; + ring_req->id = sdev->id; + ring_req->lun = sdev->lun; + ring_req->channel = sdev->channel; - BUG_ON(sc->cmd_len > VSCSIIF_MAX_COMMAND_SIZE); + if (sc) { + ring_req->cmd_len = sc->cmd_len; - memcpy(ring_req->cmnd, sc->cmnd, sc->cmd_len); + BUG_ON(sc->cmd_len > VSCSIIF_MAX_COMMAND_SIZE); - ring_req->sc_data_direction = (uint8_t)sc->sc_data_direction; - ring_req->timeout_per_command = scsi_cmd_to_rq(sc)->timeout / HZ; + memcpy(ring_req->cmnd, sc->cmnd, sc->cmd_len); + + ring_req->sc_data_direction = (uint8_t)sc->sc_data_direction; + ring_req->timeout_per_command = + scsi_cmd_to_rq(sc)->timeout / HZ; + } else { + ring_req->cmd_len = VSCSIIF_MAX_COMMAND_SIZE; + memset(ring_req->cmnd, 0, VSCSIIF_MAX_COMMAND_SIZE); + ring_req->sc_data_direction = DMA_NONE; + } for (i = 0; i < (shadow->nr_segments & ~VSCSIIF_SG_GRANT); i++) ring_req->seg[i] = shadow->seg[i]; @@ -637,7 +646,7 @@ static int scsifront_queuecommand(struct Scsi_Host *shost, return 0; } - if (scsifront_do_request(info, shadow)) { + if (scsifront_do_request(sc->device, info, shadow)) { scsifront_gnttab_done(info, shadow); goto busy; } @@ -685,7 +694,7 @@ static int scsifront_action_handler(struct scsi_cmnd *sc, uint8_t act) if (scsifront_enter(info)) goto fail; - if (!scsifront_do_request(info, shadow)) + if (!scsifront_do_request(sc->device, info, shadow)) break; scsifront_return(info);