From patchwork Tue Aug 20 08:05:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 171781 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp4068804ily; Tue, 20 Aug 2019 01:05:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwBm2mn6fqrNSIenavK18rMMcT93oikqo7rF/KM9OmP1sLHKMtLf/rpFnoU5YFebRi8qhtS X-Received: by 2002:a17:90a:fe0c:: with SMTP id ck12mr25448153pjb.74.1566288335049; Tue, 20 Aug 2019 01:05:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566288335; cv=none; d=google.com; s=arc-20160816; b=bJnzxLct0CFiU2kVxgZKkVWpwzYofn95FQsPB7TVS1MykxdsOfq8fBCqELF/Nsh9hO axzC14snwUOUBIzISBdgo5FrMWegnsN5m7smIMkkWMzAfMnnmsqfMmTejT/rz7INaOLa dJgbSEK3WG9i3yZhQs/+AJp5hnxrVahFNt1v7iZIupCJRHFVYVHz5fCp3jS6xgggOq1C +kcVQALipvo3hKKMbKoYyO3VotKURS5QTAgWU2FE1BpZi1xpj6WfKUFxK1RD1HT8Il8V NP7Fqssvs/XsEQ7URKXAKjh1dGTcuii71PNPz2GqzGaFSMUqmXMQOLB8ipP+my9VhTqE ATNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=mAOQfKuPDv59rAP/50Uq7dXiqumJsVP5h6BG03JNo8Q=; b=mST5K1Hmfd+5ybQQJc4EGF8wM/gkpJfWeufLqgazBgNfUPM71B+3ha0/xwmLPLs2oa 9O8ui+JRcHHRhGqRJquQMKgn82ZuqirEmjPrqEhem8dIMBvd+386sNq2shpS/sP5ZqYj 0MdnJZG541hnLzpUv70T2opBT0YI/2WtssU2CTvNMyP2roUYrpLe5ZrQ51Q9jLsjd2jM Wqy3GOQl7OhVa4IGaLk/bU8ZRjsCoBWFNt4eDrRfoYTrcJczLSgm69j5FqSx7F3/NHeC chnbyCzMgsQpQZzpnkU03CdxUjuQT7AOk14h+BNAXe3CoE+85aTDgDO/MbpSC8NU175N DMNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jqnHPhyb; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x20si10924084pjt.50.2019.08.20.01.05.34; Tue, 20 Aug 2019 01:05:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jqnHPhyb; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728595AbfHTIFe (ORCPT + 5 others); Tue, 20 Aug 2019 04:05:34 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:37215 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726049AbfHTIFe (ORCPT ); Tue, 20 Aug 2019 04:05:34 -0400 Received: by mail-lf1-f66.google.com with SMTP id c9so3421320lfh.4 for ; Tue, 20 Aug 2019 01:05:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mAOQfKuPDv59rAP/50Uq7dXiqumJsVP5h6BG03JNo8Q=; b=jqnHPhybhbHcvdfAzVhhj6bXrAwKiN/cMJDgpXvEhVMT4l16f/n8QXBTX0x1HtqKLy C1RYOqqsbe6pGprK/gm0KXdTNY/I7h2iClPwvqnmMsiIw9GRKFP0Zmu0j/rSsO6yfSxv AfqzxX0aV6JV+xe7hZXlV/vB56yA/26/k2VVIGg0JB8ZD2Bp4FkCmDpsYywySMKwbxiU cBfgzIqbdbsq8cAGcF6+4FrTWo0mFY+zdWH+wNCG/W0pYRiEqDfO5UwvjnHfpfTOqqtJ PHuhzxsk5frZqkqo4rZ0MYS67hvtTekNy5ORNoxRA0Z9IuoUn4C4ZH8bLmqPQCjmp2p8 n0CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mAOQfKuPDv59rAP/50Uq7dXiqumJsVP5h6BG03JNo8Q=; b=GhqprFsF55qc06wm0TgnYp6w7Go9xjfOOtrpfuGfRQ2dMzbo4T9UpKyCqogc0Z7bnr 3CIpZXGH6fhkyMSuObr9HE9O3gADMghxl22NnhdK8Y91O7FIt4+VW6/e/4ivWLdfEcw9 8PYrw6NOkMV4wPYO1Il8ufBNML5RQgKwL2PDGY8av2vgh3yXETSJ1HRoqA5kfSs6LYUm dgoVNJHWBZEBgw8K59yp2wE5TNbXpWildfM12edmKiWJnsjh5gduNfsAToiHy5CQnaTB 6KzHR9NDIl21DU2GljjzpakN+WUkSK3TvTDyaVSec5uvFFJQtJ9gv5ki1nMVMvb7GQrB +dlA== X-Gm-Message-State: APjAAAUj83D7r7p1Ooa+oz2yRMUkrY0cZFR+g2gzSqCHVbdin4cLREHl XOh4abzZbOZXy/g72eRGspkie+RXLTA= X-Received: by 2002:a19:4349:: with SMTP id m9mr14554832lfj.64.1566288331681; Tue, 20 Aug 2019 01:05:31 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id i123sm3014957lfi.72.2019.08.20.01.05.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 01:05:30 -0700 (PDT) From: Linus Walleij To: linux-gpio@vger.kernel.org Cc: Bartosz Golaszewski , Linus Walleij , Thierry Reding , Grygorii Strashko , Wei Xu , Andy Shevchenko Subject: [PATCH] gpio: Fix irqchip initialization order Date: Tue, 20 Aug 2019 10:05:27 +0200 Message-Id: <20190820080527.11796-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The new API for registering a gpio_irq_chip along with a gpio_chip has a different semantic ordering than the old API which added the irqchip explicitly after registering the gpio_chip. Move the calls to add the gpio_irq_chip *last* in the function, so that the different hooks setting up OF and ACPI and machine gpio_chips are called *before* we try to register the interrupts, preserving the elder semantic order. This cropped up in the PL061 driver which used to work fine with no special ACPI quirks, but started to misbehave using the new API. Fixes: e0d897289813 ("gpio: Implement tighter IRQ chip integration") Cc: Thierry Reding Cc: Grygorii Strashko Cc: Wei Xu Cc: Andy Shevchenko Reported-by: Wei Xu Reported-by: Andy Shevchenko Signed-off-by: Linus Walleij --- Wei: it would be great if you could test this and confirm if it solves your problem, so I can apply this for fixes. --- drivers/gpio/gpiolib.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) -- 2.21.0 Tested-by: Wei Xu diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 80a2a2cb673b..cca749010cd0 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1373,21 +1373,13 @@ int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data, if (status) goto err_remove_from_list; - status = gpiochip_irqchip_init_valid_mask(chip); - if (status) - goto err_remove_from_list; - status = gpiochip_alloc_valid_mask(chip); if (status) - goto err_remove_irqchip_mask; - - status = gpiochip_add_irqchip(chip, lock_key, request_key); - if (status) - goto err_free_gpiochip_mask; + goto err_remove_from_list; status = of_gpiochip_add(chip); if (status) - goto err_remove_chip; + goto err_free_gpiochip_mask; status = gpiochip_init_valid_mask(chip); if (status) @@ -1413,6 +1405,14 @@ int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data, machine_gpiochip_add(chip); + status = gpiochip_irqchip_init_valid_mask(chip); + if (status) + goto err_remove_acpi_chip; + + status = gpiochip_add_irqchip(chip, lock_key, request_key); + if (status) + goto err_remove_irqchip_mask; + /* * By first adding the chardev, and then adding the device, * we get a device node entry in sysfs under @@ -1424,21 +1424,21 @@ int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data, if (gpiolib_initialized) { status = gpiochip_setup_dev(gdev); if (status) - goto err_remove_acpi_chip; + goto err_remove_irqchip; } return 0; +err_remove_irqchip: + gpiochip_irqchip_remove(chip); +err_remove_irqchip_mask: + gpiochip_irqchip_free_valid_mask(chip); err_remove_acpi_chip: acpi_gpiochip_remove(chip); err_remove_of_chip: gpiochip_free_hogs(chip); of_gpiochip_remove(chip); -err_remove_chip: - gpiochip_irqchip_remove(chip); err_free_gpiochip_mask: gpiochip_free_valid_mask(chip); -err_remove_irqchip_mask: - gpiochip_irqchip_free_valid_mask(chip); err_remove_from_list: spin_lock_irqsave(&gpio_lock, flags); list_del(&gdev->list);