diff options
Diffstat (limited to 'drivers/scsi/st.c')
-rw-r--r-- | drivers/scsi/st.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index ddf2630b347..c6f19ee8f2c 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c | |||
@@ -3695,6 +3695,8 @@ static struct st_buffer *new_tape_buffer(int need_dma, int max_sg) | |||
3695 | 3695 | ||
3696 | 3696 | ||
3697 | /* Try to allocate enough space in the tape buffer */ | 3697 | /* Try to allocate enough space in the tape buffer */ |
3698 | #define ST_MAX_ORDER 6 | ||
3699 | |||
3698 | static int enlarge_buffer(struct st_buffer * STbuffer, int new_size, int need_dma) | 3700 | static int enlarge_buffer(struct st_buffer * STbuffer, int new_size, int need_dma) |
3699 | { | 3701 | { |
3700 | int segs, nbr, max_segs, b_size, order, got; | 3702 | int segs, nbr, max_segs, b_size, order, got; |
@@ -3723,9 +3725,16 @@ static int enlarge_buffer(struct st_buffer * STbuffer, int new_size, int need_dm | |||
3723 | b_size = PAGE_SIZE << order; | 3725 | b_size = PAGE_SIZE << order; |
3724 | } else { | 3726 | } else { |
3725 | for (b_size = PAGE_SIZE, order = 0; | 3727 | for (b_size = PAGE_SIZE, order = 0; |
3726 | order <= 6 && b_size < new_size; order++, b_size *= 2) | 3728 | order < ST_MAX_ORDER && b_size < new_size; |
3729 | order++, b_size *= 2) | ||
3727 | ; /* empty */ | 3730 | ; /* empty */ |
3728 | } | 3731 | } |
3732 | if (max_segs * (PAGE_SIZE << order) < new_size) { | ||
3733 | if (order == ST_MAX_ORDER) | ||
3734 | return 0; | ||
3735 | normalize_buffer(STbuffer); | ||
3736 | return enlarge_buffer(STbuffer, new_size, need_dma); | ||
3737 | } | ||
3729 | 3738 | ||
3730 | for (segs = STbuffer->frp_segs, got = STbuffer->buffer_size; | 3739 | for (segs = STbuffer->frp_segs, got = STbuffer->buffer_size; |
3731 | segs < max_segs && got < new_size;) { | 3740 | segs < max_segs && got < new_size;) { |