Skip to content

Commit 5bc9f07

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 1bd2489 commit 5bc9f07

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;
@@ -1154,6 +1158,11 @@ static irqreturn_t apple_dart_irq(int irq, void *dev)
11541158
return ret;
11551159
}
11561160

1161+
static bool apple_dart_is_locked(struct apple_dart *dart)
1162+
{
1163+
return !!(readl(dart->regs + dart->hw->lock) & dart->hw->lock_bit);
1164+
}
1165+
11571166
static int apple_dart_probe(struct platform_device *pdev)
11581167
{
11591168
int ret;
@@ -1251,6 +1260,7 @@ static int apple_dart_probe(struct platform_device *pdev)
12511260
goto err_clk_disable;
12521261
}
12531262

1263+
dart->locked = apple_dart_is_locked(dart);
12541264
ret = apple_dart_hw_reset(dart);
12551265
if (ret)
12561266
goto err_clk_disable;
@@ -1278,9 +1288,9 @@ static int apple_dart_probe(struct platform_device *pdev)
12781288

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

12861296
err_sysfs_remove:

0 commit comments

Comments
 (0)