From owner-freebsd-hackers@FreeBSD.ORG Tue Jan 25 15:15:26 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F315C1065673 for ; Tue, 25 Jan 2011 15:15:26 +0000 (UTC) (envelope-from philip-freebsd1@soeberg.net) Received: from pasmtpA.tele.dk (pasmtpa.tele.dk [80.160.77.114]) by mx1.freebsd.org (Postfix) with ESMTP id 9EC4E8FC14 for ; Tue, 25 Jan 2011 15:15:26 +0000 (UTC) Received: from mail.soeberg.net (0x573f534a.cpe.ge-1-1-0-1109.bynqu1.customer.tele.dk [87.63.83.74]) by pasmtpA.tele.dk (Postfix) with ESMTP id 35C0780074A for ; Tue, 25 Jan 2011 15:46:57 +0100 (CET) Received: from [10.240.10.87] ([188.120.77.114]) (authenticated user philip@soeberg.net) by mail.soeberg.net (using TLSv1/SSLv3 with cipher AES256-SHA (256 bits)) for freebsd-hackers@freebsd.org; Tue, 25 Jan 2011 15:47:02 +0100 Message-ID: <4D3EE287.3010203@soeberg.net> Date: Tue, 25 Jan 2011 15:47:35 +0100 From: Philip Soeberg User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101207 Lightning/1.0b2 Thunderbird/3.1.7 MIME-Version: 1.0 To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: pci_suspend/pci_resume of custom pcie board X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: philip-freebsd1@soeberg.net List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Jan 2011 15:15:27 -0000 Hi, I'm in a particular problem where I need to set my custom pcie adapter into d3hot power-mode and a couple of seconds later reset it back to d0. The board has an FPGA directly attached to the pcie interface, and as I need to re-configure the FPGA on the fly, I have to ensure the datalink layer between the upstream bridge and my device is idle to prevent any hickups. On linux I simply do a pci_save_state(device) followed by pci_set_power_state(device, d3hot), then after my magic on my board, I do the reverse: pci_set_power_state(device, d0) followed by pci_restore_state(device). On FreeBSD, say 8, I've found the pci_set_powerstate function, which is documented in PCI(9), but that function does not save nor restore the config space. I've tried, just for the fun of it, to go via pci_cfg_save(device, dinfo, 0) with dinfo being device_get_ivars(device) and then subsequently restoring the config space back via pci_cfg_restore(), but since both those functions are declared in I'm not sure if I'm supposed to use those directly or not.. Besides, I'm not really having any luck with that approach. Reading high and low on the net suggest that not all too many driver devs are concerned with suspend/resume operation of their device, and if they are, leave it to user-space to decide when to suspend/resume a device.. I would like to be able to save off my device' config space, put it to sleep (d3hot), wake it back up (d0) and restore the device' config space directly from the device' own driver.. Anyone who can help me with this? Thanks, Phil