diff options
Diffstat (limited to 'drivers/scsi/osst.c')
-rw-r--r-- | drivers/scsi/osst.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c index 331b789937c4..1c5c4b68f20f 100644 --- a/drivers/scsi/osst.c +++ b/drivers/scsi/osst.c | |||
@@ -542,7 +542,7 @@ static int osst_verify_frame(struct osst_tape * STp, int frame_seq_number, int q | |||
542 | if (STp->raw) { | 542 | if (STp->raw) { |
543 | if (STp->buffer->syscall_result) { | 543 | if (STp->buffer->syscall_result) { |
544 | for (i=0; i < STp->buffer->sg_segs; i++) | 544 | for (i=0; i < STp->buffer->sg_segs; i++) |
545 | memset(page_address(STp->buffer->sg[i].page), | 545 | memset(page_address(sg_page(&STp->buffer->sg[i])), |
546 | 0, STp->buffer->sg[i].length); | 546 | 0, STp->buffer->sg[i].length); |
547 | strcpy(STp->buffer->b_data, "READ ERROR ON FRAME"); | 547 | strcpy(STp->buffer->b_data, "READ ERROR ON FRAME"); |
548 | } else | 548 | } else |
@@ -4437,7 +4437,7 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp) | |||
4437 | for (i = 0, b_size = 0; | 4437 | for (i = 0, b_size = 0; |
4438 | (i < STp->buffer->sg_segs) && ((b_size + STp->buffer->sg[i].length) <= OS_DATA_SIZE); | 4438 | (i < STp->buffer->sg_segs) && ((b_size + STp->buffer->sg[i].length) <= OS_DATA_SIZE); |
4439 | b_size += STp->buffer->sg[i++].length); | 4439 | b_size += STp->buffer->sg[i++].length); |
4440 | STp->buffer->aux = (os_aux_t *) (page_address(STp->buffer->sg[i].page) + OS_DATA_SIZE - b_size); | 4440 | STp->buffer->aux = (os_aux_t *) (page_address(sg_page(&STp->buffer->sg[i])) + OS_DATA_SIZE - b_size); |
4441 | #if DEBUG | 4441 | #if DEBUG |
4442 | printk(OSST_DEB_MSG "%s:D: b_data points to %p in segment 0 at %p\n", name, | 4442 | printk(OSST_DEB_MSG "%s:D: b_data points to %p in segment 0 at %p\n", name, |
4443 | STp->buffer->b_data, page_address(STp->buffer->sg[0].page)); | 4443 | STp->buffer->b_data, page_address(STp->buffer->sg[0].page)); |
@@ -5252,25 +5252,26 @@ static int enlarge_buffer(struct osst_buffer *STbuffer, int need_dma) | |||
5252 | /* Try to allocate the first segment up to OS_DATA_SIZE and the others | 5252 | /* Try to allocate the first segment up to OS_DATA_SIZE and the others |
5253 | big enough to reach the goal (code assumes no segments in place) */ | 5253 | big enough to reach the goal (code assumes no segments in place) */ |
5254 | for (b_size = OS_DATA_SIZE, order = OSST_FIRST_ORDER; b_size >= PAGE_SIZE; order--, b_size /= 2) { | 5254 | for (b_size = OS_DATA_SIZE, order = OSST_FIRST_ORDER; b_size >= PAGE_SIZE; order--, b_size /= 2) { |
5255 | STbuffer->sg[0].page = alloc_pages(priority, order); | 5255 | struct page *page = alloc_pages(priority, order); |
5256 | |||
5256 | STbuffer->sg[0].offset = 0; | 5257 | STbuffer->sg[0].offset = 0; |
5257 | if (STbuffer->sg[0].page != NULL) { | 5258 | if (page != NULL) { |
5259 | sg_set_page(&STbuffer->sg[0], page); | ||
5258 | STbuffer->sg[0].length = b_size; | 5260 | STbuffer->sg[0].length = b_size; |
5259 | STbuffer->b_data = page_address(STbuffer->sg[0].page); | 5261 | STbuffer->b_data = page_address(page); |
5260 | break; | 5262 | break; |
5261 | } | 5263 | } |
5262 | } | 5264 | } |
5263 | if (STbuffer->sg[0].page == NULL) { | 5265 | if (sg_page(&STbuffer->sg[0]) == NULL) { |
5264 | printk(KERN_NOTICE "osst :I: Can't allocate tape buffer main segment.\n"); | 5266 | printk(KERN_NOTICE "osst :I: Can't allocate tape buffer main segment.\n"); |
5265 | return 0; | 5267 | return 0; |
5266 | } | 5268 | } |
5267 | /* Got initial segment of 'bsize,order', continue with same size if possible, except for AUX */ | 5269 | /* Got initial segment of 'bsize,order', continue with same size if possible, except for AUX */ |
5268 | for (segs=STbuffer->sg_segs=1, got=b_size; | 5270 | for (segs=STbuffer->sg_segs=1, got=b_size; |
5269 | segs < max_segs && got < OS_FRAME_SIZE; ) { | 5271 | segs < max_segs && got < OS_FRAME_SIZE; ) { |
5270 | STbuffer->sg[segs].page = | 5272 | struct page *page = alloc_pages(priority, (OS_FRAME_SIZE - got <= PAGE_SIZE) ? 0 : order); |
5271 | alloc_pages(priority, (OS_FRAME_SIZE - got <= PAGE_SIZE) ? 0 : order); | ||
5272 | STbuffer->sg[segs].offset = 0; | 5273 | STbuffer->sg[segs].offset = 0; |
5273 | if (STbuffer->sg[segs].page == NULL) { | 5274 | if (page == NULL) { |
5274 | if (OS_FRAME_SIZE - got <= (max_segs - segs) * b_size / 2 && order) { | 5275 | if (OS_FRAME_SIZE - got <= (max_segs - segs) * b_size / 2 && order) { |
5275 | b_size /= 2; /* Large enough for the rest of the buffers */ | 5276 | b_size /= 2; /* Large enough for the rest of the buffers */ |
5276 | order--; | 5277 | order--; |
@@ -5284,6 +5285,7 @@ static int enlarge_buffer(struct osst_buffer *STbuffer, int need_dma) | |||
5284 | normalize_buffer(STbuffer); | 5285 | normalize_buffer(STbuffer); |
5285 | return 0; | 5286 | return 0; |
5286 | } | 5287 | } |
5288 | sg_set_page(&STbuffer->sg[segs], page); | ||
5287 | STbuffer->sg[segs].length = (OS_FRAME_SIZE - got <= PAGE_SIZE / 2) ? (OS_FRAME_SIZE - got) : b_size; | 5289 | STbuffer->sg[segs].length = (OS_FRAME_SIZE - got <= PAGE_SIZE / 2) ? (OS_FRAME_SIZE - got) : b_size; |
5288 | got += STbuffer->sg[segs].length; | 5290 | got += STbuffer->sg[segs].length; |
5289 | STbuffer->buffer_size = got; | 5291 | STbuffer->buffer_size = got; |
@@ -5316,7 +5318,7 @@ static void normalize_buffer(struct osst_buffer *STbuffer) | |||
5316 | b_size < STbuffer->sg[i].length; | 5318 | b_size < STbuffer->sg[i].length; |
5317 | b_size *= 2, order++); | 5319 | b_size *= 2, order++); |
5318 | 5320 | ||
5319 | __free_pages(STbuffer->sg[i].page, order); | 5321 | __free_pages(sg_page(&STbuffer->sg[i]), order); |
5320 | STbuffer->buffer_size -= STbuffer->sg[i].length; | 5322 | STbuffer->buffer_size -= STbuffer->sg[i].length; |
5321 | } | 5323 | } |
5322 | #if DEBUG | 5324 | #if DEBUG |
@@ -5344,7 +5346,7 @@ static int append_to_buffer(const char __user *ubp, struct osst_buffer *st_bp, i | |||
5344 | for ( ; i < st_bp->sg_segs && do_count > 0; i++) { | 5346 | for ( ; i < st_bp->sg_segs && do_count > 0; i++) { |
5345 | cnt = st_bp->sg[i].length - offset < do_count ? | 5347 | cnt = st_bp->sg[i].length - offset < do_count ? |
5346 | st_bp->sg[i].length - offset : do_count; | 5348 | st_bp->sg[i].length - offset : do_count; |
5347 | res = copy_from_user(page_address(st_bp->sg[i].page) + offset, ubp, cnt); | 5349 | res = copy_from_user(page_address(sg_page(&st_bp->sg[i])) + offset, ubp, cnt); |
5348 | if (res) | 5350 | if (res) |
5349 | return (-EFAULT); | 5351 | return (-EFAULT); |
5350 | do_count -= cnt; | 5352 | do_count -= cnt; |
@@ -5377,7 +5379,7 @@ static int from_buffer(struct osst_buffer *st_bp, char __user *ubp, int do_count | |||
5377 | for ( ; i < st_bp->sg_segs && do_count > 0; i++) { | 5379 | for ( ; i < st_bp->sg_segs && do_count > 0; i++) { |
5378 | cnt = st_bp->sg[i].length - offset < do_count ? | 5380 | cnt = st_bp->sg[i].length - offset < do_count ? |
5379 | st_bp->sg[i].length - offset : do_count; | 5381 | st_bp->sg[i].length - offset : do_count; |
5380 | res = copy_to_user(ubp, page_address(st_bp->sg[i].page) + offset, cnt); | 5382 | res = copy_to_user(ubp, page_address(sg_page(&st_bp->sg[i])) + offset, cnt); |
5381 | if (res) | 5383 | if (res) |
5382 | return (-EFAULT); | 5384 | return (-EFAULT); |
5383 | do_count -= cnt; | 5385 | do_count -= cnt; |
@@ -5410,7 +5412,7 @@ static int osst_zero_buffer_tail(struct osst_buffer *st_bp) | |||
5410 | i < st_bp->sg_segs && do_count > 0; i++) { | 5412 | i < st_bp->sg_segs && do_count > 0; i++) { |
5411 | cnt = st_bp->sg[i].length - offset < do_count ? | 5413 | cnt = st_bp->sg[i].length - offset < do_count ? |
5412 | st_bp->sg[i].length - offset : do_count ; | 5414 | st_bp->sg[i].length - offset : do_count ; |
5413 | memset(page_address(st_bp->sg[i].page) + offset, 0, cnt); | 5415 | memset(page_address(sg_page(&st_bp->sg[i])) + offset, 0, cnt); |
5414 | do_count -= cnt; | 5416 | do_count -= cnt; |
5415 | offset = 0; | 5417 | offset = 0; |
5416 | } | 5418 | } |
@@ -5430,7 +5432,7 @@ static int osst_copy_to_buffer(struct osst_buffer *st_bp, unsigned char *ptr) | |||
5430 | for (i = 0; i < st_bp->sg_segs && do_count > 0; i++) { | 5432 | for (i = 0; i < st_bp->sg_segs && do_count > 0; i++) { |
5431 | cnt = st_bp->sg[i].length < do_count ? | 5433 | cnt = st_bp->sg[i].length < do_count ? |
5432 | st_bp->sg[i].length : do_count ; | 5434 | st_bp->sg[i].length : do_count ; |
5433 | memcpy(page_address(st_bp->sg[i].page), ptr, cnt); | 5435 | memcpy(page_address(sg_page(&st_bp->sg[i])), ptr, cnt); |
5434 | do_count -= cnt; | 5436 | do_count -= cnt; |
5435 | ptr += cnt; | 5437 | ptr += cnt; |
5436 | } | 5438 | } |
@@ -5451,7 +5453,7 @@ static int osst_copy_from_buffer(struct osst_buffer *st_bp, unsigned char *ptr) | |||
5451 | for (i = 0; i < st_bp->sg_segs && do_count > 0; i++) { | 5453 | for (i = 0; i < st_bp->sg_segs && do_count > 0; i++) { |
5452 | cnt = st_bp->sg[i].length < do_count ? | 5454 | cnt = st_bp->sg[i].length < do_count ? |
5453 | st_bp->sg[i].length : do_count ; | 5455 | st_bp->sg[i].length : do_count ; |
5454 | memcpy(ptr, page_address(st_bp->sg[i].page), cnt); | 5456 | memcpy(ptr, page_address(sg_page(&st_bp->sg[i])), cnt); |
5455 | do_count -= cnt; | 5457 | do_count -= cnt; |
5456 | ptr += cnt; | 5458 | ptr += cnt; |
5457 | } | 5459 | } |