Skip to content

Commit 64a1493

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 0f196d6 commit 64a1493

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;
@@ -863,6 +865,8 @@ static int apple_dart_of_xlate(struct device *dev,
863865
return -EINVAL;
864866
if (cfg_dart->ias != dart->ias)
865867
return -EINVAL;
868+
if (cfg_dart->locked != dart->locked)
869+
return -EINVAL;
866870
}
867871

868872
cfg->supports_bypass &= dart->supports_bypass;
@@ -1164,6 +1168,11 @@ static irqreturn_t apple_dart_irq(int irq, void *dev)
11641168
return ret;
11651169
}
11661170

1171+
static bool apple_dart_is_locked(struct apple_dart *dart)
1172+
{
1173+
return !!(readl(dart->regs + dart->hw->lock) & dart->hw->lock_bit);
1174+
}
1175+
11671176
static int apple_dart_probe(struct platform_device *pdev)
11681177
{
11691178
int ret;
@@ -1261,6 +1270,7 @@ static int apple_dart_probe(struct platform_device *pdev)
12611270
goto err_clk_disable;
12621271
}
12631272

1273+
dart->locked = apple_dart_is_locked(dart);
12641274
ret = apple_dart_hw_reset(dart);
12651275
if (ret)
12661276
goto err_clk_disable;
@@ -1288,9 +1298,9 @@ static int apple_dart_probe(struct platform_device *pdev)
12881298

12891299
dev_info(
12901300
&pdev->dev,
1291-
"DART [pagesize %x, %d streams, bypass support: %d, bypass forced: %d, AS %d -> %d] initialized\n",
1301+
"DART [pagesize %x, %d streams, bypass support: %d, bypass forced: %d, locked: %d, AS %d -> %d] initialized\n",
12921302
dart->pgsize, dart->num_streams, dart->supports_bypass,
1293-
dart->pgsize > PAGE_SIZE, dart->ias, dart->oas);
1303+
dart->pgsize > PAGE_SIZE, dart->locked, dart->ias, dart->oas);
12941304
return 0;
12951305

12961306
err_sysfs_remove:

0 commit comments

Comments
 (0)