From owner-svn-src-all@FreeBSD.ORG Fri Mar 23 21:59:57 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5B7501065899; Fri, 23 Mar 2012 21:59:57 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from zimbra.averesystems.com (75-149-8-245-Pennsylvania.hfc.comcastbusiness.net [75.149.8.245]) by mx1.freebsd.org (Postfix) with ESMTP id 1AEB78FC1C; Fri, 23 Mar 2012 21:59:56 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by zimbra.averesystems.com (Postfix) with ESMTP id 3F324446006; Fri, 23 Mar 2012 17:59:55 -0400 (EDT) X-Virus-Scanned: amavisd-new at averesystems.com Received: from zimbra.averesystems.com ([127.0.0.1]) by localhost (zimbra.averesystems.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jM6-TcbC+cNs; Fri, 23 Mar 2012 17:59:43 -0400 (EDT) Received: from hqrouter.arriad.com (vm.arriad.com [10.0.1.251]) by zimbra.averesystems.com (Postfix) with ESMTP id 5DEEF446023; Fri, 23 Mar 2012 17:59:41 -0400 (EDT) X-Mailbox-Line: From owner-svn-src-stable-8@freebsd.org Fri Mar 23 14:04:37 2012 X-Original-To: aboyer@averesystems.com Delivered-To: aboyer@averesystems.com Received: from mx2.freebsd.org (mx2.freebsd.org [69.147.83.53]) by zimbra.averesystems.com (Postfix) with ESMTP id BE59B200AF for ; Fri, 23 Mar 2012 14:04:36 -0400 (EDT) Received: from hub.freebsd.org (hub.freebsd.org [IPv6:2001:4f8:fff6::36]) by mx2.freebsd.org (Postfix) with ESMTP id 5B6101763D1; Fri, 23 Mar 2012 18:04:22 +0000 (UTC) Received: from hub.freebsd.org (localhost [127.0.0.1]) by hub.freebsd.org (Postfix) with ESMTP id 43E7A106567A; Fri, 23 Mar 2012 18:04:22 +0000 (UTC) (envelope-from owner-svn-src-stable-8@freebsd.org) Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7F0491065680; Fri, 23 Mar 2012 18:03:39 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 68A548FC1A; Fri, 23 Mar 2012 18:03:39 +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 q2NI3diW087721; Fri, 23 Mar 2012 18:03:39 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q2NI3dx2087716; Fri, 23 Mar 2012 18:03:39 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201203231803.q2NI3dx2087716@svn.freebsd.org> From: John Baldwin Date: Fri, 23 Mar 2012 18:03:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Sender: owner-svn-src-stable-8@freebsd.org Errors-To: owner-svn-src-stable-8@freebsd.org Cc: Subject: svn commit: r233380 - in stable/8: share/man/man9 sys/dev/pci sys/i386/conf X-BeenThere: svn-src-all@freebsd.org 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: Fri, 23 Mar 2012 21:59:57 -0000 Author: jhb Date: Fri Mar 23 18:03:38 2012 New Revision: 233380 URL: http://svn.freebsd.org/changeset/base/233380 Log: MFC 232360: Add pci_save_state() and pci_restore_state() wrappers around pci_cfg_save() and pci_cfg_restore() for device drivers to use when saving and restoring state (e.g. to handle device-specific resets). Modified: stable/8/share/man/man9/Makefile stable/8/share/man/man9/pci.9 stable/8/sys/dev/pci/pci.c stable/8/sys/dev/pci/pcivar.h Directory Properties: stable/8/share/man/man9/ (props changed) stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/boot/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/e1000/ (props changed) stable/8/sys/i386/conf/XENHVM (props changed) Modified: stable/8/share/man/man9/Makefile ============================================================================== --- stable/8/share/man/man9/Makefile Fri Mar 23 18:03:04 2012 (r233379) +++ stable/8/share/man/man9/Makefile Fri Mar 23 18:03:38 2012 (r233380) @@ -944,6 +944,8 @@ MLINKS+=pci.9 pci_disable_busmaster.9 \ pci.9 pci_find_device.9 \ pci.9 pci_get_powerstate.9 \ pci.9 pci_read_config.9 \ + pci.9 pci_restore_state.9 \ + pci.9 pci_save_state.9 \ pci.9 pci_set_powerstate.9 \ pci.9 pci_write_config.9 MLINKS+=pfil.9 pfil_add_hook.9 \ Modified: stable/8/share/man/man9/pci.9 ============================================================================== --- stable/8/share/man/man9/pci.9 Fri Mar 23 18:03:04 2012 (r233379) +++ stable/8/share/man/man9/pci.9 Fri Mar 23 18:03:38 2012 (r233380) @@ -38,6 +38,8 @@ .Nm pci_disable_io , .Nm pci_set_powerstate , .Nm pci_get_powerstate , +.Nm pci_save_state , +.Nm pci_restore_state , .Nm pci_find_bsf , .Nm pci_find_dbsf , .Nm pci_find_device @@ -63,6 +65,10 @@ .Fn pci_get_powerstate "device_t dev" .Ft uint32_t .Fn pci_read_config "device_t dev" "int reg" "int width" +.Ft void +.Fn pci_save_state "device_t dev" +.Ft void +.Fn pci_restore_state "device_t dev" .Ft device_t .Fn pci_find_bsf "uint8_t bus" "uint8_t slot" "uint8_t func" .Ft device_t @@ -188,6 +194,26 @@ of is set. .Pp The +.Fn pci_save_state +and +.Fn pci_restore_state +functions can be used by a device driver to save and restore standard PCI +config registers. +The +.Fn pci_save_state +function must be invoked while the device has valid state before +.Fn pci_restore_state +can be used. +If the device is not in the fully-powered state +.Pq Dv PCI_POWERSTATE_D0 +when +.Fn pci_restore_state +is invoked, +then the device will be transitioned to +.Dv PCI_POWERSTATE_D0 +before any config registers are restored. +.Pp +The .Fn pci_find_bsf function looks up the .Vt device_t Modified: stable/8/sys/dev/pci/pci.c ============================================================================== --- stable/8/sys/dev/pci/pci.c Fri Mar 23 18:03:04 2012 (r233379) +++ stable/8/sys/dev/pci/pci.c Fri Mar 23 18:03:38 2012 (r233380) @@ -4171,3 +4171,22 @@ pci_cfg_save(device_t dev, struct pci_de if (pci_get_powerstate(dev) != PCI_POWERSTATE_D3) pci_set_powerstate(dev, PCI_POWERSTATE_D3); } + +/* Wrapper APIs suitable for device driver use. */ +void +pci_save_state(device_t dev) +{ + struct pci_devinfo *dinfo; + + dinfo = device_get_ivars(dev); + pci_cfg_save(dev, dinfo, 0); +} + +void +pci_restore_state(device_t dev) +{ + struct pci_devinfo *dinfo; + + dinfo = device_get_ivars(dev); + pci_cfg_restore(dev, dinfo); +} Modified: stable/8/sys/dev/pci/pcivar.h ============================================================================== --- stable/8/sys/dev/pci/pcivar.h Fri Mar 23 18:03:04 2012 (r233379) +++ stable/8/sys/dev/pci/pcivar.h Fri Mar 23 18:03:38 2012 (r233380) @@ -460,6 +460,8 @@ int pci_msi_device_blacklisted(device_t void pci_ht_map_msi(device_t dev, uint64_t addr); int pci_get_max_read_req(device_t dev); +void pci_restore_state(device_t dev); +void pci_save_state(device_t dev); int pci_set_max_read_req(device_t dev, int size); #endif /* _SYS_BUS_H_ */ _______________________________________________ svn-src-stable-8@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-stable-8 To unsubscribe, send any mail to "svn-src-stable-8-unsubscribe@freebsd.org"