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-next>] [day] [month] [year] [list]
Message-ID: <87wt3xcmyr.fsf@sw.ru>
Date:	Mon, 08 Jan 2007 22:55:40 +0300
From:	Dmitriy Monakhov <dmonakhov@...ru>
To:	linux-kernel@...r.kernel.org
Subject: pci_driver resume() callback return value

While investigating pci driver model i've found strange thing.
struct pci_driver has resume() callback and it declarated like follows
int  (*resume) (struct pci_dev *dev);/* Device woken up */
Documentation states about it:
from Documentation/pci-error-recovery.txt
STEP 5: Resume Operations
-------------------------
The platform will call the resume() callback on all affected device
drivers if all drivers on the segment have returned
PCI_ERS_RESULT_RECOVERED from one of the 3 previous callbacks.
The goal of this callback is to tell the driver to restart activity,
that everything is back and running.
This callback does not return a result code.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.......
But most of pci devices may return correct error code if error happens
during resume(), for example e1000 implement it as follows:
static int e1000_resume(struct pci_dev *pdev)
{
	struct net_device *netdev = pci_get_drvdata(pdev);
	struct e1000_adapter *adapter = netdev_priv(netdev);
	uint32_t err;
        .....
	if ((err = pci_enable_device(pdev))) {
           printk(KERN_ERR "e1000: Cannot enable PCI device from suspend\n");
           return err;
	}
.....
Even generic pci routines may return nonzero err code and upper(but_type) level
routunes properly handles it:
from drivers/pci/pci-driver.c:321
static int pci_device_resume(struct device * dev)
{
	int error;
	struct pci_dev * pci_dev = to_pci_dev(dev);
	struct pci_driver * drv = pci_dev->driver;

	if (drv && drv->resume)
		error = drv->resume(pci_dev);
	else
		error = pci_default_resume(pci_dev);
	return error;
}

Now question. Should we,or should we not return error code from resume callback?
Where a two possible ways:
a) Comment in document section is out of date and we have to properly handle 
   and return error code if something goes wrong.
b) Comment in document section is correct and and dont have to worry about any 
error, and return code  from resume() callback.
As i understand (a) is correct answer.

-
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