From patchwork Fri Jan 28 22:18:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 537864 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 D7CC5C433EF for ; Fri, 28 Jan 2022 22:21:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344651AbiA1WVd (ORCPT ); Fri, 28 Jan 2022 17:21:33 -0500 Received: from mail-pj1-f46.google.com ([209.85.216.46]:55201 "EHLO mail-pj1-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232618AbiA1WVW (ORCPT ); Fri, 28 Jan 2022 17:21:22 -0500 Received: by mail-pj1-f46.google.com with SMTP id r59so7788980pjg.4 for ; Fri, 28 Jan 2022 14:21:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=18IE7iS17cTsg0Pe8BaO6xp8GRuiUiq9Rqi+/kQ2urQ=; b=DOke9QQcWvdYuf3DAGqrKZq1I55Qx+3CTu4pNFemRy2HXCf2kjDxIpX44lP31OWwxc U01857Xpjx/+1ceUzxXRkqrWGjJ7MOFaiBbwPVVLTfnRFkhdsJ3bp0W51WuHuJsQ1hrX ZZ/w4wDpVqxBMKAqrADs0KG95xUtRDlq9PnSzp3+P1ucVUJKkpazHTW0Luq2W8bk4u9Q ELhxPUUHx41DeXUCwKL9uLds0X9ZUCIni7V/MZNI9tOpuVq2IQDMrrjsdg4A0+3o5wge Zsfdo9fmf/p2EZRO6esBYDP9GELaRByD4kTCWAkRVoxOyG1OrZSrHMr03/5FoRnAwx7x L9yg== X-Gm-Message-State: AOAM531TmLguPr3ZgQzTXGX+EdpiOCmNyk7guZeSK8hFoMRwmKLcIj/P 6bColPuvHkJNw5RI76AxN/j/oPCNLKCVcg== X-Google-Smtp-Source: ABdhPJyn4Ytnx4iu+pcD9UWmCUB0VHtP0lCSmbTXNt5KD+vfdJ7h4rk2IUp7RRLfVR39nKwUQjDBlw== X-Received: by 2002:a17:90b:350c:: with SMTP id ls12mr12058306pjb.182.1643408481981; Fri, 28 Jan 2022 14:21:21 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id t2sm7787931pfg.207.2022.01.28.14.21.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 14:21:21 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , "James E.J. Bottomley" Subject: [PATCH 23/44] initio: Stop using the SCSI pointer Date: Fri, 28 Jan 2022 14:18:48 -0800 Message-Id: <20220128221909.8141-24-bvanassche@acm.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220128221909.8141-1-bvanassche@acm.org> References: <20220128221909.8141-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set .cmd_size in the SCSI host template instead of using the SCSI pointer from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Signed-off-by: Bart Van Assche Reviewed-by: Johannes Thumshirn --- drivers/scsi/initio.c | 14 ++++++++------ drivers/scsi/initio.h | 9 +++++++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c index 5f96ac47d7fd..f585d6e5fab9 100644 --- a/drivers/scsi/initio.c +++ b/drivers/scsi/initio.c @@ -2553,7 +2553,7 @@ static void initio_build_scb(struct initio_host * host, struct scsi_ctrl_blk * c SENSE_SIZE, DMA_FROM_DEVICE); cblk->senseptr = (u32)dma_addr; cblk->senselen = SENSE_SIZE; - cmnd->SCp.ptr = (char *)(unsigned long)dma_addr; + initio_priv(cmnd)->sense_dma_addr = dma_addr; cblk->cdblen = cmnd->cmd_len; /* Clear the returned status */ @@ -2577,7 +2577,7 @@ static void initio_build_scb(struct initio_host * host, struct scsi_ctrl_blk * c sizeof(struct sg_entry) * TOTAL_SG_ENTRY, DMA_BIDIRECTIONAL); cblk->bufptr = (u32)dma_addr; - cmnd->SCp.dma_handle = dma_addr; + initio_priv(cmnd)->sglist_dma_addr = dma_addr; cblk->sglen = nseg; @@ -2704,16 +2704,17 @@ static int i91u_biosparam(struct scsi_device *sdev, struct block_device *dev, static void i91u_unmap_scb(struct pci_dev *pci_dev, struct scsi_cmnd *cmnd) { /* auto sense buffer */ - if (cmnd->SCp.ptr) { + if (initio_priv(cmnd)->sense_dma_addr) { dma_unmap_single(&pci_dev->dev, - (dma_addr_t)((unsigned long)cmnd->SCp.ptr), + initio_priv(cmnd)->sense_dma_addr, SENSE_SIZE, DMA_FROM_DEVICE); - cmnd->SCp.ptr = NULL; + initio_priv(cmnd)->sense_dma_addr = 0; } /* request buffer */ if (scsi_sg_count(cmnd)) { - dma_unmap_single(&pci_dev->dev, cmnd->SCp.dma_handle, + dma_unmap_single(&pci_dev->dev, + initio_priv(cmnd)->sglist_dma_addr, sizeof(struct sg_entry) * TOTAL_SG_ENTRY, DMA_BIDIRECTIONAL); @@ -2796,6 +2797,7 @@ static struct scsi_host_template initio_template = { .can_queue = MAX_TARGETS * i91u_MAXQUEUE, .this_id = 1, .sg_tablesize = SG_ALL, + .cmd_size = sizeof(struct initio_cmd_priv), }; static int initio_probe_one(struct pci_dev *pdev, diff --git a/drivers/scsi/initio.h b/drivers/scsi/initio.h index 9fd010cf1f8a..7c9741552654 100644 --- a/drivers/scsi/initio.h +++ b/drivers/scsi/initio.h @@ -640,3 +640,12 @@ typedef struct _NVRAM { #define SCSI_RESET_HOST_RESET 0x200 #define SCSI_RESET_ACTION 0xff +struct initio_cmd_priv { + dma_addr_t sense_dma_addr; + dma_addr_t sglist_dma_addr; +}; + +static inline struct initio_cmd_priv *initio_priv(struct scsi_cmnd *cmd) +{ + return scsi_cmd_priv(cmd); +}