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

scsi: NCR5380: Add SCp members to struct NCR5380_cmd

This is necessary for the eventual removal of SCp from struct scsi_cmnd.

Link: https://lore.kernel.org/r/20220218195117.25689-9-bvanassche@acm.org
Cc: Michael Schmitz <schmitzmic@gmail.com>
Cc: Ondrej Zary <linux@zary.sk>
Suggested-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Finn Thain <fthain@linux-m68k.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Finn Thain and committed by
Martin K. Petersen
ff1269cb cd614642

+66 -56
+46 -48
drivers/scsi/NCR5380.c
··· 84 84 * On command termination, the done function will be called as 85 85 * appropriate. 86 86 * 87 - * SCSI pointers are maintained in the SCp field of SCSI command 88 - * structures, being initialized after the command is connected 87 + * The command data pointer is initialized after the command is connected 89 88 * in NCR5380_select, and set as appropriate in NCR5380_information_transfer. 90 89 * Note that in violation of the standard, an implicit SAVE POINTERS operation 91 90 * is done, since some BROKEN disks fail to issue an explicit SAVE POINTERS. ··· 144 145 145 146 static inline void initialize_SCp(struct scsi_cmnd *cmd) 146 147 { 147 - /* 148 - * Initialize the Scsi Pointer field so that all of the commands in the 149 - * various queues are valid. 150 - */ 148 + struct NCR5380_cmd *ncmd = NCR5380_to_ncmd(cmd); 151 149 152 150 if (scsi_bufflen(cmd)) { 153 - cmd->SCp.buffer = scsi_sglist(cmd); 154 - cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); 155 - cmd->SCp.this_residual = cmd->SCp.buffer->length; 151 + ncmd->buffer = scsi_sglist(cmd); 152 + ncmd->ptr = sg_virt(ncmd->buffer); 153 + ncmd->this_residual = ncmd->buffer->length; 156 154 } else { 157 - cmd->SCp.buffer = NULL; 158 - cmd->SCp.ptr = NULL; 159 - cmd->SCp.this_residual = 0; 155 + ncmd->buffer = NULL; 156 + ncmd->ptr = NULL; 157 + ncmd->this_residual = 0; 160 158 } 161 159 162 - cmd->SCp.Status = 0; 163 - cmd->SCp.Message = 0; 160 + ncmd->status = 0; 161 + ncmd->message = 0; 164 162 } 165 163 166 - static inline void advance_sg_buffer(struct scsi_cmnd *cmd) 164 + static inline void advance_sg_buffer(struct NCR5380_cmd *ncmd) 167 165 { 168 - struct scatterlist *s = cmd->SCp.buffer; 166 + struct scatterlist *s = ncmd->buffer; 169 167 170 - if (!cmd->SCp.this_residual && s && !sg_is_last(s)) { 171 - cmd->SCp.buffer = sg_next(s); 172 - cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); 173 - cmd->SCp.this_residual = cmd->SCp.buffer->length; 168 + if (!ncmd->this_residual && s && !sg_is_last(s)) { 169 + ncmd->buffer = sg_next(s); 170 + ncmd->ptr = sg_virt(ncmd->buffer); 171 + ncmd->this_residual = ncmd->buffer->length; 174 172 } 175 173 } 176 174 177 175 static inline void set_resid_from_SCp(struct scsi_cmnd *cmd) 178 176 { 179 - int resid = cmd->SCp.this_residual; 180 - struct scatterlist *s = cmd->SCp.buffer; 177 + struct NCR5380_cmd *ncmd = NCR5380_to_ncmd(cmd); 178 + int resid = ncmd->this_residual; 179 + struct scatterlist *s = ncmd->buffer; 181 180 182 181 if (s) 183 182 while (!sg_is_last(s)) { ··· 561 564 struct scsi_cmnd *cmd) 562 565 { 563 566 struct NCR5380_hostdata *hostdata = shost_priv(instance); 564 - struct NCR5380_cmd *ncmd = scsi_cmd_priv(cmd); 567 + struct NCR5380_cmd *ncmd = NCR5380_to_ncmd(cmd); 565 568 unsigned long flags; 566 569 567 570 #if (NDEBUG & NDEBUG_NO_WRITE) ··· 669 672 static void requeue_cmd(struct Scsi_Host *instance, struct scsi_cmnd *cmd) 670 673 { 671 674 struct NCR5380_hostdata *hostdata = shost_priv(instance); 672 - struct NCR5380_cmd *ncmd = scsi_cmd_priv(cmd); 675 + struct NCR5380_cmd *ncmd = NCR5380_to_ncmd(cmd); 673 676 674 677 if (hostdata->sensing == cmd) { 675 678 scsi_eh_restore_cmnd(cmd, &hostdata->ses); ··· 754 757 static void NCR5380_dma_complete(struct Scsi_Host *instance) 755 758 { 756 759 struct NCR5380_hostdata *hostdata = shost_priv(instance); 760 + struct NCR5380_cmd *ncmd = NCR5380_to_ncmd(hostdata->connected); 757 761 int transferred; 758 762 unsigned char **data; 759 763 int *count; ··· 762 764 unsigned char p; 763 765 764 766 if (hostdata->read_overruns) { 765 - p = hostdata->connected->SCp.phase; 767 + p = ncmd->phase; 766 768 if (p & SR_IO) { 767 769 udelay(10); 768 770 if ((NCR5380_read(BUS_AND_STATUS_REG) & ··· 799 801 transferred = hostdata->dma_len - NCR5380_dma_residual(hostdata); 800 802 hostdata->dma_len = 0; 801 803 802 - data = (unsigned char **)&hostdata->connected->SCp.ptr; 803 - count = &hostdata->connected->SCp.this_residual; 804 + data = (unsigned char **)&ncmd->ptr; 805 + count = &ncmd->this_residual; 804 806 *data += transferred; 805 807 *count -= transferred; 806 808 ··· 1496 1498 return -1; 1497 1499 } 1498 1500 1499 - hostdata->connected->SCp.phase = p; 1501 + NCR5380_to_ncmd(hostdata->connected)->phase = p; 1500 1502 1501 1503 if (p & SR_IO) { 1502 1504 if (hostdata->read_overruns) ··· 1688 1690 #endif 1689 1691 1690 1692 while ((cmd = hostdata->connected)) { 1691 - struct NCR5380_cmd *ncmd = scsi_cmd_priv(cmd); 1693 + struct NCR5380_cmd *ncmd = NCR5380_to_ncmd(cmd); 1692 1694 1693 1695 tmp = NCR5380_read(STATUS_REG); 1694 1696 /* We only have a valid SCSI phase when REQ is asserted */ ··· 1703 1705 sun3_dma_setup_done != cmd) { 1704 1706 int count; 1705 1707 1706 - advance_sg_buffer(cmd); 1708 + advance_sg_buffer(ncmd); 1707 1709 1708 1710 count = sun3scsi_dma_xfer_len(hostdata, cmd); 1709 1711 1710 1712 if (count > 0) { 1711 1713 if (cmd->sc_data_direction == DMA_TO_DEVICE) 1712 1714 sun3scsi_dma_send_setup(hostdata, 1713 - cmd->SCp.ptr, count); 1715 + ncmd->ptr, count); 1714 1716 else 1715 1717 sun3scsi_dma_recv_setup(hostdata, 1716 - cmd->SCp.ptr, count); 1718 + ncmd->ptr, count); 1717 1719 sun3_dma_setup_done = cmd; 1718 1720 } 1719 1721 #ifdef SUN3_SCSI_VME ··· 1753 1755 * scatter-gather list, move onto the next one. 1754 1756 */ 1755 1757 1756 - advance_sg_buffer(cmd); 1758 + advance_sg_buffer(ncmd); 1757 1759 dsprintk(NDEBUG_INFORMATION, instance, 1758 1760 "this residual %d, sg ents %d\n", 1759 - cmd->SCp.this_residual, 1760 - sg_nents(cmd->SCp.buffer)); 1761 + ncmd->this_residual, 1762 + sg_nents(ncmd->buffer)); 1761 1763 1762 1764 /* 1763 1765 * The preferred transfer method is going to be ··· 1776 1778 if (transfersize > 0) { 1777 1779 len = transfersize; 1778 1780 if (NCR5380_transfer_dma(instance, &phase, 1779 - &len, (unsigned char **)&cmd->SCp.ptr)) { 1781 + &len, (unsigned char **)&ncmd->ptr)) { 1780 1782 /* 1781 1783 * If the watchdog timer fires, all future 1782 1784 * accesses to this device will use the ··· 1792 1794 /* Transfer a small chunk so that the 1793 1795 * irq mode lock is not held too long. 1794 1796 */ 1795 - transfersize = min(cmd->SCp.this_residual, 1797 + transfersize = min(ncmd->this_residual, 1796 1798 NCR5380_PIO_CHUNK_SIZE); 1797 1799 len = transfersize; 1798 1800 NCR5380_transfer_pio(instance, &phase, &len, 1799 - (unsigned char **)&cmd->SCp.ptr, 1801 + (unsigned char **)&ncmd->ptr, 1800 1802 0); 1801 - cmd->SCp.this_residual -= transfersize - len; 1803 + ncmd->this_residual -= transfersize - len; 1802 1804 } 1803 1805 #ifdef CONFIG_SUN3 1804 1806 if (sun3_dma_setup_done == cmd) ··· 1809 1811 len = 1; 1810 1812 data = &tmp; 1811 1813 NCR5380_transfer_pio(instance, &phase, &len, &data, 0); 1812 - cmd->SCp.Message = tmp; 1814 + ncmd->message = tmp; 1813 1815 1814 1816 switch (tmp) { 1815 1817 case ABORT: ··· 1826 1828 hostdata->connected = NULL; 1827 1829 hostdata->busy[scmd_id(cmd)] &= ~(1 << cmd->device->lun); 1828 1830 1829 - set_status_byte(cmd, cmd->SCp.Status); 1831 + set_status_byte(cmd, ncmd->status); 1830 1832 1831 1833 set_resid_from_SCp(cmd); 1832 1834 1833 1835 if (cmd->cmnd[0] == REQUEST_SENSE) 1834 1836 complete_cmd(instance, cmd); 1835 1837 else { 1836 - if (cmd->SCp.Status == SAM_STAT_CHECK_CONDITION || 1837 - cmd->SCp.Status == SAM_STAT_COMMAND_TERMINATED) { 1838 + if (ncmd->status == SAM_STAT_CHECK_CONDITION || 1839 + ncmd->status == SAM_STAT_COMMAND_TERMINATED) { 1838 1840 dsprintk(NDEBUG_QUEUES, instance, "autosense: adding cmd %p to tail of autosense queue\n", 1839 1841 cmd); 1840 1842 list_add_tail(&ncmd->list, ··· 1998 2000 len = 1; 1999 2001 data = &tmp; 2000 2002 NCR5380_transfer_pio(instance, &phase, &len, &data, 0); 2001 - cmd->SCp.Status = tmp; 2003 + ncmd->status = tmp; 2002 2004 break; 2003 2005 default: 2004 2006 shost_printk(KERN_ERR, instance, "unknown phase\n"); ··· 2151 2153 if (sun3_dma_setup_done != tmp) { 2152 2154 int count; 2153 2155 2154 - advance_sg_buffer(tmp); 2156 + advance_sg_buffer(ncmd); 2155 2157 2156 2158 count = sun3scsi_dma_xfer_len(hostdata, tmp); 2157 2159 2158 2160 if (count > 0) { 2159 2161 if (tmp->sc_data_direction == DMA_TO_DEVICE) 2160 2162 sun3scsi_dma_send_setup(hostdata, 2161 - tmp->SCp.ptr, count); 2163 + ncmd->ptr, count); 2162 2164 else 2163 2165 sun3scsi_dma_recv_setup(hostdata, 2164 - tmp->SCp.ptr, count); 2166 + ncmd->ptr, count); 2165 2167 sun3_dma_setup_done = tmp; 2166 2168 } 2167 2169 } ··· 2204 2206 struct scsi_cmnd *needle) 2205 2207 { 2206 2208 if (list_find_cmd(haystack, needle)) { 2207 - struct NCR5380_cmd *ncmd = scsi_cmd_priv(needle); 2209 + struct NCR5380_cmd *ncmd = NCR5380_to_ncmd(needle); 2208 2210 2209 2211 list_del(&ncmd->list); 2210 2212 return true;
+11
drivers/scsi/NCR5380.h
··· 227 227 }; 228 228 229 229 struct NCR5380_cmd { 230 + char *ptr; 231 + int this_residual; 232 + struct scatterlist *buffer; 233 + int status; 234 + int message; 235 + int phase; 230 236 struct list_head list; 231 237 }; 232 238 ··· 244 238 static inline struct scsi_cmnd *NCR5380_to_scmd(struct NCR5380_cmd *ncmd_ptr) 245 239 { 246 240 return ((struct scsi_cmnd *)ncmd_ptr) - 1; 241 + } 242 + 243 + static inline struct NCR5380_cmd *NCR5380_to_ncmd(struct scsi_cmnd *cmd) 244 + { 245 + return scsi_cmd_priv(cmd); 247 246 } 248 247 249 248 #ifndef NDEBUG
+2 -2
drivers/scsi/atari_scsi.c
··· 538 538 static int atari_scsi_dma_xfer_len(struct NCR5380_hostdata *hostdata, 539 539 struct scsi_cmnd *cmd) 540 540 { 541 - int wanted_len = cmd->SCp.this_residual; 541 + int wanted_len = NCR5380_to_ncmd(cmd)->this_residual; 542 542 int possible_len, limit; 543 543 544 544 if (wanted_len < DMA_MIN_SIZE) ··· 610 610 } 611 611 612 612 /* Last step: apply the hard limit on DMA transfers */ 613 - limit = (atari_dma_buffer && !STRAM_ADDR(virt_to_phys(cmd->SCp.ptr))) ? 613 + limit = (atari_dma_buffer && !STRAM_ADDR(virt_to_phys(NCR5380_to_ncmd(cmd)->ptr))) ? 614 614 STRAM_BUFFER_SIZE : 255*512; 615 615 if (possible_len > limit) 616 616 possible_len = limit;
+2 -2
drivers/scsi/g_NCR5380.c
··· 663 663 static int generic_NCR5380_dma_xfer_len(struct NCR5380_hostdata *hostdata, 664 664 struct scsi_cmnd *cmd) 665 665 { 666 - int transfersize = cmd->SCp.this_residual; 666 + int transfersize = NCR5380_to_ncmd(cmd)->this_residual; 667 667 668 668 if (hostdata->flags & FLAG_NO_PSEUDO_DMA) 669 669 return 0; ··· 675 675 /* Limit PDMA send to 512 B to avoid random corruption on DTC3181E */ 676 676 if (hostdata->board == BOARD_DTC3181E && 677 677 cmd->sc_data_direction == DMA_TO_DEVICE) 678 - transfersize = min(cmd->SCp.this_residual, 512); 678 + transfersize = min(transfersize, 512); 679 679 680 680 return min(transfersize, DMA_MAX_SIZE); 681 681 }
+4 -3
drivers/scsi/mac_scsi.c
··· 404 404 static int macscsi_dma_xfer_len(struct NCR5380_hostdata *hostdata, 405 405 struct scsi_cmnd *cmd) 406 406 { 407 - if (hostdata->flags & FLAG_NO_PSEUDO_DMA || 408 - cmd->SCp.this_residual < setup_use_pdma) 407 + int resid = NCR5380_to_ncmd(cmd)->this_residual; 408 + 409 + if (hostdata->flags & FLAG_NO_PSEUDO_DMA || resid < setup_use_pdma) 409 410 return 0; 410 411 411 - return cmd->SCp.this_residual; 412 + return resid; 412 413 } 413 414 414 415 static int macscsi_dma_residual(struct NCR5380_hostdata *hostdata)
+1 -1
drivers/scsi/sun3_scsi.c
··· 334 334 static int sun3scsi_dma_xfer_len(struct NCR5380_hostdata *hostdata, 335 335 struct scsi_cmnd *cmd) 336 336 { 337 - int wanted_len = cmd->SCp.this_residual; 337 + int wanted_len = NCR5380_to_ncmd(cmd)->this_residual; 338 338 339 339 if (wanted_len < DMA_MIN_SIZE || blk_rq_is_passthrough(scsi_cmd_to_rq(cmd))) 340 340 return 0;