Commit 061c063e authored by Stephen Rothwell's avatar Stephen Rothwell Committed by Linus Torvalds

[PATCH] ppc64 iSeries: remove some more members of iSeries_Device_Node

The AgentId, PhbId, FrameId, CardLocation and Location members of
iSeries_Device_Node are stored early in the boot process just so that a
message about the device can be printed later in the boot process.  Remove
them and construct the message by doing the VPD parsing at the time the
message is printed.

Also remove a few unused defines in iSeries_VpdInfo.c.
Signed-off-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent a2ebaf25
...@@ -44,7 +44,6 @@ ...@@ -44,7 +44,6 @@
/* /*
* Bus Vpd Tags * Bus Vpd Tags
*/ */
#define VpdEndOfDataTag 0x78
#define VpdEndOfAreaTag 0x79 #define VpdEndOfAreaTag 0x79
#define VpdIdStringTag 0x82 #define VpdIdStringTag 0x82
#define VpdVendorAreaTag 0x84 #define VpdVendorAreaTag 0x84
...@@ -52,11 +51,8 @@ ...@@ -52,11 +51,8 @@
/* /*
* Mfg Area Tags * Mfg Area Tags
*/ */
#define VpdFruFlag 0x4647 // "FG"
#define VpdFruFrameId 0x4649 // "FI" #define VpdFruFrameId 0x4649 // "FI"
#define VpdSlotMapFormat 0x4D46 // "MF" #define VpdSlotMapFormat 0x4D46 // "MF"
#define VpdAsmPartNumber 0x504E // "PN"
#define VpdFruSerial 0x534E // "SN"
#define VpdSlotMap 0x534D // "SM" #define VpdSlotMap 0x534D // "SM"
/* /*
...@@ -82,49 +78,11 @@ struct SlotMapStruct { ...@@ -82,49 +78,11 @@ struct SlotMapStruct {
typedef struct SlotMapStruct SlotMap; typedef struct SlotMapStruct SlotMap;
#define SLOT_ENTRY_SIZE 16 #define SLOT_ENTRY_SIZE 16
/*
* Formats the device information.
* - Pass in pci_dev* pointer to the device.
* - Pass in buffer to place the data. Danger here is the buffer must
* be as big as the client says it is. Should be at least 128 bytes.
* Return will the length of the string data put in the buffer.
* Format:
* PCI: Bus 0, Device 26, Vendor 0x12AE Frame 1, Card C10 Ethernet
* controller
*/
int iSeries_Device_Information(struct pci_dev *PciDev, char *buffer,
int BufferSize)
{
struct iSeries_Device_Node *DevNode =
(struct iSeries_Device_Node *)PciDev->sysdata;
int len;
if (DevNode == NULL)
return sprintf(buffer,
"PCI: iSeries_Device_Information DevNode is NULL");
if (BufferSize < 128)
return 0;
len = sprintf(buffer, "PCI: Bus%3d, Device%3d, Vendor %04X ",
ISERIES_BUS(DevNode), PCI_SLOT(PciDev->devfn),
PciDev->vendor);
len += sprintf(buffer + len, "Frame%3d, Card %4s ",
DevNode->FrameId, DevNode->CardLocation);
if (pci_class_name(PciDev->class >> 8) == 0)
len += sprintf(buffer + len, "0x%04X ",
(int)(PciDev->class >> 8));
else
len += sprintf(buffer + len, "%s",
pci_class_name(PciDev->class >> 8));
return len;
}
/* /*
* Parse the Slot Area * Parse the Slot Area
*/ */
static void iSeries_Parse_SlotArea(SlotMap *MapPtr, int MapLen, static void __init iSeries_Parse_SlotArea(SlotMap *MapPtr, int MapLen,
struct iSeries_Device_Node *DevNode) HvAgentId agent, u8 *PhbId, char card[4])
{ {
int SlotMapLen = MapLen; int SlotMapLen = MapLen;
SlotMap *SlotMapPtr = MapPtr; SlotMap *SlotMapPtr = MapPtr;
...@@ -133,17 +91,16 @@ static void iSeries_Parse_SlotArea(SlotMap *MapPtr, int MapLen, ...@@ -133,17 +91,16 @@ static void iSeries_Parse_SlotArea(SlotMap *MapPtr, int MapLen,
* Parse Slot label until we find the one requested * Parse Slot label until we find the one requested
*/ */
while (SlotMapLen > 0) { while (SlotMapLen > 0) {
if (SlotMapPtr->AgentId == DevNode->AgentId ) { if (SlotMapPtr->AgentId == agent) {
/* /*
* If Phb wasn't found, grab the entry first one found. * If Phb wasn't found, grab the entry first one found.
*/ */
if (DevNode->PhbId == 0xff) if (*PhbId == 0xff)
DevNode->PhbId = SlotMapPtr->PhbId; *PhbId = SlotMapPtr->PhbId;
/* Found it, extract the data. */ /* Found it, extract the data. */
if (SlotMapPtr->PhbId == DevNode->PhbId ) { if (SlotMapPtr->PhbId == *PhbId) {
memcpy(&DevNode->CardLocation, memcpy(card, &SlotMapPtr->CardLocation, 3);
&SlotMapPtr->CardLocation, 3); card[3] = 0;
DevNode->CardLocation[3] = 0;
break; break;
} }
} }
...@@ -156,8 +113,9 @@ static void iSeries_Parse_SlotArea(SlotMap *MapPtr, int MapLen, ...@@ -156,8 +113,9 @@ static void iSeries_Parse_SlotArea(SlotMap *MapPtr, int MapLen,
/* /*
* Parse the Mfg Area * Parse the Mfg Area
*/ */
static void iSeries_Parse_MfgArea(u8 *AreaData, int AreaLen, static void __init iSeries_Parse_MfgArea(u8 *AreaData, int AreaLen,
struct iSeries_Device_Node *DevNode) HvAgentId agent, u8 *PhbId,
u8 *frame, char card[4])
{ {
MfgArea *MfgAreaPtr = (MfgArea *)AreaData; MfgArea *MfgAreaPtr = (MfgArea *)AreaData;
int MfgAreaLen = AreaLen; int MfgAreaLen = AreaLen;
...@@ -168,7 +126,7 @@ static void iSeries_Parse_MfgArea(u8 *AreaData, int AreaLen, ...@@ -168,7 +126,7 @@ static void iSeries_Parse_MfgArea(u8 *AreaData, int AreaLen,
int MfgTagLen = MfgAreaPtr->TagLength; int MfgTagLen = MfgAreaPtr->TagLength;
/* Frame ID (FI 4649020310 ) */ /* Frame ID (FI 4649020310 ) */
if (MfgAreaPtr->Tag == VpdFruFrameId) /* FI */ if (MfgAreaPtr->Tag == VpdFruFrameId) /* FI */
DevNode->FrameId = MfgAreaPtr->AreaData1; *frame = MfgAreaPtr->AreaData1;
/* Slot Map Format (MF 4D46020004 ) */ /* Slot Map Format (MF 4D46020004 ) */
else if (MfgAreaPtr->Tag == VpdSlotMapFormat) /* MF */ else if (MfgAreaPtr->Tag == VpdSlotMapFormat) /* MF */
SlotMapFmt = (MfgAreaPtr->AreaData1 * 256) SlotMapFmt = (MfgAreaPtr->AreaData1 * 256)
...@@ -183,7 +141,8 @@ static void iSeries_Parse_MfgArea(u8 *AreaData, int AreaLen, ...@@ -183,7 +141,8 @@ static void iSeries_Parse_MfgArea(u8 *AreaData, int AreaLen,
else else
SlotMapPtr = (SlotMap *)((char *)MfgAreaPtr SlotMapPtr = (SlotMap *)((char *)MfgAreaPtr
+ MFG_ENTRY_SIZE); + MFG_ENTRY_SIZE);
iSeries_Parse_SlotArea(SlotMapPtr, MfgTagLen, DevNode); iSeries_Parse_SlotArea(SlotMapPtr, MfgTagLen,
agent, PhbId, card);
} }
/* /*
* Point to the next Mfg Area * Point to the next Mfg Area
...@@ -199,7 +158,7 @@ static void iSeries_Parse_MfgArea(u8 *AreaData, int AreaLen, ...@@ -199,7 +158,7 @@ static void iSeries_Parse_MfgArea(u8 *AreaData, int AreaLen,
* Look for "BUS".. Data is not Null terminated. * Look for "BUS".. Data is not Null terminated.
* PHBID of 0xFF indicates PHB was not found in VPD Data. * PHBID of 0xFF indicates PHB was not found in VPD Data.
*/ */
static int iSeries_Parse_PhbId(u8 *AreaPtr, int AreaLength) static int __init iSeries_Parse_PhbId(u8 *AreaPtr, int AreaLength)
{ {
u8 *PhbPtr = AreaPtr; u8 *PhbPtr = AreaPtr;
int DataLen = AreaLength; int DataLen = AreaLength;
...@@ -223,27 +182,30 @@ static int iSeries_Parse_PhbId(u8 *AreaPtr, int AreaLength) ...@@ -223,27 +182,30 @@ static int iSeries_Parse_PhbId(u8 *AreaPtr, int AreaLength)
/* /*
* Parse out the VPD Areas * Parse out the VPD Areas
*/ */
static void iSeries_Parse_Vpd(u8 *VpdData, int VpdDataLen, static void __init iSeries_Parse_Vpd(u8 *VpdData, int VpdDataLen,
struct iSeries_Device_Node *DevNode) HvAgentId agent, u8 *frame, char card[4])
{ {
u8 *TagPtr = VpdData; u8 *TagPtr = VpdData;
int DataLen = VpdDataLen - 3; int DataLen = VpdDataLen - 3;
u8 PhbId;
while ((*TagPtr != VpdEndOfAreaTag) && (DataLen > 0)) { while ((*TagPtr != VpdEndOfAreaTag) && (DataLen > 0)) {
int AreaLen = *(TagPtr + 1) + (*(TagPtr + 2) * 256); int AreaLen = *(TagPtr + 1) + (*(TagPtr + 2) * 256);
u8 *AreaData = TagPtr + 3; u8 *AreaData = TagPtr + 3;
if (*TagPtr == VpdIdStringTag) if (*TagPtr == VpdIdStringTag)
DevNode->PhbId = iSeries_Parse_PhbId(AreaData, AreaLen); PhbId = iSeries_Parse_PhbId(AreaData, AreaLen);
else if (*TagPtr == VpdVendorAreaTag) else if (*TagPtr == VpdVendorAreaTag)
iSeries_Parse_MfgArea(AreaData, AreaLen, DevNode); iSeries_Parse_MfgArea(AreaData, AreaLen,
agent, &PhbId, frame, card);
/* Point to next Area. */ /* Point to next Area. */
TagPtr = AreaData + AreaLen; TagPtr = AreaData + AreaLen;
DataLen -= AreaLen; DataLen -= AreaLen;
} }
} }
void iSeries_Get_Location_Code(struct iSeries_Device_Node *DevNode) static void __init iSeries_Get_Location_Code(u16 bus, HvAgentId agent,
u8 *frame, char card[4])
{ {
int BusVpdLen = 0; int BusVpdLen = 0;
u8 *BusVpdPtr = kmalloc(BUS_VPDSIZE, GFP_KERNEL); u8 *BusVpdPtr = kmalloc(BUS_VPDSIZE, GFP_KERNEL);
...@@ -252,23 +214,58 @@ void iSeries_Get_Location_Code(struct iSeries_Device_Node *DevNode) ...@@ -252,23 +214,58 @@ void iSeries_Get_Location_Code(struct iSeries_Device_Node *DevNode)
printk("PCI: Bus VPD Buffer allocation failure.\n"); printk("PCI: Bus VPD Buffer allocation failure.\n");
return; return;
} }
BusVpdLen = HvCallPci_getBusVpd(ISERIES_BUS(DevNode), BusVpdLen = HvCallPci_getBusVpd(bus, ISERIES_HV_ADDR(BusVpdPtr),
ISERIES_HV_ADDR(BusVpdPtr),
BUS_VPDSIZE); BUS_VPDSIZE);
if (BusVpdLen == 0) { if (BusVpdLen == 0) {
kfree(BusVpdPtr);
printk("PCI: Bus VPD Buffer zero length.\n"); printk("PCI: Bus VPD Buffer zero length.\n");
return; goto out_free;
} }
/* printk("PCI: BusVpdPtr: %p, %d\n",BusVpdPtr, BusVpdLen); */ /* printk("PCI: BusVpdPtr: %p, %d\n",BusVpdPtr, BusVpdLen); */
/* Make sure this is what I think it is */ /* Make sure this is what I think it is */
if (*BusVpdPtr != VpdIdStringTag) { /* 0x82 */ if (*BusVpdPtr != VpdIdStringTag) { /* 0x82 */
printk("PCI: Bus VPD Buffer missing starting tag.\n"); printk("PCI: Bus VPD Buffer missing starting tag.\n");
kfree(BusVpdPtr); goto out_free;
return;
} }
iSeries_Parse_Vpd(BusVpdPtr,BusVpdLen, DevNode); iSeries_Parse_Vpd(BusVpdPtr, BusVpdLen, agent, frame, card);
sprintf(DevNode->Location, "Frame%3d, Card %-4s", DevNode->FrameId, out_free:
DevNode->CardLocation);
kfree(BusVpdPtr); kfree(BusVpdPtr);
} }
/*
* Prints the device information.
* - Pass in pci_dev* pointer to the device.
* - Pass in the device count
*
* Format:
* PCI: Bus 0, Device 26, Vendor 0x12AE Frame 1, Card C10 Ethernet
* controller
*/
void __init iSeries_Device_Information(struct pci_dev *PciDev, int count)
{
struct iSeries_Device_Node *DevNode = PciDev->sysdata;
u16 bus;
u8 frame;
char card[4];
HvSubBusNumber subbus;
HvAgentId agent;
if (DevNode == NULL) {
printk("%d. PCI: iSeries_Device_Information DevNode is NULL\n",
count);
return;
}
bus = ISERIES_BUS(DevNode);
subbus = ISERIES_SUBBUS(DevNode);
agent = ISERIES_PCI_AGENTID(ISERIES_GET_DEVICE_FROM_SUBBUS(subbus),
ISERIES_GET_FUNCTION_FROM_SUBBUS(subbus));
iSeries_Get_Location_Code(bus, agent, &frame, card);
printk("%d. PCI: Bus%3d, Device%3d, Vendor %04X Frame%3d, Card %4s ",
count, bus, PCI_SLOT(PciDev->devfn), PciDev->vendor,
frame, card);
if (pci_class_name(PciDev->class >> 8) == 0)
printk("0x%04X\n", (int)(PciDev->class >> 8));
else
printk("%s\n", pci_class_name(PciDev->class >> 8));
}
...@@ -223,9 +223,7 @@ static struct iSeries_Device_Node *build_device_node(HvBusNumber Bus, ...@@ -223,9 +223,7 @@ static struct iSeries_Device_Node *build_device_node(HvBusNumber Bus,
node->DsaAddr.Dsa.busNumber = Bus; node->DsaAddr.Dsa.busNumber = Bus;
node->DsaAddr.Dsa.subBusNumber = SubBus; node->DsaAddr.Dsa.subBusNumber = SubBus;
node->DsaAddr.Dsa.deviceId = 0x10; node->DsaAddr.Dsa.deviceId = 0x10;
node->AgentId = AgentId;
node->DevFn = PCI_DEVFN(ISERIES_ENCODE_DEVICE(AgentId), Function); node->DevFn = PCI_DEVFN(ISERIES_ENCODE_DEVICE(AgentId), Function);
iSeries_Get_Location_Code(node);
return node; return node;
} }
...@@ -299,7 +297,6 @@ void __init iSeries_pci_final_fixup(void) ...@@ -299,7 +297,6 @@ void __init iSeries_pci_final_fixup(void)
{ {
struct pci_dev *pdev = NULL; struct pci_dev *pdev = NULL;
struct iSeries_Device_Node *node; struct iSeries_Device_Node *node;
char Buffer[256];
int DeviceCount = 0; int DeviceCount = 0;
PPCDBG(PPCDBG_BUSWALK, "iSeries_pcibios_fixup Entry.\n"); PPCDBG(PPCDBG_BUSWALK, "iSeries_pcibios_fixup Entry.\n");
...@@ -321,9 +318,7 @@ void __init iSeries_pci_final_fixup(void) ...@@ -321,9 +318,7 @@ void __init iSeries_pci_final_fixup(void)
"pdev 0x%p <==> DevNode 0x%p\n", "pdev 0x%p <==> DevNode 0x%p\n",
pdev, node); pdev, node);
allocate_device_bars(pdev); allocate_device_bars(pdev);
iSeries_Device_Information(pdev, Buffer, iSeries_Device_Information(pdev, DeviceCount);
sizeof(Buffer));
printk("%d. %s\n", DeviceCount, Buffer);
iommu_devnode_init_iSeries(node); iommu_devnode_init_iSeries(node);
} else } else
printk("PCI: Device Tree not found for 0x%016lX\n", printk("PCI: Device Tree not found for 0x%016lX\n",
......
...@@ -76,19 +76,13 @@ struct iSeries_Device_Node { ...@@ -76,19 +76,13 @@ struct iSeries_Device_Node {
union HvDsaMap DsaAddr; /* Direct Select Address */ union HvDsaMap DsaAddr; /* Direct Select Address */
/* busNumber, subBusNumber, */ /* busNumber, subBusNumber, */
/* deviceId, barNumber */ /* deviceId, barNumber */
HvAgentId AgentId; /* Hypervisor DevFn */
int DevFn; /* Linux devfn */ int DevFn; /* Linux devfn */
int Irq; /* Assigned IRQ */ int Irq; /* Assigned IRQ */
int Flags; /* Possible flags(disable/bist)*/ int Flags; /* Possible flags(disable/bist)*/
u8 LogicalSlot; /* Hv Slot Index for Tces */ u8 LogicalSlot; /* Hv Slot Index for Tces */
struct iommu_table *iommu_table;/* Device TCE Table */ struct iommu_table *iommu_table;/* Device TCE Table */
u8 PhbId; /* Phb Card is on. */
u8 FrameId; /* iSeries spcn Frame Id */
char CardLocation[4];/* Char format of planar vpd */
char Location[20]; /* Frame 1, Card C10 */
}; };
extern int iSeries_Device_Information(struct pci_dev*, char*, int); extern void iSeries_Device_Information(struct pci_dev*, int);
extern void iSeries_Get_Location_Code(struct iSeries_Device_Node*);
#endif /* _ISERIES_64_PCI_H */ #endif /* _ISERIES_64_PCI_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment