Skip to content

Commit c56a808

Browse files
alyssarosenzweigjannau
authored andcommitted
iommu/dart: Track if the DART is locked
Some DARTs are locked at boot-time. That means they are already configured and we cannot change their configuration, which requires special handling. Locked DARTs are identified in the configuration register. Check this bit when probing and save the result so we can handle accordingly. Signed-off-by: Alyssa Rosenzweig <[email protected]> Signed-off-by: Janne Grunau <[email protected]>
1 parent cf23ad4 commit c56a808

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

drivers/iommu/apple-dart.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ struct apple_dart_hw {
203203
* @lock: lock for hardware operations involving this dart
204204
* @pgsize: pagesize supported by this DART
205205
* @supports_bypass: indicates if this DART supports bypass mode
206+
* @locked: indicates if this DART is locked
206207
* @sid2group: maps stream ids to iommu_groups
207208
* @iommu: iommu core device
208209
*/
@@ -224,6 +225,7 @@ struct apple_dart {
224225
u32 num_streams;
225226
u32 supports_bypass : 1;
226227
u32 four_level : 1;
228+
u32 locked : 1;
227229

228230
dma_addr_t dma_min;
229231
dma_addr_t dma_max;
@@ -854,6 +856,8 @@ static int apple_dart_of_xlate(struct device *dev,
854856
if (cfg_dart) {
855857
if (cfg_dart->pgsize != dart->pgsize)
856858
return -EINVAL;
859+
if (cfg_dart->locked != dart->locked)
860+
return -EINVAL;
857861
}
858862

859863
cfg->supports_bypass &= dart->supports_bypass;
@@ -1157,6 +1161,11 @@ static irqreturn_t apple_dart_irq(int irq, void *dev)
11571161
return ret;
11581162
}
11591163

1164+
static bool apple_dart_is_locked(struct apple_dart *dart)
1165+
{
1166+
return !!(readl(dart->regs + dart->hw->lock) & dart->hw->lock_bit);
1167+
}
1168+
11601169
static int apple_dart_probe(struct platform_device *pdev)
11611170
{
11621171
int ret;
@@ -1254,6 +1263,7 @@ static int apple_dart_probe(struct platform_device *pdev)
12541263
goto err_clk_disable;
12551264
}
12561265

1266+
dart->locked = apple_dart_is_locked(dart);
12571267
ret = apple_dart_hw_reset(dart);
12581268
if (ret)
12591269
goto err_clk_disable;
@@ -1281,9 +1291,9 @@ static int apple_dart_probe(struct platform_device *pdev)
12811291

12821292
dev_info(
12831293
&pdev->dev,
1284-
"DART [pagesize %x, %d streams, bypass support: %d, bypass forced: %d, AS %d -> %d] initialized\n",
1294+
"DART [pagesize %x, %d streams, bypass support: %d, bypass forced: %d, locked: %d, AS %d -> %d] initialized\n",
12851295
dart->pgsize, dart->num_streams, dart->supports_bypass,
1286-
dart->pgsize > PAGE_SIZE, dart->ias, dart->oas);
1296+
dart->pgsize > PAGE_SIZE, dart->locked, dart->ias, dart->oas);
12871297
return 0;
12881298

12891299
err_sysfs_remove:

0 commit comments

Comments
 (0)