lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sat, 1 Oct 2011 13:03:57 +0200
From:	Francois Romieu <romieu@...zoreil.com>
To:	Mark Einon <mark.einon@...il.com>
Cc:	"Rafael J. Wysocki" <rjw@...k.pl>, gregkh@...e.de,
	devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org,
	o.hartmann@...ovital.com, alan@...ux.intel.com
Subject: Re: [PATCH 4/8] staging: et131x: Add pci suspend & resume functions

Mark Einon <mark.einon@...il.com> :
> Added basic suspend & resume functionality.
> Tested on an et1310 device, and putting Fedora15 host in and out of
> hibernation successfully.
> 
> Signed-off-by: Mark Einon <mark.einon@...il.com>
[...]
> diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c
> index 10283a3..e166fde 100644
> --- a/drivers/staging/et131x/et131x_initpci.c
> +++ b/drivers/staging/et131x/et131x_initpci.c
> @@ -869,6 +869,45 @@ static void __devexit et131x_pci_remove(struct pci_dev *pdev)
>  	pci_disable_device(pdev);
>  }
>  
> +static int et131x_pci_suspend(struct pci_dev *pdev, pm_message_t state)
> +{
> +	struct net_device *netdev = pci_get_drvdata(pdev);
> +
> +	if (!netif_running(netdev))
> +		return 0;
> +
> +	et131x_close(netdev);
> +	netif_device_detach(netdev);
> +
> +	pci_save_state(pdev);
> +	pci_set_power_state(pdev, pci_choose_state(pdev, state));
> +
> +	return 0;
> +}
> +
> +static int et131x_pci_resume(struct pci_dev *pdev)
> +{
> +	struct net_device *netdev = pci_get_drvdata(pdev);
> +	int err = 0;
> +
> +	if (!netif_running(netdev))
> +		return 0;
> +
> +	pci_set_power_state(pdev, PCI_D0);
> +	pci_restore_state(pdev);
> +
> +	err = et131x_open(netdev);
> +	if (err) {
> +		dev_err(&pdev->dev, "Can't resume interface!\n");
> +		goto out;
> +	}

You can/should split et131x_{open/close} to remove this failure point.

[...]
> @@ -884,8 +923,10 @@ static struct pci_driver et131x_driver = {
>  	.id_table	= et131x_pci_table,
>  	.probe		= et131x_pci_setup,
>  	.remove		= __devexit_p(et131x_pci_remove),
> -	.suspend	= NULL,		/* et131x_pci_suspend */
> -	.resume		= NULL,		/* et131x_pci_resume */
> +#ifdef CONFIG_PM
> +	.suspend	= et131x_pci_suspend,
> +	.resume		= et131x_pci_resume,
> +#endif

There is not much driver specific there. It should probably go through
pci_driver.driver.pm.

-- 
Ueimor
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ