From owner-svn-src-all@freebsd.org Sat Oct 24 23:45:46 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8613FA1ECC8; Sat, 24 Oct 2015 23:45:46 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5CE9511BC; Sat, 24 Oct 2015 23:45:46 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9ONjjcj011964; Sat, 24 Oct 2015 23:45:45 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9ONjjYo011963; Sat, 24 Oct 2015 23:45:45 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201510242345.t9ONjjYo011963@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: "Conrad E. Meyer" Date: Sat, 24 Oct 2015 23:45:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289908 - head/sys/dev/ioat 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.20 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, 24 Oct 2015 23:45:46 -0000 Author: cem Date: Sat Oct 24 23:45:45 2015 New Revision: 289908 URL: https://svnweb.freebsd.org/changeset/base/289908 Log: ioat: Add sysctl to force hw reset To enable controlled testing. Sponsored by: EMC / Isilon Storage Division Modified: head/sys/dev/ioat/ioat.c Modified: head/sys/dev/ioat/ioat.c ============================================================================== --- head/sys/dev/ioat/ioat.c Sat Oct 24 23:45:33 2015 (r289907) +++ head/sys/dev/ioat/ioat.c Sat Oct 24 23:45:45 2015 (r289908) @@ -82,6 +82,7 @@ static void ioat_comp_update_map(void *a int error); static int ioat_reset_hw(struct ioat_softc *ioat); static void ioat_setup_sysctl(device_t device); +static int sysctl_handle_reset(SYSCTL_HANDLER_ARGS); static inline struct ioat_softc *ioat_get(struct ioat_softc *, enum ioat_ref_kind); static inline void ioat_put(struct ioat_softc *, enum ioat_ref_kind); @@ -1028,8 +1029,10 @@ ioat_reset_hw(struct ioat_softc *ioat) * BDXDE and BWD models reset MSI-X registers on device reset. * Save/restore their contents manually. */ - if (ioat_model_resets_msix(ioat)) + if (ioat_model_resets_msix(ioat)) { + ioat_log_message(1, "device resets MSI-X registers; saving\n"); pci_save_state(ioat->device); + } ioat_reset(ioat); @@ -1039,12 +1042,37 @@ ioat_reset_hw(struct ioat_softc *ioat) if (timeout == 20) return (ETIMEDOUT); - if (ioat_model_resets_msix(ioat)) + if (ioat_model_resets_msix(ioat)) { + ioat_log_message(1, "device resets registers; restored\n"); pci_restore_state(ioat->device); + } return (0); } +static int +sysctl_handle_reset(SYSCTL_HANDLER_ARGS) +{ + struct ioat_softc *ioat; + int error, arg; + + ioat = arg1; + + arg = 0; + error = SYSCTL_OUT(req, &arg, sizeof(arg)); + if (error != 0 || req->newptr == NULL) + return (error); + + error = SYSCTL_IN(req, &arg, sizeof(arg)); + if (error != 0) + return (error); + + if (arg != 0) + error = ioat_reset_hw(ioat); + + return (error); +} + static void dump_descriptor(void *hw_desc) { @@ -1060,23 +1088,26 @@ dump_descriptor(void *hw_desc) static void ioat_setup_sysctl(device_t device) { - struct sysctl_ctx_list *sysctl_ctx; - struct sysctl_oid *sysctl_tree; + struct sysctl_oid_list *par; + struct sysctl_ctx_list *ctx; + struct sysctl_oid *tree; struct ioat_softc *ioat; ioat = DEVICE2SOFTC(device); - sysctl_ctx = device_get_sysctl_ctx(device); - sysctl_tree = device_get_sysctl_tree(device); - - SYSCTL_ADD_UINT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, - "ring_size_order", CTLFLAG_RD, &ioat->ring_size_order, - 0, "HW descriptor ring size order"); - SYSCTL_ADD_UINT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, - "head", CTLFLAG_RD, &ioat->head, - 0, "HW descriptor head pointer index"); - SYSCTL_ADD_UINT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, - "tail", CTLFLAG_RD, &ioat->tail, - 0, "HW descriptor tail pointer index"); + ctx = device_get_sysctl_ctx(device); + tree = device_get_sysctl_tree(device); + par = SYSCTL_CHILDREN(tree); + + SYSCTL_ADD_UINT(ctx, par, OID_AUTO, "ring_size_order", CTLFLAG_RD, + &ioat->ring_size_order, 0, "HW descriptor ring size order"); + SYSCTL_ADD_UINT(ctx, par, OID_AUTO, "head", CTLFLAG_RD, &ioat->head, 0, + "HW descriptor head pointer index"); + SYSCTL_ADD_UINT(ctx, par, OID_AUTO, "tail", CTLFLAG_RD, &ioat->tail, 0, + "HW descriptor tail pointer index"); + + SYSCTL_ADD_PROC(ctx, par, OID_AUTO, "force_hw_reset", + CTLTYPE_INT | CTLFLAG_RW, ioat, 0, sysctl_handle_reset, "I", + "Set to non-zero to reset the hardware"); } static inline struct ioat_softc *