Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp7256068ybp; Wed, 16 Oct 2019 06:12:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqxeYnfNHThVVb8xfjlYrgJypQy9Frm2OtvlFPolBmaznlK8Ayagmkhrxk8hXTxUDEZvZTf1 X-Received: by 2002:a17:906:e113:: with SMTP id gj19mr40210796ejb.203.1571231546186; Wed, 16 Oct 2019 06:12:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571231546; cv=none; d=google.com; s=arc-20160816; b=nwqPqmCWHAgRLVDx25oaZiRxnZN7yHdKXkGhFZWUSYc2iS1icBMhQL7F2BiJDnfofQ vjduQ5gVefEX4wLwIxwBiZSoSzBpofv4KUUxrt8f1uyBNJeyimAkcFi4h1742CUMKG24 PX4BForlUEjGjoGltEZXRp1PN4lVJArZi+QRzeWcV/UChdMBlC5MCSF5PBlyP2NDhZK7 KLtSD3tmgE7S64T3BLTVybxM7b/1jLFHyyNk16StpqEy2skU6Ed2MEaRxldEhRZcukOO scaeiYzSZgel8nBvKM9Lqv6Bps86TJj4FPwB1sSV8Z2DAOGkdRrlD8fxToV8k/jC86vW pw/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=bGeptUl5VWaDWJe0kbVIKH1TVehn3Zah8WEOJT4L97c=; b=tqzGRCqju0PvJnfjUlunF7dMUAGsjrEVYCWeumrQNNa/P0kQute8+NXUONhLKu81EB E+pfF5TA5kg2QU2URON3bLavNcgtetCuaTUKXmeZQ+6K5UFN6hdshXPPx/ZZTTvfk5p6 PcwEk2AxFOc0rMRlAoDqJTLLaE6ogfocE/3dPLUYNIzxYuv5/hakrXp/9KV8TyZbWWoh OpZSFteqWBh0ACU102zjQInjTOVn4IH9MSzCVJJkXX7X0TOuCH6vWME14bRsUEOaot4G akS4zwCQ75GufKZILQ/EzKotrELhDkl6tDmfKAv8tdBqTM03qtgFkM8YkAiw4GuIb4Ls EIZg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p18si16932027ejn.370.2019.10.16.06.12.02; Wed, 16 Oct 2019 06:12:26 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390150AbfJPImr (ORCPT + 99 others); Wed, 16 Oct 2019 04:42:47 -0400 Received: from smtp2.goneo.de ([85.220.129.33]:59808 "EHLO smtp2.goneo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731936AbfJPImr (ORCPT ); Wed, 16 Oct 2019 04:42:47 -0400 Received: from localhost (localhost [127.0.0.1]) by smtp2.goneo.de (Postfix) with ESMTP id 8B717240A7C; Wed, 16 Oct 2019 10:42:43 +0200 (CEST) X-Virus-Scanned: by goneo X-Spam-Flag: NO X-Spam-Score: -3.08 X-Spam-Level: X-Spam-Status: No, score=-3.08 tagged_above=-999 tests=[ALL_TRUSTED=-1, AWL=-0.180, BAYES_00=-1.9] autolearn=ham Received: from smtp2.goneo.de ([127.0.0.1]) by localhost (smtp2.goneo.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id h5fgb4HpxPzc; Wed, 16 Oct 2019 10:42:42 +0200 (CEST) Received: from lem-wkst-02.lemonage (hq.lemonage.de [87.138.178.34]) by smtp2.goneo.de (Postfix) with ESMTPSA id B4BA5240FB1; Wed, 16 Oct 2019 10:42:41 +0200 (CEST) Date: Wed, 16 Oct 2019 10:42:37 +0200 From: Lars Poeschel To: Jakub Kicinski Cc: Jilayne Lovejoy , Kate Stewart , Allison Randal , Greg Kroah-Hartman , Thomas Gleixner , Steve Winslow , "Gustavo A. R. Silva" , Johan Hovold , "open list:NFC SUBSYSTEM" , open list , Claudiu Beznea Subject: Re: [PATCH v9 4/7] nfc: pn533: Split pn533 init & nfc_register Message-ID: <20191016084236.GA6610@lem-wkst-02.lemonage> References: <20191008140544.17112-1-poeschel@lemonage.de> <20191008140544.17112-5-poeschel@lemonage.de> <20191009174023.528c278b@cakuba.netronome.com> <20191015095124.GA17778@lem-wkst-02.lemonage> <20191015091642.6f49dd8f@cakuba.netronome.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191015091642.6f49dd8f@cakuba.netronome.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 15, 2019 at 09:16:42AM -0700, Jakub Kicinski wrote: > On Tue, 15 Oct 2019 11:51:24 +0200, Lars Poeschel wrote: > > > > - priv->nfc_dev = nfc_allocate_device(&pn533_nfc_ops, protocols, > > > > - priv->ops->tx_header_len + > > > > - PN533_CMD_DATAEXCH_HEAD_LEN, > > > > - priv->ops->tx_tail_len); > > > > - if (!priv->nfc_dev) { > > > > - rc = -ENOMEM; > > > > - goto destroy_wq; > > > > - } > > > > - > > > > - nfc_set_parent_dev(priv->nfc_dev, parent); > > > > - nfc_set_drvdata(priv->nfc_dev, priv); > > > > - > > > > - rc = nfc_register_device(priv->nfc_dev); > > > > - if (rc) > > > > - goto free_nfc_dev; > > > > > > Aren't you moving too much out of here? Looking at commit 32ecc75ded72 > > > ("NFC: pn533: change order operations in dev registation") it seems like > > > IRQ handler may want to access the data structures, do this change not > > > reintroduce the problem? > > > > Yes, you are right, there could be a problem if an irq gets served > > before the driver is registered to the nfc subsystem. > > Well, but the purpose of this patch is exactly that: Prevent use of nfc > > subsystem before the chip is fully initialized. > > To address this, I would not change the part above, but move the > > request_threaded_irq to the very bottom in pn533_i2c_probe, after the > > call to pn53x_register_nfc. So it is not possible to use nfc before the > > chip is initialized and irqs don't get served before the driver is > > registered to nfc subsystem. > > Thank you for this! > > I will include this in v10 of the patchset. > > You can run nfc_allocate_device() etc. early, then allocate the IRQ, > and then run nfc_register_device(), would that work? Is that what you > have in mind? Well, I think my proposed solution above would technically do it, but I think I will do it like you proposed. I think for someone reading the code it is far more easier to understand, what the idea behind it is, if the irq is requested right between nfc_allocate_device and nfc_register_device. Thanks again!