From owner-svn-src-all@FreeBSD.ORG Sat May 12 13:55:37 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7EE0E106573A; Sat, 12 May 2012 13:55:37 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5F6578FC0A; Sat, 12 May 2012 13:55:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q4CDtbw9036776; Sat, 12 May 2012 13:55:37 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q4CDtbaD036768; Sat, 12 May 2012 13:55:37 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201205121355.q4CDtbaD036768@svn.freebsd.org> From: Alexander Motin Date: Sat, 12 May 2012 13:55:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235333 - in head/sys: cam dev/ahci dev/ata dev/mvs dev/siis X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 May 2012 13:55:37 -0000 Author: mav Date: Sat May 12 13:55:36 2012 New Revision: 235333 URL: http://svn.freebsd.org/changeset/base/235333 Log: Add two functions xpt_batch_start() and xpt_batch_done() to the CAM SIM KPI to allow drivers to handle request completion directly without passing them to the CAM SWI thread removing extra context switch. Modify all ATA/SATA drivers to use them. Reviewed by: gibbs, ken MFC after: 2 weeks Modified: head/sys/cam/cam_sim.h head/sys/cam/cam_xpt.c head/sys/cam/cam_xpt_sim.h head/sys/dev/ahci/ahci.c head/sys/dev/ata/ata-all.c head/sys/dev/mvs/mvs.c head/sys/dev/siis/siis.c Modified: head/sys/cam/cam_sim.h ============================================================================== --- head/sys/cam/cam_sim.h Sat May 12 12:02:51 2012 (r235332) +++ head/sys/cam/cam_sim.h Sat May 12 13:55:36 2012 (r235333) @@ -106,6 +106,7 @@ struct cam_sim { #define CAM_SIM_MPSAFE 0x02 #define CAM_SIM_ON_DONEQ 0x04 #define CAM_SIM_POLLED 0x08 +#define CAM_SIM_BATCH 0x10 struct callout callout; struct cam_devq *devq; /* Device Queue to use for this SIM */ int refcount; /* References to the SIM. */ Modified: head/sys/cam/cam_xpt.c ============================================================================== --- head/sys/cam/cam_xpt.c Sat May 12 12:02:51 2012 (r235332) +++ head/sys/cam/cam_xpt.c Sat May 12 13:55:36 2012 (r235333) @@ -4332,7 +4332,8 @@ xpt_done(union ccb *done_ccb) TAILQ_INSERT_TAIL(&sim->sim_doneq, &done_ccb->ccb_h, sim_links.tqe); done_ccb->ccb_h.pinfo.index = CAM_DONEQ_INDEX; - if ((sim->flags & (CAM_SIM_ON_DONEQ | CAM_SIM_POLLED)) == 0) { + if ((sim->flags & (CAM_SIM_ON_DONEQ | CAM_SIM_POLLED | + CAM_SIM_BATCH)) == 0) { mtx_lock(&cam_simq_lock); first = TAILQ_EMPTY(&cam_simq); TAILQ_INSERT_TAIL(&cam_simq, sim, links); @@ -4344,6 +4345,25 @@ xpt_done(union ccb *done_ccb) } } +void +xpt_batch_start(struct cam_sim *sim) +{ + + KASSERT((sim->flags & CAM_SIM_BATCH) == 0, ("Batch flag already set")); + sim->flags |= CAM_SIM_BATCH; +} + +void +xpt_batch_done(struct cam_sim *sim) +{ + + KASSERT((sim->flags & CAM_SIM_BATCH) != 0, ("Batch flag was not set")); + sim->flags &= ~CAM_SIM_BATCH; + if (!TAILQ_EMPTY(&sim->sim_doneq) && + (sim->flags & CAM_SIM_ON_DONEQ) == 0) + camisr_runqueue(&sim->sim_doneq); +} + union ccb * xpt_alloc_ccb() { Modified: head/sys/cam/cam_xpt_sim.h ============================================================================== --- head/sys/cam/cam_xpt_sim.h Sat May 12 12:02:51 2012 (r235332) +++ head/sys/cam/cam_xpt_sim.h Sat May 12 13:55:36 2012 (r235333) @@ -51,6 +51,8 @@ void xpt_release_devq_rl(struct cam_pat u_int count, int run_queue); int xpt_sim_opened(struct cam_sim *sim); void xpt_done(union ccb *done_ccb); +void xpt_batch_start(struct cam_sim *sim); +void xpt_batch_done(struct cam_sim *sim); #endif #endif /* _CAM_CAM_XPT_SIM_H */ Modified: head/sys/dev/ahci/ahci.c ============================================================================== --- head/sys/dev/ahci/ahci.c Sat May 12 12:02:51 2012 (r235332) +++ head/sys/dev/ahci/ahci.c Sat May 12 13:55:36 2012 (r235333) @@ -1457,7 +1457,9 @@ ahci_ch_intr_locked(void *data) struct ahci_channel *ch = device_get_softc(dev); mtx_lock(&ch->mtx); + xpt_batch_start(ch->sim); ahci_ch_intr(data); + xpt_batch_done(ch->sim); mtx_unlock(&ch->mtx); } Modified: head/sys/dev/ata/ata-all.c ============================================================================== --- head/sys/dev/ata/ata-all.c Sat May 12 12:02:51 2012 (r235332) +++ head/sys/dev/ata/ata-all.c Sat May 12 13:55:36 2012 (r235333) @@ -544,9 +544,11 @@ ata_interrupt(void *data) struct ata_channel *ch = (struct ata_channel *)data; mtx_lock(&ch->state_mtx); + xpt_batch_start(ch->sim); #endif ata_interrupt_locked(data); #ifdef ATA_CAM + xpt_batch_done(ch->sim); mtx_unlock(&ch->state_mtx); #endif } Modified: head/sys/dev/mvs/mvs.c ============================================================================== --- head/sys/dev/mvs/mvs.c Sat May 12 12:02:51 2012 (r235332) +++ head/sys/dev/mvs/mvs.c Sat May 12 13:55:36 2012 (r235333) @@ -654,7 +654,9 @@ mvs_ch_intr_locked(void *data) struct mvs_channel *ch = device_get_softc(dev); mtx_lock(&ch->mtx); + xpt_batch_start(ch->sim); mvs_ch_intr(data); + xpt_batch_done(ch->sim); mtx_unlock(&ch->mtx); } Modified: head/sys/dev/siis/siis.c ============================================================================== --- head/sys/dev/siis/siis.c Sat May 12 12:02:51 2012 (r235332) +++ head/sys/dev/siis/siis.c Sat May 12 13:55:36 2012 (r235333) @@ -830,7 +830,9 @@ siis_ch_intr_locked(void *data) struct siis_channel *ch = device_get_softc(dev); mtx_lock(&ch->mtx); + xpt_batch_start(ch->sim); siis_ch_intr(data); + xpt_batch_done(ch->sim); mtx_unlock(&ch->mtx); }