[PATCH 2/9] powerpc/powernv: Use CPU-endian hub diag-data type in pnv_eeh_get_and_dump_hub_diag()

Gavin Shan gwshan at linux.vnet.ibm.com
Tue Aug 2 14:10:30 AEST 2016


The hub diag-data type is filled with big-endian data by OPAL call
opal_pci_get_hub_diag_data(). We need convert it to CPU-endian value
before using it. The issue is reported by sparse as pointed by Michael
Ellerman:

  gwshan at gwshan:~/sandbox/l$ make C=2 CF=-D__CHECK_ENDIAN__ \
                        arch/powerpc/platforms/powernv/eeh-powernv.o
       :
  arch/powerpc/platforms/powernv/eeh-powernv.c:1309:21: \
  warning: restricted __be16 degrades to integer
  arch/powerpc/platforms/powernv/eeh-powernv.c:1309:21: \
  warning: restricted __be16 degrades to integer
  arch/powerpc/platforms/powernv/eeh-powernv.c:1309:21: \
  warning: restricted __be16 degrades to integer
  arch/powerpc/platforms/powernv/eeh-powernv.c:1309:21: \
  warning: restricted __be16 degrades to integer
  arch/powerpc/platforms/powernv/eeh-powernv.c:1309:21: \
  warning: restricted __be16 degrades to integer

This converts hub diag-data type to CPU-endian before using it in
pnv_eeh_get_and_dump_hub_diag().

Fixes: 2a485ad7c88d ("powerpc/powernv: Drop PHB operation next_error()")
Cc: stable at vger.kernel.org # v4.1+
Suggested-by: Michael Ellerman <mpe at ellerman.id.au>
Signed-off-by: Gavin Shan <gwshan at linux.vnet.ibm.com>
---
 arch/powerpc/platforms/powernv/eeh-powernv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/powernv/eeh-powernv.c b/arch/powerpc/platforms/powernv/eeh-powernv.c
index 75363d9..8fec7a3 100644
--- a/arch/powerpc/platforms/powernv/eeh-powernv.c
+++ b/arch/powerpc/platforms/powernv/eeh-powernv.c
@@ -1306,7 +1306,7 @@ static void pnv_eeh_get_and_dump_hub_diag(struct pci_controller *hose)
 		return;
 	}
 
-	switch (data->type) {
+	switch (be16_to_cpu(data->type)) {
 	case OPAL_P7IOC_DIAG_TYPE_RGC:
 		pr_info("P7IOC diag-data for RGC\n\n");
 		pnv_eeh_dump_hub_diag_common(data);
-- 
2.1.0



More information about the Linuxppc-dev mailing list