Skip to content

Commit 8b05afe

Browse files
alyssarosenzweigmarcan
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 cdeb4a6 commit 8b05afe

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
* @pgsize: pagesize supported by this DART
198198
* @supports_bypass: indicates if this DART supports bypass mode
199199
* @force_bypass: force bypass mode due to pagesize mismatch?
200+
* @locked: indicates if this DART is locked
200201
* @sid2group: maps stream ids to iommu_groups
201202
* @iommu: iommu core device
202203
*/
@@ -218,6 +219,7 @@ struct apple_dart {
218219
u32 num_streams;
219220
u32 supports_bypass : 1;
220221
u32 force_bypass : 1;
222+
u32 locked : 1;
221223

222224
struct iommu_group *sid2group[DART_MAX_STREAMS];
223225
struct iommu_device iommu;
@@ -1043,6 +1045,11 @@ static irqreturn_t apple_dart_t8110_irq(int irq, void *dev)
10431045
return IRQ_HANDLED;
10441046
}
10451047

1048+
static bool apple_dart_is_locked(struct apple_dart *dart)
1049+
{
1050+
return !!(readl(dart->regs + dart->hw->lock) & dart->hw->lock_bit);
1051+
}
1052+
10461053
static int apple_dart_probe(struct platform_device *pdev)
10471054
{
10481055
int ret;
@@ -1112,6 +1119,7 @@ static int apple_dart_probe(struct platform_device *pdev)
11121119

11131120
dart->force_bypass = dart->pgsize > PAGE_SIZE;
11141121

1122+
dart->locked = apple_dart_is_locked(dart);
11151123
ret = apple_dart_hw_reset(dart);
11161124
if (ret)
11171125
goto err_clk_disable;
@@ -1134,8 +1142,8 @@ static int apple_dart_probe(struct platform_device *pdev)
11341142

11351143
dev_info(
11361144
&pdev->dev,
1137-
"DART [pagesize %x, %d streams, bypass support: %d, bypass forced: %d] initialized\n",
1138-
dart->pgsize, dart->num_streams, dart->supports_bypass, dart->force_bypass);
1145+
"DART [pagesize %x, %d streams, bypass support: %d, bypass forced: %d, locked: %d] initialized\n",
1146+
dart->pgsize, dart->num_streams, dart->supports_bypass, dart->force_bypass, dart->locked);
11391147
return 0;
11401148

11411149
err_sysfs_remove:

0 commit comments

Comments
 (0)