aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/libiscsi_tcp.c15
-rw-r--r--include/scsi/libiscsi_tcp.h1
2 files changed, 14 insertions, 2 deletions
diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c
index 8eeb39ffa37f..e98ae33f1295 100644
--- a/drivers/scsi/libiscsi_tcp.c
+++ b/drivers/scsi/libiscsi_tcp.c
@@ -132,14 +132,25 @@ static void iscsi_tcp_segment_map(struct iscsi_segment *segment, int recv)
132 if (page_count(sg_page(sg)) >= 1 && !recv) 132 if (page_count(sg_page(sg)) >= 1 && !recv)
133 return; 133 return;
134 134
135 segment->sg_mapped = kmap_atomic(sg_page(sg), KM_SOFTIRQ0); 135 if (recv) {
136 segment->atomic_mapped = true;
137 segment->sg_mapped = kmap_atomic(sg_page(sg), KM_SOFTIRQ0);
138 } else {
139 segment->atomic_mapped = false;
140 /* the xmit path can sleep with the page mapped so use kmap */
141 segment->sg_mapped = kmap(sg_page(sg));
142 }
143
136 segment->data = segment->sg_mapped + sg->offset + segment->sg_offset; 144 segment->data = segment->sg_mapped + sg->offset + segment->sg_offset;
137} 145}
138 146
139void iscsi_tcp_segment_unmap(struct iscsi_segment *segment) 147void iscsi_tcp_segment_unmap(struct iscsi_segment *segment)
140{ 148{
141 if (segment->sg_mapped) { 149 if (segment->sg_mapped) {
142 kunmap_atomic(segment->sg_mapped, KM_SOFTIRQ0); 150 if (segment->atomic_mapped)
151 kunmap_atomic(segment->sg_mapped, KM_SOFTIRQ0);
152 else
153 kunmap(sg_page(segment->sg));
143 segment->sg_mapped = NULL; 154 segment->sg_mapped = NULL;
144 segment->data = NULL; 155 segment->data = NULL;
145 } 156 }
diff --git a/include/scsi/libiscsi_tcp.h b/include/scsi/libiscsi_tcp.h
index 741ae7ed4394..e6b9fd2eea34 100644
--- a/include/scsi/libiscsi_tcp.h
+++ b/include/scsi/libiscsi_tcp.h
@@ -47,6 +47,7 @@ struct iscsi_segment {
47 struct scatterlist *sg; 47 struct scatterlist *sg;
48 void *sg_mapped; 48 void *sg_mapped;
49 unsigned int sg_offset; 49 unsigned int sg_offset;
50 bool atomic_mapped;
50 51
51 iscsi_segment_done_fn_t *done; 52 iscsi_segment_done_fn_t *done;
52}; 53};