Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: initio: Stop using the SCSI pointer

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.

Link: https://lore.kernel.org/r/20220218195117.25689-27-bvanassche@acm.org
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Bart Van Assche and committed by
Martin K. Petersen
09cc102b db22de3e

+17 -6
+8 -6
drivers/scsi/initio.c
··· 2553 2553 SENSE_SIZE, DMA_FROM_DEVICE); 2554 2554 cblk->senseptr = (u32)dma_addr; 2555 2555 cblk->senselen = SENSE_SIZE; 2556 - cmnd->SCp.ptr = (char *)(unsigned long)dma_addr; 2556 + initio_priv(cmnd)->sense_dma_addr = dma_addr; 2557 2557 cblk->cdblen = cmnd->cmd_len; 2558 2558 2559 2559 /* Clear the returned status */ ··· 2577 2577 sizeof(struct sg_entry) * TOTAL_SG_ENTRY, 2578 2578 DMA_BIDIRECTIONAL); 2579 2579 cblk->bufptr = (u32)dma_addr; 2580 - cmnd->SCp.dma_handle = dma_addr; 2580 + initio_priv(cmnd)->sglist_dma_addr = dma_addr; 2581 2581 2582 2582 cblk->sglen = nseg; 2583 2583 ··· 2704 2704 static void i91u_unmap_scb(struct pci_dev *pci_dev, struct scsi_cmnd *cmnd) 2705 2705 { 2706 2706 /* auto sense buffer */ 2707 - if (cmnd->SCp.ptr) { 2707 + if (initio_priv(cmnd)->sense_dma_addr) { 2708 2708 dma_unmap_single(&pci_dev->dev, 2709 - (dma_addr_t)((unsigned long)cmnd->SCp.ptr), 2709 + initio_priv(cmnd)->sense_dma_addr, 2710 2710 SENSE_SIZE, DMA_FROM_DEVICE); 2711 - cmnd->SCp.ptr = NULL; 2711 + initio_priv(cmnd)->sense_dma_addr = 0; 2712 2712 } 2713 2713 2714 2714 /* request buffer */ 2715 2715 if (scsi_sg_count(cmnd)) { 2716 - dma_unmap_single(&pci_dev->dev, cmnd->SCp.dma_handle, 2716 + dma_unmap_single(&pci_dev->dev, 2717 + initio_priv(cmnd)->sglist_dma_addr, 2717 2718 sizeof(struct sg_entry) * TOTAL_SG_ENTRY, 2718 2719 DMA_BIDIRECTIONAL); 2719 2720 ··· 2797 2796 .can_queue = MAX_TARGETS * i91u_MAXQUEUE, 2798 2797 .this_id = 1, 2799 2798 .sg_tablesize = SG_ALL, 2799 + .cmd_size = sizeof(struct initio_cmd_priv), 2800 2800 }; 2801 2801 2802 2802 static int initio_probe_one(struct pci_dev *pdev,
+9
drivers/scsi/initio.h
··· 640 640 #define SCSI_RESET_HOST_RESET 0x200 641 641 #define SCSI_RESET_ACTION 0xff 642 642 643 + struct initio_cmd_priv { 644 + dma_addr_t sense_dma_addr; 645 + dma_addr_t sglist_dma_addr; 646 + }; 647 + 648 + static inline struct initio_cmd_priv *initio_priv(struct scsi_cmnd *cmd) 649 + { 650 + return scsi_cmd_priv(cmd); 651 + }