From: Andi Kleen <andi@firstfloor.org>
To: linux-scsi@vger.kernel.org,
James.Bottomley@HansenPartnership.com, axboe@kernel.dk
Subject: [PATCH] [11/21] SCSI-ISA-DMA: Remove GFP_DMA uses in st/osst
Date: Thu, 2 Oct 2008 09:58:49 +0200 (CEST) [thread overview]
Message-ID: <20081002075849.4D7643E6A09@basil.firstfloor.org> (raw)
In-Reply-To: <20081002958.641114646@firstfloor.org>
Parts of it were already dead code: the ->dma member was only set, but not read.
Then also remove the code to allocate buffers with GFP_DMA, because this
goes all through the block layer which bounces anyways.
Also remove code to disable direct sg for unchecked_isa_dma
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Andi Kleen <andi@firstfloor.org>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
drivers/scsi/osst.c | 24 ++++++++++--------------
drivers/scsi/osst.h | 2 --
drivers/scsi/st.c | 35 ++++++++++++++++-------------------
drivers/scsi/st.h | 2 --
4 files changed, 26 insertions(+), 37 deletions(-)
Index: linux/drivers/scsi/osst.c
===================================================================
--- linux.orig/drivers/scsi/osst.c
+++ linux/drivers/scsi/osst.c
@@ -158,8 +158,8 @@ static DEFINE_RWLOCK(os_scsi_tapes_lock)
static int modes_defined = 0;
-static struct osst_buffer *new_tape_buffer(int, int, int);
-static int enlarge_buffer(struct osst_buffer *, int);
+static struct osst_buffer *new_tape_buffer(int, int);
+static int enlarge_buffer(struct osst_buffer *);
static void normalize_buffer(struct osst_buffer *);
static int append_to_buffer(const char __user *, struct osst_buffer *, int);
static int from_buffer(struct osst_buffer *, char __user *, int);
@@ -4431,7 +4431,7 @@ static int __os_scsi_tape_open(struct in
STp->header_ok = 0;
/* Allocate data segments for this device's tape buffer */
- if (!enlarge_buffer(STp->buffer, STp->restr_dma)) {
+ if (!enlarge_buffer(STp->buffer)) {
printk(KERN_ERR "%s:E: Unable to allocate memory segments for tape buffer.\n", name);
retval = (-EOVERFLOW);
goto err_out;
@@ -5210,7 +5210,7 @@ static long osst_compat_ioctl(struct fil
/* Memory handling routines */
/* Try to allocate a new tape buffer skeleton. Caller must not hold os_scsi_tapes_lock */
-static struct osst_buffer * new_tape_buffer( int from_initialization, int need_dma, int max_sg )
+static struct osst_buffer * new_tape_buffer( int from_initialization, int max_sg )
{
int i;
gfp_t priority;
@@ -5231,19 +5231,18 @@ static struct osst_buffer * new_tape_buf
tb->sg_segs = tb->orig_sg_segs = 0;
tb->use_sg = max_sg;
tb->in_use = 1;
- tb->dma = need_dma;
tb->buffer_size = 0;
#if DEBUG
if (debugging)
printk(OSST_DEB_MSG
- "osst :D: Allocated tape buffer skeleton (%d bytes, %d segments, dma: %d).\n",
- i, max_sg, need_dma);
+ "osst :D: Allocated tape buffer skeleton (%d bytes, %d segments).\n",
+ i, max_sg);
#endif
return tb;
}
/* Try to allocate a temporary (while a user has the device open) enlarged tape buffer */
-static int enlarge_buffer(struct osst_buffer *STbuffer, int need_dma)
+static int enlarge_buffer(struct osst_buffer *STbuffer)
{
int segs, nbr, max_segs, b_size, order, got;
gfp_t priority;
@@ -5261,8 +5260,6 @@ static int enlarge_buffer(struct osst_bu
return 0;
priority = GFP_KERNEL /* | __GFP_NOWARN */;
- if (need_dma)
- priority |= GFP_DMA;
/* Try to allocate the first segment up to OS_DATA_SIZE and the others
big enough to reach the goal (code assumes no segments in place) */
@@ -5307,8 +5304,8 @@ static int enlarge_buffer(struct osst_bu
#if DEBUG
if (debugging) {
printk(OSST_DEB_MSG
- "osst :D: Expanded tape buffer (%d bytes, %d->%d segments, dma: %d, at: %p).\n",
- got, STbuffer->orig_sg_segs, STbuffer->sg_segs, need_dma, STbuffer->b_data);
+ "osst :D: Expanded tape buffer (%d bytes, %d->%d segments, at: %p).\n",
+ got, STbuffer->orig_sg_segs, STbuffer->sg_segs, STbuffer->b_data);
printk(OSST_DEB_MSG
"osst :D: segment sizes: first %d at %p, last %d bytes at %p.\n",
STbuffer->sg[0].length, page_address(STbuffer->sg[0].page),
@@ -5805,7 +5802,7 @@ static int osst_probe(struct device *dev
i = SDp->host->sg_tablesize;
if (osst_max_sg_segs < i)
i = osst_max_sg_segs;
- buffer = new_tape_buffer(1, SDp->host->unchecked_isa_dma, i);
+ buffer = new_tape_buffer(1, i);
if (buffer == NULL) {
write_unlock(&os_scsi_tapes_lock);
printk(KERN_ERR "osst :E: Unable to allocate a tape buffer, device not attached.\n");
@@ -5823,7 +5820,6 @@ static int osst_probe(struct device *dev
tpnt->capacity = 0xfffff;
tpnt->dirty = 0;
tpnt->drv_buffer = 1; /* Try buffering if no mode sense */
- tpnt->restr_dma = (SDp->host)->unchecked_isa_dma;
tpnt->density = 0;
tpnt->do_auto_lock = OSST_AUTO_LOCK;
tpnt->can_bsr = OSST_IN_FILE_POS;
Index: linux/drivers/scsi/osst.h
===================================================================
--- linux.orig/drivers/scsi/osst.h
+++ linux/drivers/scsi/osst.h
@@ -510,7 +510,6 @@ typedef struct os_header_s {
/* The OnStream tape buffer descriptor. */
struct osst_buffer {
unsigned char in_use;
- unsigned char dma; /* DMA-able buffer */
int buffer_size;
int buffer_blocks;
int buffer_bytes;
@@ -544,7 +543,6 @@ struct osst_tape {
unsigned char can_partitions;
unsigned char two_fm;
unsigned char fast_mteom;
- unsigned char restr_dma;
unsigned char scsi2_logical;
unsigned char default_drvbuffer; /* 0xff = don't touch, value 3 bits */
unsigned char pos_unknown; /* after reset position unknown */
Index: linux/drivers/scsi/st.c
===================================================================
--- linux.orig/drivers/scsi/st.c
+++ linux/drivers/scsi/st.c
@@ -182,8 +182,8 @@ static struct scsi_tape **scsi_tapes = N
static int modes_defined;
-static struct st_buffer *new_tape_buffer(int, int, int);
-static int enlarge_buffer(struct st_buffer *, int, int);
+static struct st_buffer *new_tape_buffer(int, int);
+static int enlarge_buffer(struct scsi_tape *t, struct st_buffer *, int);
static void clear_buffer(struct st_buffer *);
static void normalize_buffer(struct st_buffer *);
static int append_to_buffer(const char __user *, struct st_buffer *, int);
@@ -1155,7 +1155,7 @@ static int st_open(struct inode *inode,
}
/* See that we have at least a one page buffer available */
- if (!enlarge_buffer(STp->buffer, PAGE_SIZE, STp->restr_dma)) {
+ if (!enlarge_buffer(STp, STp->buffer, PAGE_SIZE)) {
printk(KERN_WARNING "%s: Can't allocate one page tape buffer.\n",
name);
retval = (-EOVERFLOW);
@@ -1447,7 +1447,7 @@ static int setup_buffering(struct scsi_t
}
if (bufsize > STbp->buffer_size &&
- !enlarge_buffer(STbp, bufsize, STp->restr_dma)) {
+ !enlarge_buffer(STp, STbp, bufsize)) {
printk(KERN_WARNING "%s: Can't allocate %d byte tape buffer.\n",
tape_name(STp), bufsize);
retval = (-EOVERFLOW);
@@ -3605,7 +3605,7 @@ static long st_compat_ioctl(struct file
/* Try to allocate a new tape buffer. Calling function must not hold
dev_arr_lock. */
static struct st_buffer *
- new_tape_buffer(int from_initialization, int need_dma, int max_sg)
+ new_tape_buffer(int from_initialization, int max_sg)
{
int i, got = 0;
gfp_t priority;
@@ -3627,7 +3627,6 @@ static struct st_buffer *
tb->use_sg = max_sg;
tb->frp = (struct st_buf_fragment *)(&(tb->sg[0]) + max_sg);
- tb->dma = need_dma;
tb->buffer_size = got;
sg_init_table(tb->sg, max_sg);
@@ -3636,9 +3635,11 @@ static struct st_buffer *
/* Try to allocate enough space in the tape buffer */
-static int enlarge_buffer(struct st_buffer * STbuffer, int new_size, int need_dma)
+static int enlarge_buffer(struct scsi_tape *t, struct st_buffer * STbuffer,
+ int new_size)
{
- int segs, nbr, max_segs, b_size, order, got;
+ struct request_queue *q = t->device->request_queue;
+ int segs, nbr, max_segs, b_size, got;
gfp_t priority;
if (new_size <= STbuffer->buffer_size)
@@ -3653,20 +3654,18 @@ static int enlarge_buffer(struct st_buff
return 0;
priority = GFP_KERNEL | __GFP_NOWARN;
- if (need_dma)
- priority |= GFP_DMA;
- for (b_size = PAGE_SIZE, order=0; order <= 6 &&
+ for (b_size = PAGE_SIZE; b_size <= (PAGE_SIZE << 6) &&
b_size < new_size - STbuffer->buffer_size;
- order++, b_size *= 2)
+ b_size *= 2)
; /* empty */
for (segs = STbuffer->frp_segs, got = STbuffer->buffer_size;
segs < max_segs && got < new_size;) {
- STbuffer->frp[segs].page = alloc_pages(priority, order);
+ STbuffer->frp[segs].page = alloc_pages_mask(priority,
+ b_size, blk_q_mask(q));
if (STbuffer->frp[segs].page == NULL) {
if (new_size - got <= (max_segs - segs) * b_size / 2) {
b_size /= 2; /* Large enough for the rest of the buffers */
- order--;
continue;
}
DEB(STbuffer->buffer_size = got);
@@ -3701,11 +3700,10 @@ static void clear_buffer(struct st_buffe
/* Release the extra buffer */
static void normalize_buffer(struct st_buffer * STbuffer)
{
- int i, order;
+ int i;
for (i = STbuffer->orig_frp_segs; i < STbuffer->frp_segs; i++) {
- order = get_order(STbuffer->frp[i].length);
- __free_pages(STbuffer->frp[i].page, order);
+ __free_pages_mask(STbuffer->frp[i].page, STbuffer->frp[i].length);
STbuffer->buffer_size -= STbuffer->frp[i].length;
}
STbuffer->frp_segs = STbuffer->orig_frp_segs;
@@ -3934,7 +3932,7 @@ static int st_probe(struct device *dev)
SDp->request_queue->max_phys_segments);
if (st_max_sg_segs < i)
i = st_max_sg_segs;
- buffer = new_tape_buffer(1, (SDp->host)->unchecked_isa_dma, i);
+ buffer = new_tape_buffer(1, i);
if (buffer == NULL) {
printk(KERN_ERR
"st: Can't allocate new tape buffer. Device not attached.\n");
@@ -4013,7 +4011,6 @@ static int st_probe(struct device *dev)
tpnt->dirty = 0;
tpnt->in_use = 0;
tpnt->drv_buffer = 1; /* Try buffering if no mode sense */
- tpnt->restr_dma = (SDp->host)->unchecked_isa_dma;
tpnt->use_pf = (SDp->scsi_level >= SCSI_2);
tpnt->density = 0;
tpnt->do_auto_lock = ST_AUTO_LOCK;
Index: linux/drivers/scsi/st.h
===================================================================
--- linux.orig/drivers/scsi/st.h
+++ linux/drivers/scsi/st.h
@@ -33,7 +33,6 @@ struct st_request {
/* The tape buffer descriptor. */
struct st_buffer {
- unsigned char dma; /* DMA-able buffer */
unsigned char do_dio; /* direct i/o set up? */
unsigned char cleared; /* internal buffer cleared after open? */
int buffer_size;
@@ -113,7 +112,6 @@ struct scsi_tape {
unsigned char two_fm;
unsigned char fast_mteom;
unsigned char immediate;
- unsigned char restr_dma;
unsigned char scsi2_logical;
unsigned char default_drvbuffer; /* 0xff = don't touch, value 3 bits */
unsigned char cln_mode; /* 0 = none, otherwise sense byte nbr */
next prev parent reply other threads:[~2008-10-02 7:58 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-02 7:58 [PATCH] [0/21] Remove SCSI unchecked_isa_dma try 3 Andi Kleen
2008-10-02 7:58 ` [PATCH] [1/21] SCSI-ISA-DMA: Add the alloc/get_pages_mask calls Andi Kleen
2008-10-02 7:58 ` [PATCH] [2/21] SCSI-ISA-DMA: Add blk_q_mask Andi Kleen
2008-10-02 7:58 ` [PATCH] [3/21] SCSI-ISA-DMA: Pass gfp to scsi_allocate_command Andi Kleen
2008-10-02 7:58 ` [PATCH] [4/21] SCSI-ISA-DMA: Add sense_buffer_isa to host template Andi Kleen
2008-10-02 7:58 ` [PATCH] [5/21] SCSI-ISA-DMA: Remove unchecked_isa in BusLogic Andi Kleen
2008-10-02 7:58 ` [PATCH] [6/21] SCSI-ISA-DMA: Remove unchecked_isa_dma in advansys.c Andi Kleen
2008-10-02 7:58 ` [PATCH] [7/21] SCSI-ISA-DMA: Remove unchecked_isa_dma in gdth Andi Kleen
2008-10-02 7:58 ` [PATCH] [8/21] SCSI-ISA-DMA: Remove unchecked_isa_dma in eata.c Andi Kleen
2008-10-02 7:58 ` [PATCH] [9/21] SCSI-ISA-DMA: Remove unchecked_isa_dma in aha1542 Andi Kleen
2008-10-02 7:58 ` [PATCH] [10/21] SCSI-ISA-DMA: Remove unchecked_isa_dma in aha152x/wd7000/sym53c416/u14-34f/NCR53c406a Andi Kleen
2008-10-02 7:58 ` Andi Kleen [this message]
2008-10-02 7:58 ` [PATCH] [12/21] SCSI-ISA-DMA: Remove unchecked_isa_dma support for hostdata Andi Kleen
2008-10-02 7:58 ` [PATCH] [13/21] SCSI-ISA-DMA: Use blk_q_mask/get_pages_mask in sg driver Andi Kleen
2008-10-02 7:58 ` [PATCH] [14/21] SCSI-ISA-DMA: Rely on block layer bouncing for ISA DMA devices scanning Andi Kleen
2008-10-02 7:58 ` [PATCH] [15/21] SCSI-ISA-DMA: Don't disable direct_io for unchecked_isa_dma in st.c Andi Kleen
2008-10-02 7:58 ` [PATCH] [16/21] SCSI-ISA-DMA: Remove automatic block layer bouncing for unchecked_isa_dma Andi Kleen
2008-10-02 7:58 ` [PATCH] [17/21] SCSI-ISA-DMA: Remove GFP_DMA use in sr.c Andi Kleen
2008-10-02 7:58 ` [PATCH] [18/21] SCSI-ISA-DMA: Remove unchecked_isa_dma from sysfs Andi Kleen
2008-10-02 7:58 ` [PATCH] [19/21] SCSI-ISA-DMA: Switch to a single SCSI command pool Andi Kleen
2008-10-02 7:58 ` [PATCH] [20/21] SCSI-ISA-DMA: Finally kill unchecked_isa_dma Andi Kleen
2008-10-02 7:58 ` [PATCH] [21/21] SCSI-ISA-DMA: Convert DMA buffers in ch.c to allocate via the block layer Andi Kleen
2008-10-07 23:53 ` [PATCH] [0/21] Remove SCSI unchecked_isa_dma try 3 Andi Kleen
2008-10-08 10:21 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081002075849.4D7643E6A09@basil.firstfloor.org \
--to=andi@firstfloor.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=axboe@kernel.dk \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox