Skip to content

Commit e57db50

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 a373a2c commit e57db50

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
@@ -197,6 +197,7 @@ struct apple_dart_hw {
197197
* @lock: lock for hardware operations involving this dart
198198
* @pgsize: pagesize supported by this DART
199199
* @supports_bypass: indicates if this DART supports bypass mode
200+
* @locked: indicates if this DART is locked
200201
* @sid2group: maps stream ids to iommu_groups
201202
* @iommu: iommu core device
202203
*/
@@ -217,6 +218,7 @@ struct apple_dart {
217218
u32 pgsize;
218219
u32 num_streams;
219220
u32 supports_bypass : 1;
221+
u32 locked : 1;
220222

221223
struct iommu_group *sid2group[DART_MAX_STREAMS];
222224
struct iommu_device iommu;
@@ -809,6 +811,8 @@ static int apple_dart_of_xlate(struct device *dev,
809811
if (cfg_dart) {
810812
if (cfg_dart->pgsize != dart->pgsize)
811813
return -EINVAL;
814+
if (cfg_dart->locked != dart->locked)
815+
return -EINVAL;
812816
}
813817

814818
cfg->supports_bypass &= dart->supports_bypass;
@@ -1097,6 +1101,11 @@ static irqreturn_t apple_dart_t8110_irq(int irq, void *dev)
10971101
return IRQ_HANDLED;
10981102
}
10991103

1104+
static bool apple_dart_is_locked(struct apple_dart *dart)
1105+
{
1106+
return !!(readl(dart->regs + dart->hw->lock) & dart->hw->lock_bit);
1107+
}
1108+
11001109
static int apple_dart_probe(struct platform_device *pdev)
11011110
{
11021111
int ret;
@@ -1164,6 +1173,7 @@ static int apple_dart_probe(struct platform_device *pdev)
11641173
goto err_clk_disable;
11651174
}
11661175

1176+
dart->locked = apple_dart_is_locked(dart);
11671177
ret = apple_dart_hw_reset(dart);
11681178
if (ret)
11691179
goto err_clk_disable;
@@ -1189,9 +1199,9 @@ static int apple_dart_probe(struct platform_device *pdev)
11891199

11901200
dev_info(
11911201
&pdev->dev,
1192-
"DART [pagesize %x, %d streams, bypass support: %d, bypass forced: %d] initialized\n",
1202+
"DART [pagesize %x, %d streams, bypass support: %d, bypass forced: %d, locked: %d] initialized\n",
11931203
dart->pgsize, dart->num_streams, dart->supports_bypass,
1194-
dart->pgsize > PAGE_SIZE);
1204+
dart->pgsize > PAGE_SIZE, dart->locked);
11951205
return 0;
11961206

11971207
err_sysfs_remove:

0 commit comments

Comments
 (0)