From owner-svn-src-head@FreeBSD.ORG Fri May 25 07:57:18 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6410F106564A; Fri, 25 May 2012 07:57:18 +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 35CE18FC0C; Fri, 25 May 2012 07:57:18 +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 q4P7vINb089170; Fri, 25 May 2012 07:57:18 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q4P7vIC0089168; Fri, 25 May 2012 07:57:18 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201205250757.q4P7vIC0089168@svn.freebsd.org> From: Alexander Motin Date: Fri, 25 May 2012 07:57:17 +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: r235980 - head/sys/cam/scsi X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 May 2012 07:57:18 -0000 Author: mav Date: Fri May 25 07:57:17 2012 New Revision: 235980 URL: http://svn.freebsd.org/changeset/base/235980 Log: Remove sleep() from invalidate call in ses driver, waiting for daemon process exit. Instead use CAM's standard reference counting to prevent periph going away until process won't complete. I think that sleep in single CAM SWI thread is not a good idea and may lead to deadlocks if daemon process waits for some command completion. Combined with recent patch avoiding use of CAM SWI for ATA it just causes panics because of sleeps prohibited in interrupt thread context. Modified: head/sys/cam/scsi/scsi_enc.c Modified: head/sys/cam/scsi/scsi_enc.c ============================================================================== --- head/sys/cam/scsi/scsi_enc.c Fri May 25 07:46:24 2012 (r235979) +++ head/sys/cam/scsi/scsi_enc.c Fri May 25 07:57:17 2012 (r235980) @@ -136,15 +136,8 @@ enc_oninvalidate(struct cam_periph *peri */ enc->enc_flags |= ENC_FLAG_SHUTDOWN; if (enc->enc_daemon != NULL) { - /* Signal and wait for the ses daemon to terminate. */ + /* Signal the ses daemon to terminate. */ wakeup(enc->enc_daemon); - /* - * We're called with the SIM mutex held, but we're dropping - * the update mutex here on sleep. So we have to manually - * drop the SIM mutex. - */ - cam_periph_sleep(enc->periph, enc->enc_daemon, - PUSER, "thtrm", 0); } callout_drain(&enc->status_updater); @@ -839,6 +832,7 @@ enc_daemon(void *arg) } enc->enc_daemon = NULL; cam_periph_unlock(enc->periph); + cam_periph_release(enc->periph); kproc_exit(0); } @@ -849,6 +843,9 @@ enc_kproc_init(enc_softc_t *enc) callout_init_mtx(&enc->status_updater, enc->periph->sim->mtx, 0); + if (cam_periph_acquire(enc->periph) != CAM_REQ_CMP) + return (ENXIO); + result = kproc_create(enc_daemon, enc, &enc->enc_daemon, /*flags*/0, /*stackpgs*/0, "enc_daemon%d", enc->periph->unit_number); @@ -857,7 +854,8 @@ enc_kproc_init(enc_softc_t *enc) cam_periph_lock(enc->periph); enc->enc_vec.poll_status(enc); cam_periph_unlock(enc->periph); - } + } else + cam_periph_release(enc->periph); return (result); } @@ -955,7 +953,7 @@ enc_ctor(struct cam_periph *periph, void err = enc_kproc_init(enc); if (err) { xpt_print(periph->path, - "error %d string enc_daemon\n", err); + "error %d starting enc_daemon\n", err); goto out; } }