asahi.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [bug report] iommu: dart: Add t8110 DART support
@ 2023-01-26  9:26 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2023-01-26  9:26 UTC (permalink / raw)
  To: marcan; +Cc: asahi, iommu

Hello Hector Martin,

The patch d8bcc870d99d: "iommu: dart: Add t8110 DART support" from
Jan 13, 2023, leads to the following Smatch static checker warning:

	drivers/iommu/apple-dart.c:991 apple_dart_t8110_irq()
	warn: duplicate check 'error_code == ((((1))) << (3))' (previous on line 989)

drivers/iommu/apple-dart.c
    972 static irqreturn_t apple_dart_t8110_irq(int irq, void *dev)
    973 {
    974         struct apple_dart *dart = dev;
    975         const char *fault_name = NULL;
    976         u32 error = readl(dart->regs + DART_T8110_ERROR);
    977         u32 error_code = FIELD_GET(DART_T8110_ERROR_CODE, error);
    978         u32 addr_lo = readl(dart->regs + DART_T8110_ERROR_ADDR_LO);
    979         u32 addr_hi = readl(dart->regs + DART_T8110_ERROR_ADDR_HI);
    980         u64 addr = addr_lo | (((u64)addr_hi) << 32);
    981         u8 stream_idx = FIELD_GET(DART_T8110_ERROR_STREAM, error);
    982 
    983         if (!(error & DART_T8110_ERROR_FLAG))
    984                 return IRQ_NONE;
    985 
    986         /* there should only be a single bit set but let's use == to be sure */
    987         if (error_code == DART_T8110_ERROR_READ_FAULT)
    988                 fault_name = "READ FAULT";
    989         else if (error_code == DART_T8110_ERROR_WRITE_FAULT)
    990                 fault_name = "WRITE FAULT";
--> 991         else if (error_code == DART_T8110_ERROR_NO_PTE)

DART_T8110_ERROR_NO_PTE and DART_T8110_ERROR_WRITE_FAULT are both BIT(3).

    992                 fault_name = "NO PTE FOR IOVA";
    993         else if (error_code == DART_T8110_ERROR_NO_PMD)
    994                 fault_name = "NO PMD FOR IOVA";
    995         else if (error_code == DART_T8110_ERROR_NO_PGD)
    996                 fault_name = "NO PGD FOR IOVA";
    997         else if (error_code == DART_T8110_ERROR_NO_TTBR)
    998                 fault_name = "NO TTBR FOR IOVA";
    999         else
    1000                 fault_name = "unknown";
    1001 
    1002         dev_err_ratelimited(
    1003                 dart->dev,
    1004                 "translation fault: status:0x%x stream:%d code:0x%x (%s) at 0x%llx",
    1005                 error, stream_idx, error_code, fault_name, addr);
    1006 
    1007         writel(error, dart->regs + DART_T8110_ERROR);
    1008         return IRQ_HANDLED;
    1009 }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-01-26  9:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-26  9:26 [bug report] iommu: dart: Add t8110 DART support Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).