Commit 3cde55ee authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi

Pull SCSI fixes from James Bottomley:
 "Five minor bug fixes.

  The libfc one is a tiny memory leak, the zfcp one is an incorrect user
  visible parameter and the rest are on error legs or obscure features"

* tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
  scsi: 53c700: pass correct "dev" to dma_alloc_attrs()
  scsi: bnx2fc: Fix error handling in probe()
  scsi: scsi_debug: fix write_same with virtual_gb problem
  scsi: libfc: free skb when receiving invalid flogi resp
  scsi: zfcp: fix sysfs block queue limit output for max_segment_size
parents b9de6efe 8437fcf1
...@@ -403,7 +403,6 @@ struct zfcp_adapter *zfcp_adapter_enqueue(struct ccw_device *ccw_device) ...@@ -403,7 +403,6 @@ struct zfcp_adapter *zfcp_adapter_enqueue(struct ccw_device *ccw_device)
goto failed; goto failed;
/* report size limit per scatter-gather segment */ /* report size limit per scatter-gather segment */
adapter->dma_parms.max_segment_size = ZFCP_QDIO_SBALE_LEN;
adapter->ccw_device->dev.dma_parms = &adapter->dma_parms; adapter->ccw_device->dev.dma_parms = &adapter->dma_parms;
adapter->stat_read_buf_num = FSF_STATUS_READS_RECOM; adapter->stat_read_buf_num = FSF_STATUS_READS_RECOM;
......
...@@ -428,6 +428,8 @@ static struct scsi_host_template zfcp_scsi_host_template = { ...@@ -428,6 +428,8 @@ static struct scsi_host_template zfcp_scsi_host_template = {
.max_sectors = (((QDIO_MAX_ELEMENTS_PER_BUFFER - 1) .max_sectors = (((QDIO_MAX_ELEMENTS_PER_BUFFER - 1)
* ZFCP_QDIO_MAX_SBALS_PER_REQ) - 2) * 8, * ZFCP_QDIO_MAX_SBALS_PER_REQ) - 2) * 8,
/* GCD, adjusted later */ /* GCD, adjusted later */
/* report size limit per scatter-gather segment */
.max_segment_size = ZFCP_QDIO_SBALE_LEN,
.dma_boundary = ZFCP_QDIO_SBALE_LEN - 1, .dma_boundary = ZFCP_QDIO_SBALE_LEN - 1,
.shost_attrs = zfcp_sysfs_shost_attrs, .shost_attrs = zfcp_sysfs_shost_attrs,
.sdev_attrs = zfcp_sysfs_sdev_attrs, .sdev_attrs = zfcp_sysfs_sdev_attrs,
......
...@@ -295,7 +295,7 @@ NCR_700_detect(struct scsi_host_template *tpnt, ...@@ -295,7 +295,7 @@ NCR_700_detect(struct scsi_host_template *tpnt,
if(tpnt->sdev_attrs == NULL) if(tpnt->sdev_attrs == NULL)
tpnt->sdev_attrs = NCR_700_dev_attrs; tpnt->sdev_attrs = NCR_700_dev_attrs;
memory = dma_alloc_attrs(hostdata->dev, TOTAL_MEM_SIZE, &pScript, memory = dma_alloc_attrs(dev, TOTAL_MEM_SIZE, &pScript,
GFP_KERNEL, DMA_ATTR_NON_CONSISTENT); GFP_KERNEL, DMA_ATTR_NON_CONSISTENT);
if(memory == NULL) { if(memory == NULL) {
printk(KERN_ERR "53c700: Failed to allocate memory for driver, detaching\n"); printk(KERN_ERR "53c700: Failed to allocate memory for driver, detaching\n");
......
...@@ -240,6 +240,7 @@ struct bnx2fc_cmd_mgr *bnx2fc_cmd_mgr_alloc(struct bnx2fc_hba *hba) ...@@ -240,6 +240,7 @@ struct bnx2fc_cmd_mgr *bnx2fc_cmd_mgr_alloc(struct bnx2fc_hba *hba)
return NULL; return NULL;
} }
cmgr->hba = hba;
cmgr->free_list = kcalloc(arr_sz, sizeof(*cmgr->free_list), cmgr->free_list = kcalloc(arr_sz, sizeof(*cmgr->free_list),
GFP_KERNEL); GFP_KERNEL);
if (!cmgr->free_list) { if (!cmgr->free_list) {
...@@ -256,7 +257,6 @@ struct bnx2fc_cmd_mgr *bnx2fc_cmd_mgr_alloc(struct bnx2fc_hba *hba) ...@@ -256,7 +257,6 @@ struct bnx2fc_cmd_mgr *bnx2fc_cmd_mgr_alloc(struct bnx2fc_hba *hba)
goto mem_err; goto mem_err;
} }
cmgr->hba = hba;
cmgr->cmds = (struct bnx2fc_cmd **)(cmgr + 1); cmgr->cmds = (struct bnx2fc_cmd **)(cmgr + 1);
for (i = 0; i < arr_sz; i++) { for (i = 0; i < arr_sz; i++) {
...@@ -295,7 +295,7 @@ struct bnx2fc_cmd_mgr *bnx2fc_cmd_mgr_alloc(struct bnx2fc_hba *hba) ...@@ -295,7 +295,7 @@ struct bnx2fc_cmd_mgr *bnx2fc_cmd_mgr_alloc(struct bnx2fc_hba *hba)
/* Allocate pool of io_bdts - one for each bnx2fc_cmd */ /* Allocate pool of io_bdts - one for each bnx2fc_cmd */
mem_size = num_ios * sizeof(struct io_bdt *); mem_size = num_ios * sizeof(struct io_bdt *);
cmgr->io_bdt_pool = kmalloc(mem_size, GFP_KERNEL); cmgr->io_bdt_pool = kzalloc(mem_size, GFP_KERNEL);
if (!cmgr->io_bdt_pool) { if (!cmgr->io_bdt_pool) {
printk(KERN_ERR PFX "failed to alloc io_bdt_pool\n"); printk(KERN_ERR PFX "failed to alloc io_bdt_pool\n");
goto mem_err; goto mem_err;
......
...@@ -1726,14 +1726,14 @@ void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp, ...@@ -1726,14 +1726,14 @@ void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp,
fc_frame_payload_op(fp) != ELS_LS_ACC) { fc_frame_payload_op(fp) != ELS_LS_ACC) {
FC_LPORT_DBG(lport, "FLOGI not accepted or bad response\n"); FC_LPORT_DBG(lport, "FLOGI not accepted or bad response\n");
fc_lport_error(lport, fp); fc_lport_error(lport, fp);
goto err; goto out;
} }
flp = fc_frame_payload_get(fp, sizeof(*flp)); flp = fc_frame_payload_get(fp, sizeof(*flp));
if (!flp) { if (!flp) {
FC_LPORT_DBG(lport, "FLOGI bad response\n"); FC_LPORT_DBG(lport, "FLOGI bad response\n");
fc_lport_error(lport, fp); fc_lport_error(lport, fp);
goto err; goto out;
} }
mfs = ntohs(flp->fl_csp.sp_bb_data) & mfs = ntohs(flp->fl_csp.sp_bb_data) &
...@@ -1743,7 +1743,7 @@ void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp, ...@@ -1743,7 +1743,7 @@ void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp,
FC_LPORT_DBG(lport, "FLOGI bad mfs:%hu response, " FC_LPORT_DBG(lport, "FLOGI bad mfs:%hu response, "
"lport->mfs:%hu\n", mfs, lport->mfs); "lport->mfs:%hu\n", mfs, lport->mfs);
fc_lport_error(lport, fp); fc_lport_error(lport, fp);
goto err; goto out;
} }
if (mfs <= lport->mfs) { if (mfs <= lport->mfs) {
......
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
/* make sure inq_product_rev string corresponds to this version */ /* make sure inq_product_rev string corresponds to this version */
#define SDEBUG_VERSION "0188" /* format to fit INQUIRY revision field */ #define SDEBUG_VERSION "0188" /* format to fit INQUIRY revision field */
static const char *sdebug_version_date = "20180128"; static const char *sdebug_version_date = "20190125";
#define MY_NAME "scsi_debug" #define MY_NAME "scsi_debug"
...@@ -735,7 +735,7 @@ static inline bool scsi_debug_lbp(void) ...@@ -735,7 +735,7 @@ static inline bool scsi_debug_lbp(void)
(sdebug_lbpu || sdebug_lbpws || sdebug_lbpws10); (sdebug_lbpu || sdebug_lbpws || sdebug_lbpws10);
} }
static void *fake_store(unsigned long long lba) static void *lba2fake_store(unsigned long long lba)
{ {
lba = do_div(lba, sdebug_store_sectors); lba = do_div(lba, sdebug_store_sectors);
...@@ -2514,8 +2514,8 @@ static int do_device_access(struct scsi_cmnd *scmd, u32 sg_skip, u64 lba, ...@@ -2514,8 +2514,8 @@ static int do_device_access(struct scsi_cmnd *scmd, u32 sg_skip, u64 lba,
return ret; return ret;
} }
/* If fake_store(lba,num) compares equal to arr(num), then copy top half of /* If lba2fake_store(lba,num) compares equal to arr(num), then copy top half of
* arr into fake_store(lba,num) and return true. If comparison fails then * arr into lba2fake_store(lba,num) and return true. If comparison fails then
* return false. */ * return false. */
static bool comp_write_worker(u64 lba, u32 num, const u8 *arr) static bool comp_write_worker(u64 lba, u32 num, const u8 *arr)
{ {
...@@ -2643,7 +2643,7 @@ static int prot_verify_read(struct scsi_cmnd *SCpnt, sector_t start_sec, ...@@ -2643,7 +2643,7 @@ static int prot_verify_read(struct scsi_cmnd *SCpnt, sector_t start_sec,
if (sdt->app_tag == cpu_to_be16(0xffff)) if (sdt->app_tag == cpu_to_be16(0xffff))
continue; continue;
ret = dif_verify(sdt, fake_store(sector), sector, ei_lba); ret = dif_verify(sdt, lba2fake_store(sector), sector, ei_lba);
if (ret) { if (ret) {
dif_errors++; dif_errors++;
return ret; return ret;
...@@ -3261,10 +3261,12 @@ static int resp_write_scat(struct scsi_cmnd *scp, ...@@ -3261,10 +3261,12 @@ static int resp_write_scat(struct scsi_cmnd *scp,
static int resp_write_same(struct scsi_cmnd *scp, u64 lba, u32 num, static int resp_write_same(struct scsi_cmnd *scp, u64 lba, u32 num,
u32 ei_lba, bool unmap, bool ndob) u32 ei_lba, bool unmap, bool ndob)
{ {
int ret;
unsigned long iflags; unsigned long iflags;
unsigned long long i; unsigned long long i;
int ret; u32 lb_size = sdebug_sector_size;
u64 lba_off; u64 block, lbaa;
u8 *fs1p;
ret = check_device_access_params(scp, lba, num); ret = check_device_access_params(scp, lba, num);
if (ret) if (ret)
...@@ -3276,31 +3278,30 @@ static int resp_write_same(struct scsi_cmnd *scp, u64 lba, u32 num, ...@@ -3276,31 +3278,30 @@ static int resp_write_same(struct scsi_cmnd *scp, u64 lba, u32 num,
unmap_region(lba, num); unmap_region(lba, num);
goto out; goto out;
} }
lbaa = lba;
lba_off = lba * sdebug_sector_size; block = do_div(lbaa, sdebug_store_sectors);
/* if ndob then zero 1 logical block, else fetch 1 logical block */ /* if ndob then zero 1 logical block, else fetch 1 logical block */
fs1p = fake_storep + (block * lb_size);
if (ndob) { if (ndob) {
memset(fake_storep + lba_off, 0, sdebug_sector_size); memset(fs1p, 0, lb_size);
ret = 0; ret = 0;
} else } else
ret = fetch_to_dev_buffer(scp, fake_storep + lba_off, ret = fetch_to_dev_buffer(scp, fs1p, lb_size);
sdebug_sector_size);
if (-1 == ret) { if (-1 == ret) {
write_unlock_irqrestore(&atomic_rw, iflags); write_unlock_irqrestore(&atomic_rw, iflags);
return DID_ERROR << 16; return DID_ERROR << 16;
} else if (sdebug_verbose && !ndob && (ret < sdebug_sector_size)) } else if (sdebug_verbose && !ndob && (ret < lb_size))
sdev_printk(KERN_INFO, scp->device, sdev_printk(KERN_INFO, scp->device,
"%s: %s: lb size=%u, IO sent=%d bytes\n", "%s: %s: lb size=%u, IO sent=%d bytes\n",
my_name, "write same", my_name, "write same", lb_size, ret);
sdebug_sector_size, ret);
/* Copy first sector to remaining blocks */ /* Copy first sector to remaining blocks */
for (i = 1 ; i < num ; i++) for (i = 1 ; i < num ; i++) {
memcpy(fake_storep + ((lba + i) * sdebug_sector_size), lbaa = lba + i;
fake_storep + lba_off, block = do_div(lbaa, sdebug_store_sectors);
sdebug_sector_size); memmove(fake_storep + (block * lb_size), fs1p, lb_size);
}
if (scsi_debug_lbp()) if (scsi_debug_lbp())
map_region(lba, num); map_region(lba, num);
out: out:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment