From patchwork Wed Jun 7 08:18:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiawen Wu X-Patchwork-Id: 104340 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp100899vqr; Wed, 7 Jun 2023 01:35:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6NdeT4oWvuly+tA2hllcaAIYmDDLhJuVRvIhCa2+p3L5IxEdEXdB62GQEJDKqy8e1GLeWA X-Received: by 2002:a05:6a21:3a85:b0:117:fd0:9694 with SMTP id zv5-20020a056a213a8500b001170fd09694mr1395102pzb.15.1686126908667; Wed, 07 Jun 2023 01:35:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686126908; cv=none; d=google.com; s=arc-20160816; b=uyKj50jAodUMnDeOcWcd0evP3laDeFMYa0/6G+FW3ko4f+10FeXDtL4YYqBMb8tGsl 1mx3A5ch1wNKoKZt2rC+ZfeulliJb/GNwTTOYAM1Eifv01o2FQxRuAz1p0MKVL2V9KpB c71tYMdpjylC9plMM9Xxr6qrlqeK0wj99pdV3QoTwGisj7Nrp2W/3IumB7UVl6NCMCJN 2/vrEuSTlBDQ9Izg+X2xhVkF7lFZPEDQkf6E5G2IPrWOBk1/7+oBnS96Cpd9w3H5KBX6 cfxxR5IA+gZv3ZWzWuVvOOJxcxoPSo8ZDnPEY7HU3lz30kLyJkvv4i0m6BM2lhtCjFIW TUkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from; bh=8KH2EOUtzNpoHkNRIVw9bJG5SpQlt7xPL9FfHwh6eNw=; b=yRCMTZLjJ4fmhuxVxyBPQenjY68JOY7Z5Yxj6U6ZqxPq895Odq91iueCi4RuqQIWne RfP/CX+xoGA+rNEJhcQH0gExsog+mYqXt9AxSeIi+IqBGlbtfB5MYdgtxVD/gvUneAsz WNq8M5AobZ5tLQkTHl5EEB5SSd3gFbseC3EgPWlQFFv5gd+iNW6+JTHhZwQSsHu58xgM LNYDsbzX5cBQgcqYMLHtkyAVeUincxxh38hqc+DFVxPeUzsu2T/rndAKeF+BTC86RbAQ 7yhnaly9QemqTLGyzyWRDNIyLxX+e+Plcc6wHkBSngqB4lleHfGSspNZrA7kAVw6IZNH DKGA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u7-20020a17090341c700b001b04bc1f28csi8827186ple.517.2023.06.07.01.34.53; Wed, 07 Jun 2023 01:35:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239117AbjFGIVX (ORCPT + 99 others); Wed, 7 Jun 2023 04:21:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239098AbjFGIVG (ORCPT ); Wed, 7 Jun 2023 04:21:06 -0400 Received: from smtpbg153.qq.com (smtpbg153.qq.com [13.245.218.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C60851FDC; Wed, 7 Jun 2023 01:20:52 -0700 (PDT) X-QQ-mid: bizesmtp81t1686126015tij1hqko Received: from wxdbg.localdomain.com ( [122.235.137.64]) by bizesmtp.qq.com (ESMTP) with id ; Wed, 07 Jun 2023 16:20:06 +0800 (CST) X-QQ-SSF: 01400000000000J0Z000000A0000000 X-QQ-FEAT: +ynUkgUhZJlWz8h9pkBblPfRUT02IjaMSbr4acK3xfZ6D3K7hFxp/p1AGukcB twgiMIpKrFXolURkQR1vr51Zd9RxTg8ZuBnaSDm8iHlBl2RWNYAMaR350cG1JVezHidLoEX ZIrT8u7K1YybOuoUpMfCA8UGUPBQPmOYOnaNRheQ6xKboqrdmJ8B0i9tqXpKA86mE69XEWQ CbdZhy3Fb2SiAq8sBTRoGDo3YWI/ng/sWYvtLyPw7ae5PEkfri+DMfx5uRa6QkWPiZTM2AK 6UV6zrqzGBRICvX0XNxubrWESmBTu79LaDXHIbCIoNMYxvyDqL2y8s/DrxevhTGYntkFW+e KG4QAOntDaxCGDjcaQSYV9zPkE30/FR8LRuMYRCJB5T3g1D2KxeBQkcL+Xk5Q== X-QQ-GoodBg: 2 X-BIZMAIL-ID: 16544725819709452032 From: Jiawen Wu To: linus.walleij@linaro.org, brgl@bgdev.pl, shreeya.patel@collabora.com, andy.shevchenko@gmail.com, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jiawen Wu Subject: [PATCH v2] gpiolib: Fix GPIO chip IRQ initialization restriction Date: Wed, 7 Jun 2023 16:18:03 +0800 Message-Id: <20230607081803.778223-1-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:trustnetic.com:qybglogicsvrgz:qybglogicsvrgz5a-1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768032209416741773?= X-GMAIL-MSGID: =?utf-8?q?1768032209416741773?= In case of gpio-regmap, IRQ chip is added by regmap-irq and associated with GPIO chip by gpiochip_irqchip_add_domain(). The initialization flag was not added in gpiochip_irqchip_add_domain(), causing gpiochip_to_irq() to return -EPROBE_DEFER. Fixes: 5467801f1fcb ("gpio: Restrict usage of GPIO chip irq members before initialization") Signed-off-by: Jiawen Wu Reviewed-by: Andy Shevchenko Reviewed-by: Linus Walleij Reviewed-by: Michael Walle Tested-by: Michael Walle # on kontron-sl28 --- v1 -> v2: - add compiler barrier --- drivers/gpio/gpiolib.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index a7220e04a93e..9ecf93cbd801 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1792,6 +1792,14 @@ int gpiochip_irqchip_add_domain(struct gpio_chip *gc, gc->to_irq = gpiochip_to_irq; gc->irq.domain = domain; + /* + * Using barrier() here to prevent compiler from reordering + * gc->irq.initialized before adding irqdomain. + */ + barrier(); + + gc->irq.initialized = true; + return 0; } EXPORT_SYMBOL_GPL(gpiochip_irqchip_add_domain);