From owner-svn-src-all@FreeBSD.ORG Sat Apr 27 08:40:38 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 5EA763E6; Sat, 27 Apr 2013 08:40:38 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 3710812FE; Sat, 27 Apr 2013 08:40:38 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r3R8ec8Y093677; Sat, 27 Apr 2013 08:40:38 GMT (envelope-from sbruno@svn.freebsd.org) Received: (from sbruno@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r3R8ecGv093676; Sat, 27 Apr 2013 08:40:38 GMT (envelope-from sbruno@svn.freebsd.org) Message-Id: <201304270840.r3R8ecGv093676@svn.freebsd.org> From: Sean Bruno Date: Sat, 27 Apr 2013 08:40:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r249977 - head/sys/dev/ciss X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 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, 27 Apr 2013 08:40:38 -0000 Author: sbruno Date: Sat Apr 27 08:40:37 2013 New Revision: 249977 URL: http://svnweb.freebsd.org/changeset/base/249977 Log: Change maxio to reflect variable hardware configurations. If max_sg_length is 0, then we default to 16 If max_sg_length is less than CISS_MAX_SG_ELEMENTS, then we will set round the value of max_sg_length to the nearest power of 2 and use it to align maxio. Else, we will use CISS_MAX_SG_ELEMENTS for our calculations. Thanks to scottl for working me through the history and providing the basis for this patch. Submitted by: scott Obtained from: Yahoo! Inc. MFC after: 2 weeks Modified: head/sys/dev/ciss/ciss.c Modified: head/sys/dev/ciss/ciss.c ============================================================================== --- head/sys/dev/ciss/ciss.c Sat Apr 27 08:11:48 2013 (r249976) +++ head/sys/dev/ciss/ciss.c Sat Apr 27 08:40:37 2013 (r249977) @@ -2985,6 +2985,7 @@ ciss_cam_action(struct cam_sim *sim, uni case XPT_PATH_INQ: { struct ccb_pathinq *cpi = &ccb->cpi; + int sg_length; debug(1, "XPT_PATH_INQ %d:%d:%d", cam_sim_bus(sim), ccb->ccb_h.target_id, ccb->ccb_h.target_lun); @@ -3005,7 +3006,22 @@ ciss_cam_action(struct cam_sim *sim, uni cpi->transport_version = 2; cpi->protocol = PROTO_SCSI; cpi->protocol_version = SCSI_REV_2; - cpi->maxio = (min(CISS_MAX_SG_ELEMENTS - 1, sc->ciss_cfg->max_sg_length)) * PAGE_SIZE; + if (sc->ciss_cfg->max_sg_length == 0) { + sg_length = 16; + } else { + /* XXX Fix for ZMR cards that advertise max_sg_length == 32 + * Confusing bit here. max_sg_length is usually a power of 2. We always + * need to subtract 1 to account for partial pages. Then we need to + * align on a valid PAGE_SIZE so we round down to the nearest power of 2. + * Add 1 so we can then subtract it out in the assignment to maxio. + * The reason for all these shenanigans is to create a maxio value that + * creates IO operations to volumes that yield consistent operations + * with good performance. + */ + sg_length = sc->ciss_cfg->max_sg_length - 1; + sg_length = (1 << (fls(sg_length) - 1)) + 1; + } + cpi->maxio = (min(CISS_MAX_SG_ELEMENTS, sg_length) - 1) * PAGE_SIZE; ccb->ccb_h.status = CAM_REQ_CMP; break; }