Re: [PATCH/RFC] I/O-check interface for driver's error handling

Andi Kleen
2005-03-01T17:19:54Z

Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com> writes:

>
> int sample_read_with_iochk(struct pci_dev *dev, u32 *buf, int words)
> {
> unsigned long ofs = pci_resource_start(dev, 0) + DATA_OFFSET;
> int i;
>
> /* Create magical cookie on the stack */
> iocookie cookie;
>
> /* Critical section start */
> iochk_clear(&dev, &cookie);
> {
> /* Get the whole packet of data */
> for (i = 0; i < words; i++)
> *buf++ = ioread32(dev, ofs);
> }
> /* Critical section end. Did we have any trouble? */
> if ( iochk_read(&cookie) ) return -1;

Looks good for handling PCI-Express errors.

But what would the default handling be? It would be nice if there
was a simple way for a driver to say "just shut me down on an error"
without adding iochk_* to each function. Ideally this would be just
a standard callback that knows how to clean up the driver.

> +void iochk_clear(iocookie *cookie, struct pci_dev *dev)
> +{
> + local_irq_save(*cookie);
> +}
> +
> +int iochk_read(iocookie *cookie)
> +{
> + local_irq_restore(*cookie);
> + return 0;
> +}

These should be inlined.

> +EXPORT_SYMBOL(iochk_init);

This doesn't need to be exported.

-Andi