Re: [PATCH 5/5] PCI: Extend pci_reset_function() to support PCI Advanced Feature

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

 



On Fri, Nov 07, 2008 at 08:58:38PM +0800, Yu Zhao wrote:
> >@@ -1798,6 +1806,36 @@ static int __pcie_flr(struct pci_dev *dev)
> > 	return 0;
> > }
> > 
> >+static int __pci_af_flr(struct pci_dev *dev)
> >+{
> >+	int cappos = pci_find_capability(dev, PCI_CAP_ID_AF);
> >+	u16 status;
> >+	u32 cap;
> >+
> >+	if (!cappos)
> >+		return -ENOTTY;
> >+	pci_read_config_byte(dev, cappos + PCI_AF_CAP, (u8 *)&cap);
> >+	if (!(cap & PCI_AF_CAP_TP) || !(cap & PCI_AF_CAP_FLR))
> >+		return -ENOTTY;
> >+
> >+	/* Wait for Transaction Pending bit clean */
> >+	msleep(100);
> >+	pci_read_config_byte(dev, cappos + PCI_AF_STATUS, (u8 *)&status);
> >+	if (status & PCI_AF_STATUS_TP) {
> >+		dev_info(&dev->dev, "Busy after 100ms while trying to"
> >+				" reset; sleeping for 1 second\n");
> >+		ssleep(1);
> >+		pci_read_config_byte(dev,
> >+				cappos + PCI_AF_STATUS, (u8 *)&status);
> >+		if (status & PCI_AF_STATUS_TP)
> >+			dev_info(&dev->dev, "Still busy after 1s; "
> >+					"proceeding with reset anyway\n");
> >+	}
> >+	pci_write_config_byte(dev, cappos + PCI_AF_CTRL, PCI_AF_CTRL_FLR);
> >+	mdelay(100);
> >+	return 0;
> >+}
> 
> Looks like the 'status' could be 'u8'?

You are correct.  This code is buggy on big-endian machines such as
powerpc and sparc.  It's always a bad idea to cast pointers to different
sized types.

-- 
Matthew Wilcox				Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."
--
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