Skip to content

Commit 0e776de

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 <alyssa@rosenzweig.io> Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 1bd410d commit 0e776de

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;
@@ -858,6 +860,8 @@ static int apple_dart_of_xlate(struct device *dev,
858860
return -EINVAL;
859861
if (cfg_dart->ias != dart->ias)
860862
return -EINVAL;
863+
if (cfg_dart->locked != dart->locked)
864+
return -EINVAL;
861865
}
862866

863867
cfg->supports_bypass &= dart->supports_bypass;
@@ -1159,6 +1163,11 @@ static irqreturn_t apple_dart_irq(int irq, void *dev)
11591163
return ret;
11601164
}
11611165

1166+
static bool apple_dart_is_locked(struct apple_dart *dart)
1167+
{
1168+
return !!(readl(dart->regs + dart->hw->lock) & dart->hw->lock_bit);
1169+
}
1170+
11621171
static int apple_dart_probe(struct platform_device *pdev)
11631172
{
11641173
int ret;
@@ -1256,6 +1265,7 @@ static int apple_dart_probe(struct platform_device *pdev)
12561265
goto err_clk_disable;
12571266
}
12581267

1268+
dart->locked = apple_dart_is_locked(dart);
12591269
ret = apple_dart_hw_reset(dart);
12601270
if (ret)
12611271
goto err_clk_disable;
@@ -1283,9 +1293,9 @@ static int apple_dart_probe(struct platform_device *pdev)
12831293

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

12911301
err_sysfs_remove:

0 commit comments

Comments
 (0)