bonito: PCI_STATUS questions
I see code in bonito.c that clears bits:PCI_STATUS_REC_MASTER_ABORT | PCI_STATUS_REC_TARGET_ABORT on each read and write.
However
1. I don't see anything in code that would set these bits
2. The PCI spec says this about the status register:
Reads to this register behave normally. Writes are slightly different in that bits can be reset, but not set. A one bit is reset (if it is not read-only) whenever the register is written, and the write data in the corresponding bit location is a 1. For instance, to clear bit 14 and not affect any other bits, write the value 0100_0000_0000_0000b to the register.
while the code in bonito.c resets the bits to 0 on each write.
Comments?
Signature · 1 line
MST
Because the code in PMON and Linux kernel use these bits to verify r/w operations. If one of them is 1 after r/w, PMON and Linux will consider r/w has failed.
I guess that software will not set them to 1, because it is set by hardware when operation fails.
Quoted 22 lines · Michael S. Tsirkin
I see code in
bonito.cthat clears bits:PCI_STATUS_REC_MASTER_ABORT|PCI_STATUS_REC_TARGET_ABORTon each read and write.However
1. I don't see anything in code that would set these bits
2. The PCI spec says this about the status register:Reads to this register behave normally. Writes are slightly different in that bits can be reset, but not set. A one bit is reset (if it is not read-only) whenever the register is written, and the write data in the corresponding bit location is a 1. For instance, to clear bit 14 and not affect any other bits, write the value 0100_0000_0000_0000b to the register.
while the code in
bonito.cresets the bits to 0 on each write.Comments?
--
MST
Signature · 1 line
Huacai Chen
Quoted 3 lines · chen huacai
Because the code in PMON and Linux kernel use these bits to verify r/w operations. If one of them is 1 after r/w, PMON and Linux will consider r/w has failed.
Where's that code in Linux?
Quoted 2 lines
I guess that software will not set them to 1, because it is set by hardware when operation fails.
So I guess just making these write 1 to clear according to spec will work?
Quoted 28 lines · Michael S. Tsirkin
Quoted 22 lines
I see code in
bonito.cthat clears bits:PCI_STATUS_REC_MASTER_ABORT|PCI_STATUS_REC_TARGET_ABORTon each read and write.However
1. I don't see anything in code that would set these bits
2. The PCI spec says this about the status register:Reads to this register behave normally. Writes are slightly different in that bits can be reset, but not set. A one bit is reset (if it is not read-only) whenever the register is written, and the write data in the corresponding bit location is a 1. For instance, to clear bit 14 and not affect any other bits, write the value 0100_0000_0000_0000b to the register.
while the code in
bonito.cresets the bits to 0 on each write.Comments?
--
MSTSignature · 1 line
Huacai Chen
Please see bonito64_pcibios_config_access() in arch/mips/pci/ops-bonito64.c of Linux kernel code. You will find something useful.
Quoted 41 lines · Michael S. Tsirkin
Quoted 3 lines · chen huacai
Because the code in PMON and Linux kernel use these bits to verify r/w operations. If one of them is 1 after r/w, PMON and Linux will consider r/w has failed.
Where's that code in Linux?
Quoted 2 lines
I guess that software will not set them to 1, because it is set by hardware when operation fails.
So I guess just making these write 1 to clear according to spec will work?
Quoted 28 lines · Michael S. Tsirkin
Quoted 15 lines
I see code in
bonito.cthat clears bits:PCI_STATUS_REC_MASTER_ABORT|PCI_STATUS_REC_TARGET_ABORTon each read and write.However
1. I don't see anything in code that would set these bits
2. The PCI spec says this about the status register:Reads to this register behave normally. Writes are slightly different in that bits can be reset, but not set. A one bit is reset (if it is not read-only) whenever the register is written, and the write data in the corresponding bit location is a 1. For instance, to clear bit 14 and not affect any other bits, write the value 0100_0000_0000_0000b to the register.
Quoted 7 lines
while the code in
bonito.cresets the bits to 0 on each write.Comments?
--
MST--
Huacai Chen
Signature · 1 line
Huacai Chen
Quoted 3 lines · chen huacai
Please see
bonito64_pcibios_config_access()inarch/mips/pci/ops-bonito64.cof Linux kernel code. You will find something useful.
Thanks!
I found this:
/* Clear aborts */
BONITO_PCICMD |= BONITO_PCICMD_MABORT_CLR | BONITO_PCICMD_MTABORT_CLR;
BONITO_PCIMAP_CFG = (addr >> 16) | type;
/* Flush Bonito register block */
dummy = BONITO_PCIMAP_CFG;
mmiowb();
addrp = CFG_SPACE_REG(addr & 0xffff);
if (access_type == PCI_ACCESS_WRITE) {
writel(cpu_to_le32(*data), addrp);
/* Wait till done */
while (BONITO_PCIMSTAT & 0xF);
} else {
*data = le32_to_cpu(readl(addrp));
}
/* Detect Master/Target abort */
if (BONITO_PCICMD & (BONITO_PCICMD_MABORT_CLR |
BONITO_PCICMD_MTABORT_CLR)) {
/* Error occurred */
/* Clear bits */
BONITO_PCICMD |= (BONITO_PCICMD_MABORT_CLR |
BONITO_PCICMD_MTABORT_CLR);
return -1;
}So it looks like guest will clear bits, perform a transaction then check error bits. In other words, it looks like it assumes that writing 1 to these bits will clear them. Correct?
Quoted 47 lines · Michael S. Tsirkin
Quoted 41 lines · chen huacai
Quoted 3 lines
Because the code in PMON and Linux kernel use these bits to verify r/w operations. If one of them is 1 after r/w, PMON and Linux will consider r/w has failed.
Where's that code in Linux?
Quoted 2 lines
I guess that software will not set them to 1, because it is set by hardware when operation fails.
So I guess just making these write 1 to clear according to spec will work?
Quoted 28 lines · Michael S. Tsirkin
Quoted 15 lines
I see code in
bonito.cthat clears bits:PCI_STATUS_REC_MASTER_ABORT|PCI_STATUS_REC_TARGET_ABORTon each read and write.However
1. I don't see anything in code that would set these bits
2. The PCI spec says this about the status register:Reads to this register behave normally. Writes are slightly different in that bits can be reset, but not set. A one bit is reset (if it is not read-only) whenever the register is written, and the write data in the corresponding bit location is a 1. For instance, to clear bit 14 and not affect any other bits, write the value 0100_0000_0000_0000b to the register.
Quoted 7 lines
while the code in
bonito.cresets the bits to 0 on each write.Comments?
--
MST--
Huacai ChenSignature · 1 line
Huacai Chen
Yes, I think so.
Quoted 92 lines · Michael S. Tsirkin
Quoted 3 lines · chen huacai
Please see
bonito64_pcibios_config_access()inarch/mips/pci/ops-bonito64.cof Linux kernel code. You will find something useful.Thanks!
I found this:/* Clear aborts */
BONITO_PCICMD |=BONITO_PCICMD_MABORT_CLR|BONITO_PCICMD_MTABORT_CLR;BONITO_PCIMAP_CFG = (addr >> 16) | type;
/* Flush Bonito register block */
dummy =BONITO_PCIMAP_CFG;
mmiowb();addrp =
CFG_SPACE_REG(addr & 0xffff);
if (access_type==PCI_ACCESS_WRITE) {
writel(cpu_to_le32(*data), addrp);
/* Wait till done */
while (BONITO_PCIMSTAT&0xF);
} else {
*data = le32_to_cpu(readl(addrp));
}/* Detect Master/Target abort */
if (BONITO_PCICMD& (BONITO_PCICMD_MABORT_CLR|BONITO_PCICMD_MTABORT_CLR)) { /* Error occurred *//* Clear bits */
BONITO_PCICMD |= (BONITO_PCICMD_MABORT_CLR|BONITO_PCICMD_MTABORT_CLR);return -1;
}So it looks like guest will clear bits, perform a transaction then check error bits. In other words, it looks like it assumes that writing 1 to these bits will clear them. Correct?
Quoted 47 lines · Michael S. Tsirkin
Quoted 5 lines · chen huacai
Quoted 3 lines
Because the code in PMON and Linux kernel use these bits to verify r/w operations. If one of them is 1 after r/w, PMON and Linux will consider r/w has failed.
Quoted 36 lines
Where's that code in Linux?
Quoted 2 lines
I guess that software will not set them to 1, because it is set by hardware when operation fails.
So I guess just making these write 1 to clear according to spec will work?
Quoted 28 lines · Michael S. Tsirkin
Quoted 15 lines
I see code in
bonito.cthat clears bits:PCI_STATUS_REC_MASTER_ABORT|PCI_STATUS_REC_TARGET_ABORTon each read and write.However
1. I don't see anything in code that would set these bits
2. The PCI spec says this about the status register:Reads to this register behave normally. Writes are slightly different in that bits can be reset, but not set. A one bit is reset (if it is not read-only) whenever the register is written, and the write data in the corresponding bit location is a 1. For instance, to clear bit 14 and not affect any other bits, write the value 0100_0000_0000_0000b to the register.
Quoted 7 lines
while the code in
bonito.cresets the bits to 0 on each write.Comments?
--
MST--
Huacai Chen--
Huacai Chen
Signature · 1 line
Huacai Chen