Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2686243ybl; Thu, 29 Aug 2019 11:28:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqz4SBJNBmAa2ItoOgwpvH9NOuE2Yho/3NICIpYuEGdcvL+RlzxvQ67kPIfFdkPV/qSqL4O0 X-Received: by 2002:a17:902:848c:: with SMTP id c12mr11397100plo.47.1567103281001; Thu, 29 Aug 2019 11:28:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567103280; cv=none; d=google.com; s=arc-20160816; b=cAOpkUP4bpNCVrhs737/cvoOc9m+buxyPjfHTQP/up5mDWGMVixlGsXuq5zNTqQHqi JcokVMBhORfne2Jo7tvGuajzYJHOC9ZI8BqY9BTWvfECNT0PX5N22RpzR82lHNAW0OHs dRbxDzN/W8eaxB0+4+/Dk86ttzONggtai6T/4j2hbkOMO/soaQTyCas/nOFgwJVYDD8v Mh7fVn/2NVyysPtZi6vuROoNjxmkq/BxKKC1n7T8TFUwzAkVR4WRQfUCGMczF4i5JG8N GsLC1uAYWxX3YzFniA5wRZqEMf7hlA2ZkiJbiUpJGsoj+MhpaWtfka35Ggu2Kttpwydx wnog== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Yi4YeRXRGehmju405DmMjgXHjqXaXZigjueHhWkc6dQ=; b=zzxFhKyR03EKFDbxubVQqDJT6kvipPotSpmgEpC9CvgfuMZJKmroF4FU0mXV66NQTw 4ukS1bjQDy0WKWPOmZCKOOM/AAztRkBmLn+7X5TZ2sUPOpby4KWEbBdgpkbwAV4/6oNl 9QJhAMixeAG7UYnRd3jNIaXVIEXca5leSuzLMYrNltowdxzSJCeGRIP4hiG7RQEdnj21 0zH3mBQAu05ywcYXrtf+PBCrc+zW4bS8IQrHNlHRU2qFqZspN1mP7dFpG9zdXOuxHn71 7+cz+SH6zDDZc82K2rWO0V+lhcd/9qprPMeqiqow9jRU5bBuhfR7tbiewZOyXgTq+JIR e/hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LPxdlt4j; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g13si2723125pgo.274.2019.08.29.11.27.45; Thu, 29 Aug 2019 11:28:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@kernel.org header.s=default header.b=LPxdlt4j; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729451AbfH2S04 (ORCPT + 99 others); Thu, 29 Aug 2019 14:26:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:57482 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728558AbfH2SPm (ORCPT ); Thu, 29 Aug 2019 14:15:42 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3D2D42342C; Thu, 29 Aug 2019 18:15:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567102541; bh=mbc88SK90w/+Uoyl1A5Z9fHXLSXvvuFhUGHwFq5VEjA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LPxdlt4jc51i344ngRHxG5qcsbiAkd3xYeNa04aHazXAwxq1rwWkEKyE8j323ii7S OyKjyxYreIXbPwZkqhKsdXkLScthARpfWsUlt/3YAxv9S3749QEhbayuSf6f16CP/i CboIi1Pnpn4y3wotVCICF8d8EJW9B/Jo+JdCMmcM= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Linus Walleij , Thierry Reding , Grygorii Strashko , Andy Shevchenko , Wei Xu , Sasha Levin , linux-gpio@vger.kernel.org Subject: [PATCH AUTOSEL 5.2 75/76] gpio: Fix irqchip initialization order Date: Thu, 29 Aug 2019 14:13:10 -0400 Message-Id: <20190829181311.7562-75-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190829181311.7562-1-sashal@kernel.org> References: <20190829181311.7562-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Linus Walleij [ Upstream commit 48057ed1840fde9239b1e000bea1a0a1f07c5e99 ] 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: Andy Shevchenko Reported-by: Wei Xu Tested-by: Wei Xu Reported-by: Andy Shevchenko Signed-off-by: Linus Walleij Link: https://lore.kernel.org/r/20190820080527.11796-1-linus.walleij@linaro.org Signed-off-by: Sasha Levin --- drivers/gpio/gpiolib.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 4f333d6f2e230..42f9e00ff4d1b 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1371,21 +1371,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) @@ -1411,6 +1403,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 @@ -1422,21 +1422,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); -- 2.20.1