Skip to content

Commit 9ee5d1a

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 519a3ca commit 9ee5d1a

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;
@@ -1045,6 +1047,11 @@ static irqreturn_t apple_dart_t8110_irq(int irq, void *dev)
10451047
return IRQ_HANDLED;
10461048
}
10471049

1050+
static bool apple_dart_is_locked(struct apple_dart *dart)
1051+
{
1052+
return !!(readl(dart->regs + dart->hw->lock) & dart->hw->lock_bit);
1053+
}
1054+
10481055
static int apple_dart_probe(struct platform_device *pdev)
10491056
{
10501057
int ret;
@@ -1114,6 +1121,7 @@ static int apple_dart_probe(struct platform_device *pdev)
11141121

11151122
dart->force_bypass = dart->pgsize > PAGE_SIZE;
11161123

1124+
dart->locked = apple_dart_is_locked(dart);
11171125
ret = apple_dart_hw_reset(dart);
11181126
if (ret)
11191127
goto err_clk_disable;
@@ -1136,8 +1144,8 @@ static int apple_dart_probe(struct platform_device *pdev)
11361144

11371145
dev_info(
11381146
&pdev->dev,
1139-
"DART [pagesize %x, %d streams, bypass support: %d, bypass forced: %d] initialized\n",
1140-
dart->pgsize, dart->num_streams, dart->supports_bypass, dart->force_bypass);
1147+
"DART [pagesize %x, %d streams, bypass support: %d, bypass forced: %d, locked: %d] initialized\n",
1148+
dart->pgsize, dart->num_streams, dart->supports_bypass, dart->force_bypass, dart->locked);
11411149
return 0;
11421150

11431151
err_sysfs_remove:

0 commit comments

Comments
 (0)