Skip to content

Commit 9371220

Browse files
Bartosz Golaszewskilinusw
authored andcommitted
pinctrl: qcom: msm: mark certain pins as invalid for interrupts
On some platforms, the UFS-reset pin has no interrupt logic in TLMM but is nevertheless registered as a GPIO in the kernel. This enables the user-space to trigger a BUG() in the pinctrl-msm driver by running, for example: `gpiomon -c 0 113` on RB2. The exact culprit is requesting pins whose intr_detection_width setting is not 1 or 2 for interrupts. This hits a BUG() in msm_gpio_irq_set_type(). Potentially crashing the kernel due to an invalid request from user-space is not optimal, so let's go through the pins and mark those that would fail the check as invalid for the irq chip as we should not even register them as available irqs. This function can be extended if we determine that there are more corner-cases like this. Fixes: f365be0 ("pinctrl: Add Qualcomm TLMM driver") Cc: [email protected] Reviewed-by: Bjorn Andersson <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent e04c78d commit 9371220

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

drivers/pinctrl/qcom/pinctrl-msm.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,25 @@ static bool msm_gpio_needs_dual_edge_parent_workaround(struct irq_data *d,
10381038
test_bit(d->hwirq, pctrl->skip_wake_irqs);
10391039
}
10401040

1041+
static void msm_gpio_irq_init_valid_mask(struct gpio_chip *gc,
1042+
unsigned long *valid_mask,
1043+
unsigned int ngpios)
1044+
{
1045+
struct msm_pinctrl *pctrl = gpiochip_get_data(gc);
1046+
const struct msm_pingroup *g;
1047+
int i;
1048+
1049+
bitmap_fill(valid_mask, ngpios);
1050+
1051+
for (i = 0; i < ngpios; i++) {
1052+
g = &pctrl->soc->groups[i];
1053+
1054+
if (g->intr_detection_width != 1 &&
1055+
g->intr_detection_width != 2)
1056+
clear_bit(i, valid_mask);
1057+
}
1058+
}
1059+
10411060
static int msm_gpio_irq_set_type(struct irq_data *d, unsigned int type)
10421061
{
10431062
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
@@ -1441,6 +1460,7 @@ static int msm_gpio_init(struct msm_pinctrl *pctrl)
14411460
girq->default_type = IRQ_TYPE_NONE;
14421461
girq->handler = handle_bad_irq;
14431462
girq->parents[0] = pctrl->irq;
1463+
girq->init_valid_mask = msm_gpio_irq_init_valid_mask;
14441464

14451465
ret = devm_gpiochip_add_data(pctrl->dev, &pctrl->chip, pctrl);
14461466
if (ret) {

0 commit comments

Comments
 (0)