From owner-svn-src-head@FreeBSD.ORG Fri Aug 9 01:09:03 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 83BA61D5; Fri, 9 Aug 2013 01:09:03 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 6F13420B1; Fri, 9 Aug 2013 01:09:03 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r79193EF047098; Fri, 9 Aug 2013 01:09:03 GMT (envelope-from scottl@svn.freebsd.org) Received: (from scottl@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r791923P047091; Fri, 9 Aug 2013 01:09:02 GMT (envelope-from scottl@svn.freebsd.org) Message-Id: <201308090109.r791923P047091@svn.freebsd.org> From: Scott Long Date: Fri, 9 Aug 2013 01:09:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r254116 - head/sys/dev/mps X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 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, 09 Aug 2013 01:09:03 -0000 Author: scottl Date: Fri Aug 9 01:09:02 2013 New Revision: 254116 URL: http://svnweb.freebsd.org/changeset/base/254116 Log: Sometimes a device misbehaves so badly that it disrupts the entire system. Add a tunable that allows such a device to be excluded from the driver. The id parameter is the target id that the driver assigns to a given device. dev.mps.X.exclude_ids=, Obtained from: Netflix MFC after: 3 days Modified: head/sys/dev/mps/mps.c head/sys/dev/mps/mps_sas.c head/sys/dev/mps/mps_sas.h head/sys/dev/mps/mps_sas_lsi.c head/sys/dev/mps/mpsvar.h Modified: head/sys/dev/mps/mps.c ============================================================================== --- head/sys/dev/mps/mps.c Fri Aug 9 01:04:44 2013 (r254115) +++ head/sys/dev/mps/mps.c Fri Aug 9 01:09:02 2013 (r254116) @@ -1371,6 +1371,11 @@ mps_get_tunables(struct mps_softc *sc) snprintf(tmpstr, sizeof(tmpstr), "dev.mps.%d.max_chains", device_get_unit(sc->mps_dev)); TUNABLE_INT_FETCH(tmpstr, &sc->max_chains); + + bzero(sc->exclude_ids, sizeof(sc->exclude_ids)); + snprintf(tmpstr, sizeof(tmpstr), "dev.mps.%d.exclude_ids", + device_get_unit(sc->mps_dev)); + TUNABLE_STR_FETCH(tmpstr, sc->exclude_ids, sizeof(sc->exclude_ids)); } static void Modified: head/sys/dev/mps/mps_sas.c ============================================================================== --- head/sys/dev/mps/mps_sas.c Fri Aug 9 01:04:44 2013 (r254115) +++ head/sys/dev/mps/mps_sas.c Fri Aug 9 01:09:02 2013 (r254116) @@ -3553,3 +3553,20 @@ mpssas_portenable_complete(struct mps_so xpt_release_simq(sassc->sim, 1); } +int +mpssas_check_id(struct mpssas_softc *sassc, int id) +{ + struct mps_softc *sc = sassc->sc; + char *ids; + char *name; + + ids = &sc->exclude_ids[0]; + while((name = strsep(&ids, ",")) != NULL) { + if (name[0] == '\0') + continue; + if (strtol(name, NULL, 0) == (long)id) + return (1); + } + + return (0); +} Modified: head/sys/dev/mps/mps_sas.h ============================================================================== --- head/sys/dev/mps/mps_sas.h Fri Aug 9 01:04:44 2013 (r254115) +++ head/sys/dev/mps/mps_sas.h Fri Aug 9 01:09:02 2013 (r254116) @@ -158,3 +158,4 @@ void mpssas_startup_decrement(struct mps struct mps_command * mpssas_alloc_tm(struct mps_softc *sc); void mpssas_free_tm(struct mps_softc *sc, struct mps_command *tm); void mpssas_firmware_event_work(void *arg, int pending); +int mpssas_check_id(struct mpssas_softc *sassc, int id); Modified: head/sys/dev/mps/mps_sas_lsi.c ============================================================================== --- head/sys/dev/mps/mps_sas_lsi.c Fri Aug 9 01:04:44 2013 (r254115) +++ head/sys/dev/mps/mps_sas_lsi.c Fri Aug 9 01:09:02 2013 (r254116) @@ -669,6 +669,13 @@ mpssas_add_device(struct mps_softc *sc, error = ENXIO; goto out; } + + if (mpssas_check_id(sassc, id) != 0) { + device_printf(sc->mps_dev, "Excluding target id %d\n", id); + error = ENXIO; + goto out; + } + mps_dprint(sc, MPS_MAPPING, "SAS Address from SAS device page0 = %jx\n", sas_address); targ = &sassc->targets[id]; Modified: head/sys/dev/mps/mpsvar.h ============================================================================== --- head/sys/dev/mps/mpsvar.h Fri Aug 9 01:04:44 2013 (r254115) +++ head/sys/dev/mps/mpsvar.h Fri Aug 9 01:09:02 2013 (r254116) @@ -414,6 +414,8 @@ struct mps_softc { uint16_t DD_block_exponent; uint64_t DD_max_lba; struct mps_column_map DD_column_map[MPS_MAX_DISKS_IN_VOL]; + + char exclude_ids[80]; }; struct mps_config_params {