Re: How does Linux handle PCI-E Surprise unplug?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



(2010/02/19 13:01), Rajat Jain wrote:
> 
> It is fairly common for the drivers to have such code:
> 
> Val1 = ioread32(reg1);
> Val2 = ioread32(reg2);
> Val3 = ioread32(reg3);
> Val4 = ioread32(reg4);
> 
> Do you mean the above code is wrong and it should be re-written as:
> 
> If ((Val1 = ioread32(reg1)) == 0xFFFFFFFF)
> 	/* Abort */
> If ((Val2 = ioread32(reg2)) == 0xFFFFFFFF)
> 	/* Abort */
> Etc ....
> 
> Checking for 0xFFFFFFFF at every read is a pain, don't you think so?

... Dejavu?

http://marc.info/?l=linux-kernel&m=108125011020312
  [RFC] readX_check() - Interface for PCI-X error recovery
  Date: 2004-04-06 11:04:49

> And
> more over, what is a register ACTUALLY contains the value 0xFFFFFFFF?
> How do we differentiate this with the case when the device has been
> plugged out?

An example I know is:
[arch/powerpc/include/asm/eeh.h]
  static inline u8 eeh_readb(const volatile void __iomem *addr)
  {
	u8 val = in_8(addr);
	if (EEH_POSSIBLE_ERROR(val, u8))
		return eeh_check_failure(addr, val);
	return val;
  }

> 
> Finally, how do we re-write the following code to handle this correctly?
> 
> iowrite32(val1, reg1);
> iowrite32(val2, reg2);
> iowrite32(val3, reg3);
> iowrite32(val4, reg4);

One answer is as already posted by Greg, "read it."

If you made a request by writing some data, I think you will wait
a response from the device, with setting some reasonable timeout.
Soon in some form you will get a message like "success", "retry" or
"failed", or nothing if timeout.  Then you can report it to userland
and/or start next conversation with the device.


Thanks,
H.Seto

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux