aboutsummaryrefslogtreecommitdiff
path: root/sys/cam
diff options
context:
space:
mode:
authorAlexander Motin <mav@FreeBSD.org>2013-10-24 14:05:44 +0000
committerAlexander Motin <mav@FreeBSD.org>2013-10-24 14:05:44 +0000
commit030844d1e7a23932f906703ac27a087a7c975e18 (patch)
treeef710dcd0c0288ef94b87a656322486540cdc6fd /sys/cam
parent62940ea951c273780217d7540ba4aa5c4ca0e359 (diff)
downloadsrc-030844d1e7a23932f906703ac27a087a7c975e18.tar.gz
src-030844d1e7a23932f906703ac27a087a7c975e18.zip
Some microoptimizations for da and ada drivers:
- Replace ordered_tag_count counter with single flag; - From da remove outstanding_cmds counter, duplicating pending_ccbs list; - From da_softc remove unused links field.
Notes
Notes: svn path=/head/; revision=257054
Diffstat (limited to 'sys/cam')
-rw-r--r--sys/cam/ata/ata_da.c24
-rw-r--r--sys/cam/scsi/scsi_da.c38
2 files changed, 21 insertions, 41 deletions
diff --git a/sys/cam/ata/ata_da.c b/sys/cam/ata/ata_da.c
index 24cc8f4dd71d..c30be2d81132 100644
--- a/sys/cam/ata/ata_da.c
+++ b/sys/cam/ata/ata_da.c
@@ -80,7 +80,7 @@ typedef enum {
ADA_FLAG_CAN_NCQ = 0x0008,
ADA_FLAG_CAN_DMA = 0x0010,
ADA_FLAG_NEED_OTAG = 0x0020,
- ADA_FLAG_WENT_IDLE = 0x0040,
+ ADA_FLAG_WAS_OTAG = 0x0040,
ADA_FLAG_CAN_TRIM = 0x0080,
ADA_FLAG_OPEN = 0x0100,
ADA_FLAG_SCTX_INIT = 0x0200,
@@ -130,12 +130,12 @@ struct trim_request {
struct ada_softc {
struct bio_queue_head bio_queue;
struct bio_queue_head trim_queue;
+ int outstanding_cmds; /* Number of active commands */
+ int refcount; /* Active xpt_action() calls */
ada_state state;
- ada_flags flags;
+ ada_flags flags;
ada_quirks quirks;
int sort_io_queue;
- int ordered_tag_count;
- int outstanding_cmds;
int trim_max_ranges;
int trim_running;
int read_ahead;
@@ -153,7 +153,6 @@ struct ada_softc {
struct sysctl_oid *sysctl_tree;
struct callout sendordered_c;
struct trim_request trim_req;
- int refcount;
};
struct ada_quirk_entry {
@@ -1489,7 +1488,7 @@ adastart(struct cam_periph *periph, union ccb *start_ccb)
if ((bp->bio_flags & BIO_ORDERED) != 0
|| (softc->flags & ADA_FLAG_NEED_OTAG) != 0) {
softc->flags &= ~ADA_FLAG_NEED_OTAG;
- softc->ordered_tag_count++;
+ softc->flags |= ADA_FLAG_WAS_OTAG;
tag_code = 0;
} else {
tag_code = 1;
@@ -1743,7 +1742,7 @@ adadone(struct cam_periph *periph, union ccb *done_ccb)
}
softc->outstanding_cmds--;
if (softc->outstanding_cmds == 0)
- softc->flags |= ADA_FLAG_WENT_IDLE;
+ softc->flags |= ADA_FLAG_WAS_OTAG;
xpt_release_ccb(done_ccb);
if (state == ADA_CCB_TRIM) {
TAILQ_HEAD(, bio) queue;
@@ -1905,14 +1904,11 @@ adasendorderedtag(void *arg)
struct ada_softc *softc = arg;
if (ada_send_ordered) {
- if ((softc->ordered_tag_count == 0)
- && ((softc->flags & ADA_FLAG_WENT_IDLE) == 0)) {
- softc->flags |= ADA_FLAG_NEED_OTAG;
+ if (softc->outstanding_cmds > 0) {
+ if ((softc->flags & ADA_FLAG_WAS_OTAG) == 0)
+ softc->flags |= ADA_FLAG_NEED_OTAG;
+ softc->flags &= ~ADA_FLAG_WAS_OTAG;
}
- if (softc->outstanding_cmds > 0)
- softc->flags &= ~ADA_FLAG_WENT_IDLE;
-
- softc->ordered_tag_count = 0;
}
/* Queue us up again */
callout_reset(&softc->sendordered_c,
diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c
index 7c5941d04445..980282d6fee6 100644
--- a/sys/cam/scsi/scsi_da.c
+++ b/sys/cam/scsi/scsi_da.c
@@ -84,7 +84,7 @@ typedef enum {
DA_FLAG_PACK_LOCKED = 0x004,
DA_FLAG_PACK_REMOVABLE = 0x008,
DA_FLAG_NEED_OTAG = 0x020,
- DA_FLAG_WENT_IDLE = 0x040,
+ DA_FLAG_WAS_OTAG = 0x040,
DA_FLAG_RETRY_UA = 0x080,
DA_FLAG_OPEN = 0x100,
DA_FLAG_SCTX_INIT = 0x200,
@@ -198,19 +198,17 @@ struct da_softc {
struct bio_queue_head bio_queue;
struct bio_queue_head delete_queue;
struct bio_queue_head delete_run_queue;
- SLIST_ENTRY(da_softc) links;
LIST_HEAD(, ccb_hdr) pending_ccbs;
+ int tur; /* TEST UNIT READY should be sent */
+ int refcount; /* Active xpt_action() calls */
da_state state;
da_flags flags;
da_quirks quirks;
int sort_io_queue;
int minimum_cmd_size;
int error_inject;
- int ordered_tag_count;
- int outstanding_cmds;
int trim_max_ranges;
int delete_running;
- int tur;
int delete_available; /* Delete methods possibly available */
uint32_t unmap_max_ranges;
uint32_t unmap_max_lba;
@@ -228,7 +226,6 @@ struct da_softc {
uint8_t unmap_buf[UNMAP_BUF_SIZE];
struct scsi_read_capacity_data_long rcaplong;
struct callout mediapoll_c;
- int refcount;
};
#define dadeleteflag(softc, delete_method, enable) \
@@ -2244,7 +2241,7 @@ skipstate:
if ((bp->bio_flags & BIO_ORDERED) != 0 ||
(softc->flags & DA_FLAG_NEED_OTAG) != 0) {
softc->flags &= ~DA_FLAG_NEED_OTAG;
- softc->ordered_tag_count++;
+ softc->flags |= DA_FLAG_WAS_OTAG;
tag_code = MSG_ORDERED_Q_TAG;
} else {
tag_code = MSG_SIMPLE_Q_TAG;
@@ -2297,13 +2294,8 @@ skipstate:
start_ccb->ccb_h.flags |= CAM_UNLOCKED;
out:
- /*
- * Block out any asynchronous callbacks
- * while we touch the pending ccb list.
- */
LIST_INSERT_HEAD(&softc->pending_ccbs,
&start_ccb->ccb_h, periph_links.le);
- softc->outstanding_cmds++;
/* We expect a unit attention from this device */
if ((softc->flags & DA_FLAG_RETRY_UA) != 0) {
@@ -2969,14 +2961,9 @@ dadone(struct cam_periph *periph, union ccb *done_ccb)
}
}
- /*
- * Block out any asynchronous callbacks
- * while we touch the pending ccb list.
- */
LIST_REMOVE(&done_ccb->ccb_h, periph_links.le);
- softc->outstanding_cmds--;
- if (softc->outstanding_cmds == 0)
- softc->flags |= DA_FLAG_WENT_IDLE;
+ if (LIST_EMPTY(&softc->pending_ccbs))
+ softc->flags |= DA_FLAG_WAS_OTAG;
xpt_release_ccb(done_ccb);
if (state == DA_CCB_DELETE) {
@@ -3583,7 +3570,7 @@ damediapoll(void *arg)
struct cam_periph *periph = arg;
struct da_softc *softc = periph->softc;
- if (!softc->tur && softc->outstanding_cmds == 0) {
+ if (!softc->tur && LIST_EMPTY(&softc->pending_ccbs)) {
if (cam_periph_acquire(periph) == CAM_REQ_CMP) {
softc->tur = 1;
daschedule(periph);
@@ -3755,14 +3742,11 @@ dasendorderedtag(void *arg)
struct da_softc *softc = arg;
if (da_send_ordered) {
- if ((softc->ordered_tag_count == 0)
- && ((softc->flags & DA_FLAG_WENT_IDLE) == 0)) {
- softc->flags |= DA_FLAG_NEED_OTAG;
+ if (!LIST_EMPTY(&softc->pending_ccbs)) {
+ if ((softc->flags & DA_FLAG_WAS_OTAG) == 0)
+ softc->flags |= DA_FLAG_NEED_OTAG;
+ softc->flags &= ~DA_FLAG_WAS_OTAG;
}
- if (softc->outstanding_cmds > 0)
- softc->flags &= ~DA_FLAG_WENT_IDLE;
-
- softc->ordered_tag_count = 0;
}
/* Queue us up again */
callout_reset(&softc->sendordered_c,