aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaurizio Lombardi <mlombard@redhat.com>2015-08-12 11:00:23 -0400
committerJames Bottomley <JBottomley@Odin.com>2015-10-26 22:05:45 -0400
commitfd6ddfa4c1ddfb4a149b31845144b4cf3cbef54d (patch)
tree846c774cf5b9bbb0a1991c4770bac1435d76d6ed
parentc4f39bdaf40e2651f4fb3e6944e05166f1ab1d38 (diff)
fnic: check pci_map_single() return value
the kernel prints some warnings when compiled with CONFIG_DMA_API_DEBUG. This is because the fnic driver doesn't check the return value of pci_map_single(). [ 11.942770] scsi host12: fnic [ 11.950811] ------------[ cut here ]------------ [ 11.950818] WARNING: at lib/dma-debug.c:937 check_unmap+0x47b/0x920() [ 11.950821] fnic 0000:0c:00.0: DMA-API: device driver failed to check map error[device address=0x0000002020a30040] [size=44 bytes] [mapped as single] Signed-off-by: Maurizio Lombardi <mlombard@redhat.com> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Reviewed By: Tomas Henzl <thenzl@redhat.com> Signed-off-by: James Bottomley <JBottomley@Odin.com>
-rw-r--r--drivers/scsi/fnic/fnic_fcs.c46
-rw-r--r--drivers/scsi/fnic/fnic_scsi.c16
2 files changed, 54 insertions, 8 deletions
diff --git a/drivers/scsi/fnic/fnic_fcs.c b/drivers/scsi/fnic/fnic_fcs.c
index bf0bbd42efb5..67669a9e73c1 100644
--- a/drivers/scsi/fnic/fnic_fcs.c
+++ b/drivers/scsi/fnic/fnic_fcs.c
@@ -939,6 +939,7 @@ int fnic_alloc_rq_frame(struct vnic_rq *rq)
939 struct sk_buff *skb; 939 struct sk_buff *skb;
940 u16 len; 940 u16 len;
941 dma_addr_t pa; 941 dma_addr_t pa;
942 int r;
942 943
943 len = FC_FRAME_HEADROOM + FC_MAX_FRAME + FC_FRAME_TAILROOM; 944 len = FC_FRAME_HEADROOM + FC_MAX_FRAME + FC_FRAME_TAILROOM;
944 skb = dev_alloc_skb(len); 945 skb = dev_alloc_skb(len);
@@ -952,8 +953,19 @@ int fnic_alloc_rq_frame(struct vnic_rq *rq)
952 skb_reset_network_header(skb); 953 skb_reset_network_header(skb);
953 skb_put(skb, len); 954 skb_put(skb, len);
954 pa = pci_map_single(fnic->pdev, skb->data, len, PCI_DMA_FROMDEVICE); 955 pa = pci_map_single(fnic->pdev, skb->data, len, PCI_DMA_FROMDEVICE);
956
957 r = pci_dma_mapping_error(fnic->pdev, pa);
958 if (r) {
959 printk(KERN_ERR "PCI mapping failed with error %d\n", r);
960 goto free_skb;
961 }
962
955 fnic_queue_rq_desc(rq, skb, pa, len); 963 fnic_queue_rq_desc(rq, skb, pa, len);
956 return 0; 964 return 0;
965
966free_skb:
967 kfree_skb(skb);
968 return r;
957} 969}
958 970
959void fnic_free_rq_buf(struct vnic_rq *rq, struct vnic_rq_buf *buf) 971void fnic_free_rq_buf(struct vnic_rq *rq, struct vnic_rq_buf *buf)
@@ -981,6 +993,7 @@ void fnic_eth_send(struct fcoe_ctlr *fip, struct sk_buff *skb)
981 struct ethhdr *eth_hdr; 993 struct ethhdr *eth_hdr;
982 struct vlan_ethhdr *vlan_hdr; 994 struct vlan_ethhdr *vlan_hdr;
983 unsigned long flags; 995 unsigned long flags;
996 int r;
984 997
985 if (!fnic->vlan_hw_insert) { 998 if (!fnic->vlan_hw_insert) {
986 eth_hdr = (struct ethhdr *)skb_mac_header(skb); 999 eth_hdr = (struct ethhdr *)skb_mac_header(skb);
@@ -1003,18 +1016,27 @@ void fnic_eth_send(struct fcoe_ctlr *fip, struct sk_buff *skb)
1003 1016
1004 pa = pci_map_single(fnic->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); 1017 pa = pci_map_single(fnic->pdev, skb->data, skb->len, PCI_DMA_TODEVICE);
1005 1018
1006 spin_lock_irqsave(&fnic->wq_lock[0], flags); 1019 r = pci_dma_mapping_error(fnic->pdev, pa);
1007 if (!vnic_wq_desc_avail(wq)) { 1020 if (r) {
1008 pci_unmap_single(fnic->pdev, pa, skb->len, PCI_DMA_TODEVICE); 1021 printk(KERN_ERR "PCI mapping failed with error %d\n", r);
1009 spin_unlock_irqrestore(&fnic->wq_lock[0], flags); 1022 goto free_skb;
1010 kfree_skb(skb);
1011 return;
1012 } 1023 }
1013 1024
1025 spin_lock_irqsave(&fnic->wq_lock[0], flags);
1026 if (!vnic_wq_desc_avail(wq))
1027 goto irq_restore;
1028
1014 fnic_queue_wq_eth_desc(wq, skb, pa, skb->len, 1029 fnic_queue_wq_eth_desc(wq, skb, pa, skb->len,
1015 0 /* hw inserts cos value */, 1030 0 /* hw inserts cos value */,
1016 fnic->vlan_id, 1); 1031 fnic->vlan_id, 1);
1017 spin_unlock_irqrestore(&fnic->wq_lock[0], flags); 1032 spin_unlock_irqrestore(&fnic->wq_lock[0], flags);
1033 return;
1034
1035irq_restore:
1036 spin_unlock_irqrestore(&fnic->wq_lock[0], flags);
1037 pci_unmap_single(fnic->pdev, pa, skb->len, PCI_DMA_TODEVICE);
1038free_skb:
1039 kfree_skb(skb);
1018} 1040}
1019 1041
1020/* 1042/*
@@ -1071,6 +1093,12 @@ static int fnic_send_frame(struct fnic *fnic, struct fc_frame *fp)
1071 1093
1072 pa = pci_map_single(fnic->pdev, eth_hdr, tot_len, PCI_DMA_TODEVICE); 1094 pa = pci_map_single(fnic->pdev, eth_hdr, tot_len, PCI_DMA_TODEVICE);
1073 1095
1096 ret = pci_dma_mapping_error(fnic->pdev, pa);
1097 if (ret) {
1098 printk(KERN_ERR "DMA map failed with error %d\n", ret);
1099 goto free_skb_on_err;
1100 }
1101
1074 if ((fnic_fc_trace_set_data(fnic->lport->host->host_no, FNIC_FC_SEND, 1102 if ((fnic_fc_trace_set_data(fnic->lport->host->host_no, FNIC_FC_SEND,
1075 (char *)eth_hdr, tot_len)) != 0) { 1103 (char *)eth_hdr, tot_len)) != 0) {
1076 printk(KERN_ERR "fnic ctlr frame trace error!!!"); 1104 printk(KERN_ERR "fnic ctlr frame trace error!!!");
@@ -1082,15 +1110,17 @@ static int fnic_send_frame(struct fnic *fnic, struct fc_frame *fp)
1082 pci_unmap_single(fnic->pdev, pa, 1110 pci_unmap_single(fnic->pdev, pa,
1083 tot_len, PCI_DMA_TODEVICE); 1111 tot_len, PCI_DMA_TODEVICE);
1084 ret = -1; 1112 ret = -1;
1085 goto fnic_send_frame_end; 1113 goto irq_restore;
1086 } 1114 }
1087 1115
1088 fnic_queue_wq_desc(wq, skb, pa, tot_len, fr_eof(fp), 1116 fnic_queue_wq_desc(wq, skb, pa, tot_len, fr_eof(fp),
1089 0 /* hw inserts cos value */, 1117 0 /* hw inserts cos value */,
1090 fnic->vlan_id, 1, 1, 1); 1118 fnic->vlan_id, 1, 1, 1);
1091fnic_send_frame_end: 1119
1120irq_restore:
1092 spin_unlock_irqrestore(&fnic->wq_lock[0], flags); 1121 spin_unlock_irqrestore(&fnic->wq_lock[0], flags);
1093 1122
1123free_skb_on_err:
1094 if (ret) 1124 if (ret)
1095 dev_kfree_skb_any(fp_skb(fp)); 1125 dev_kfree_skb_any(fp_skb(fp));
1096 1126
diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index 25436cd2860c..266b909fe854 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -330,6 +330,7 @@ static inline int fnic_queue_wq_copy_desc(struct fnic *fnic,
330 int flags; 330 int flags;
331 u8 exch_flags; 331 u8 exch_flags;
332 struct scsi_lun fc_lun; 332 struct scsi_lun fc_lun;
333 int r;
333 334
334 if (sg_count) { 335 if (sg_count) {
335 /* For each SGE, create a device desc entry */ 336 /* For each SGE, create a device desc entry */
@@ -346,6 +347,12 @@ static inline int fnic_queue_wq_copy_desc(struct fnic *fnic,
346 io_req->sgl_list, 347 io_req->sgl_list,
347 sizeof(io_req->sgl_list[0]) * sg_count, 348 sizeof(io_req->sgl_list[0]) * sg_count,
348 PCI_DMA_TODEVICE); 349 PCI_DMA_TODEVICE);
350
351 r = pci_dma_mapping_error(fnic->pdev, io_req->sgl_list_pa);
352 if (r) {
353 printk(KERN_ERR "PCI mapping failed with error %d\n", r);
354 return SCSI_MLQUEUE_HOST_BUSY;
355 }
349 } 356 }
350 357
351 io_req->sense_buf_pa = pci_map_single(fnic->pdev, 358 io_req->sense_buf_pa = pci_map_single(fnic->pdev,
@@ -353,6 +360,15 @@ static inline int fnic_queue_wq_copy_desc(struct fnic *fnic,
353 SCSI_SENSE_BUFFERSIZE, 360 SCSI_SENSE_BUFFERSIZE,
354 PCI_DMA_FROMDEVICE); 361 PCI_DMA_FROMDEVICE);
355 362
363 r = pci_dma_mapping_error(fnic->pdev, io_req->sense_buf_pa);
364 if (r) {
365 pci_unmap_single(fnic->pdev, io_req->sgl_list_pa,
366 sizeof(io_req->sgl_list[0]) * sg_count,
367 PCI_DMA_TODEVICE);
368 printk(KERN_ERR "PCI mapping failed with error %d\n", r);
369 return SCSI_MLQUEUE_HOST_BUSY;
370 }
371
356 int_to_scsilun(sc->device->lun, &fc_lun); 372 int_to_scsilun(sc->device->lun, &fc_lun);
357 373
358 /* Enqueue the descriptor in the Copy WQ */ 374 /* Enqueue the descriptor in the Copy WQ */