Skip to content

Commit 1625c0a

Browse files
alyssarosenzweigjannau
authored andcommitted
iommu/dart: Track if the DART is locked
Locked DARTs require special handling. This can be detected with the configuration register. Check this when probing and save the result. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
1 parent a30b739 commit 1625c0a

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

drivers/iommu/apple-dart.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ struct apple_dart_hw {
197197
* @lock: lock for hardware operations involving this dart
198198
* @pgsize: pagesize supported by this DART
199199
* @supports_bypass: indicates if this DART supports bypass mode
200+
* @locked: indicates if this DART is locked
200201
* @sid2group: maps stream ids to iommu_groups
201202
* @iommu: iommu core device
202203
*/
@@ -217,6 +218,7 @@ struct apple_dart {
217218
u32 pgsize;
218219
u32 num_streams;
219220
u32 supports_bypass : 1;
221+
u32 locked : 1;
220222

221223
struct iommu_group *sid2group[DART_MAX_STREAMS];
222224
struct iommu_device iommu;
@@ -1076,6 +1078,11 @@ static irqreturn_t apple_dart_t8110_irq(int irq, void *dev)
10761078
return IRQ_HANDLED;
10771079
}
10781080

1081+
static bool apple_dart_is_locked(struct apple_dart *dart)
1082+
{
1083+
return !!(readl(dart->regs + dart->hw->lock) & dart->hw->lock_bit);
1084+
}
1085+
10791086
static int apple_dart_probe(struct platform_device *pdev)
10801087
{
10811088
int ret;
@@ -1143,6 +1150,7 @@ static int apple_dart_probe(struct platform_device *pdev)
11431150
goto err_clk_disable;
11441151
}
11451152

1153+
dart->locked = apple_dart_is_locked(dart);
11461154
ret = apple_dart_hw_reset(dart);
11471155
if (ret)
11481156
goto err_clk_disable;
@@ -1165,9 +1173,9 @@ static int apple_dart_probe(struct platform_device *pdev)
11651173

11661174
dev_info(
11671175
&pdev->dev,
1168-
"DART [pagesize %x, %d streams, bypass support: %d, bypass forced: %d] initialized\n",
1176+
"DART [pagesize %x, %d streams, bypass support: %d, bypass forced: %d, locked: %d] initialized\n",
11691177
dart->pgsize, dart->num_streams, dart->supports_bypass,
1170-
dart->pgsize > PAGE_SIZE);
1178+
dart->pgsize > PAGE_SIZE, dart->locked);
11711179
return 0;
11721180

11731181
err_sysfs_remove:

0 commit comments

Comments
 (0)