Skip to content

Commit 9184b1c

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 e89d7eb commit 9184b1c

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;
@@ -853,6 +855,8 @@ static int apple_dart_of_xlate(struct device *dev,
853855
if (cfg_dart) {
854856
if (cfg_dart->pgsize != dart->pgsize)
855857
return -EINVAL;
858+
if (cfg_dart->locked != dart->locked)
859+
return -EINVAL;
856860
}
857861

858862
cfg->supports_bypass &= dart->supports_bypass;
@@ -1156,6 +1160,11 @@ static irqreturn_t apple_dart_irq(int irq, void *dev)
11561160
return ret;
11571161
}
11581162

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

1265+
dart->locked = apple_dart_is_locked(dart);
12561266
ret = apple_dart_hw_reset(dart);
12571267
if (ret)
12581268
goto err_clk_disable;
@@ -1280,9 +1290,9 @@ static int apple_dart_probe(struct platform_device *pdev)
12801290

12811291
dev_info(
12821292
&pdev->dev,
1283-
"DART [pagesize %x, %d streams, bypass support: %d, bypass forced: %d, AS %d -> %d] initialized\n",
1293+
"DART [pagesize %x, %d streams, bypass support: %d, bypass forced: %d, locked: %d, AS %d -> %d] initialized\n",
12841294
dart->pgsize, dart->num_streams, dart->supports_bypass,
1285-
dart->pgsize > PAGE_SIZE, dart->ias, dart->oas);
1295+
dart->pgsize > PAGE_SIZE, dart->locked, dart->ias, dart->oas);
12861296
return 0;
12871297

12881298
err_sysfs_remove:

0 commit comments

Comments
 (0)