diff options
| -rw-r--r-- | drivers/irqchip/irq-gic-v3-its.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index cae53937feeb..fcfc96f8e0de 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c | |||
| @@ -182,6 +182,14 @@ static struct its_collection *dev_event_to_col(struct its_device *its_dev, | |||
| 182 | return its->collections + its_dev->event_map.col_map[event]; | 182 | return its->collections + its_dev->event_map.col_map[event]; |
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | static struct its_collection *valid_col(struct its_collection *col) | ||
| 186 | { | ||
| 187 | if (WARN_ON_ONCE(col->target_address & GENMASK_ULL(0, 15))) | ||
| 188 | return NULL; | ||
| 189 | |||
| 190 | return col; | ||
| 191 | } | ||
| 192 | |||
| 185 | /* | 193 | /* |
| 186 | * ITS command descriptors - parameters to be encoded in a command | 194 | * ITS command descriptors - parameters to be encoded in a command |
| 187 | * block. | 195 | * block. |
| @@ -439,7 +447,7 @@ static struct its_collection *its_build_mapti_cmd(struct its_node *its, | |||
| 439 | 447 | ||
| 440 | its_fixup_cmd(cmd); | 448 | its_fixup_cmd(cmd); |
| 441 | 449 | ||
| 442 | return col; | 450 | return valid_col(col); |
| 443 | } | 451 | } |
| 444 | 452 | ||
| 445 | static struct its_collection *its_build_movi_cmd(struct its_node *its, | 453 | static struct its_collection *its_build_movi_cmd(struct its_node *its, |
| @@ -458,7 +466,7 @@ static struct its_collection *its_build_movi_cmd(struct its_node *its, | |||
| 458 | 466 | ||
| 459 | its_fixup_cmd(cmd); | 467 | its_fixup_cmd(cmd); |
| 460 | 468 | ||
| 461 | return col; | 469 | return valid_col(col); |
| 462 | } | 470 | } |
| 463 | 471 | ||
| 464 | static struct its_collection *its_build_discard_cmd(struct its_node *its, | 472 | static struct its_collection *its_build_discard_cmd(struct its_node *its, |
| @@ -476,7 +484,7 @@ static struct its_collection *its_build_discard_cmd(struct its_node *its, | |||
| 476 | 484 | ||
| 477 | its_fixup_cmd(cmd); | 485 | its_fixup_cmd(cmd); |
| 478 | 486 | ||
| 479 | return col; | 487 | return valid_col(col); |
| 480 | } | 488 | } |
| 481 | 489 | ||
| 482 | static struct its_collection *its_build_inv_cmd(struct its_node *its, | 490 | static struct its_collection *its_build_inv_cmd(struct its_node *its, |
| @@ -494,7 +502,7 @@ static struct its_collection *its_build_inv_cmd(struct its_node *its, | |||
| 494 | 502 | ||
| 495 | its_fixup_cmd(cmd); | 503 | its_fixup_cmd(cmd); |
| 496 | 504 | ||
| 497 | return col; | 505 | return valid_col(col); |
| 498 | } | 506 | } |
| 499 | 507 | ||
| 500 | static struct its_collection *its_build_int_cmd(struct its_node *its, | 508 | static struct its_collection *its_build_int_cmd(struct its_node *its, |
| @@ -512,7 +520,7 @@ static struct its_collection *its_build_int_cmd(struct its_node *its, | |||
| 512 | 520 | ||
| 513 | its_fixup_cmd(cmd); | 521 | its_fixup_cmd(cmd); |
| 514 | 522 | ||
| 515 | return col; | 523 | return valid_col(col); |
| 516 | } | 524 | } |
| 517 | 525 | ||
| 518 | static struct its_collection *its_build_clear_cmd(struct its_node *its, | 526 | static struct its_collection *its_build_clear_cmd(struct its_node *its, |
| @@ -530,7 +538,7 @@ static struct its_collection *its_build_clear_cmd(struct its_node *its, | |||
| 530 | 538 | ||
| 531 | its_fixup_cmd(cmd); | 539 | its_fixup_cmd(cmd); |
| 532 | 540 | ||
| 533 | return col; | 541 | return valid_col(col); |
| 534 | } | 542 | } |
| 535 | 543 | ||
| 536 | static struct its_collection *its_build_invall_cmd(struct its_node *its, | 544 | static struct its_collection *its_build_invall_cmd(struct its_node *its, |
| @@ -1824,11 +1832,16 @@ static int its_alloc_tables(struct its_node *its) | |||
| 1824 | 1832 | ||
| 1825 | static int its_alloc_collections(struct its_node *its) | 1833 | static int its_alloc_collections(struct its_node *its) |
| 1826 | { | 1834 | { |
| 1835 | int i; | ||
| 1836 | |||
| 1827 | its->collections = kcalloc(nr_cpu_ids, sizeof(*its->collections), | 1837 | its->collections = kcalloc(nr_cpu_ids, sizeof(*its->collections), |
| 1828 | GFP_KERNEL); | 1838 | GFP_KERNEL); |
| 1829 | if (!its->collections) | 1839 | if (!its->collections) |
| 1830 | return -ENOMEM; | 1840 | return -ENOMEM; |
| 1831 | 1841 | ||
| 1842 | for (i = 0; i < nr_cpu_ids; i++) | ||
| 1843 | its->collections[i].target_address = ~0ULL; | ||
| 1844 | |||
| 1832 | return 0; | 1845 | return 0; |
| 1833 | } | 1846 | } |
| 1834 | 1847 | ||
