Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp121722imj; Wed, 13 Feb 2019 05:45:51 -0800 (PST) X-Google-Smtp-Source: AHgI3IZtDHeINyCrXdi+JBEtfZb7TPBRxTjFcAR32btQH7zWT4L8fFLCLQ8AfMPfg/Pvxjfn48mA X-Received: by 2002:a17:902:f08b:: with SMTP id go11mr610308plb.115.1550065550997; Wed, 13 Feb 2019 05:45:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550065550; cv=none; d=google.com; s=arc-20160816; b=NqDrTU16zH9K4oOopYpdjNgplZ/UxEndvAn4S12EUn32OH0IYin9TJosXPWvaVEgPO ozTa+JgpIdpeLkbaZtykAGhkDz5A+J4yoYFY+04TZ4iqf5Twj849lLeDUTMlW6FHkDf2 wnmwzi4bxwk8XNUT1SZgdSWV8LiKth/qDmQbrPyOOmLtYIIdbgna0MT6CGbCJQ5cII1F o0UNjpYoFUhbAsKbRQJGJ591d3wvec9IfsZJyn+z2RDjeiGa2BNRDG8Pc1fx8zehH9s/ ff0S+vONcykxvt4BZsiHyoaC4TupglOO6SkCgCVlCa++98eDC3RtcDN/6vbo6cSBtzUf FK+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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=rF6hDIv3cmYj7Li/1ZKjWzmBdQxwnPKRNjT1kF5p5lU=; b=bA2WHhUiAZzEx+UHWPE+29bC+M5ZDT1XVmcsA0BQRr39yd/wTQTGnfmhC/NZZt00Vl XUQKsHP0niNydpzcJ+zE2SqMyxjcJsDJNYke/sAUv8vxN3GTrF7l/Evs+X5Rn/Lt1ifG RNBtUEttqGH/atP5+658Ple+nJfrkAmaxk+l2KRHAtMnzygPQFc4aLnIqOYCCd9pQ/cP QveHUZCiuVMmc74KNKP6/xZ01SEqJqIfFJk0bO92yPyT9KEaW2lfEP6B4xbbpBhmZAMS +j1meWJ7wwqR6WFZ90d/p5hl+6q1DXfOdrvIATD4GmN3x2VfHHTxX2lgzADT1RYqwO+f sz5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xjqUn6bd; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a23si15787648pls.384.2019.02.13.05.45.35; Wed, 13 Feb 2019 05:45:50 -0800 (PST) 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=@linaro.org header.s=google header.b=xjqUn6bd; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391501AbfBMKjw (ORCPT + 99 others); Wed, 13 Feb 2019 05:39:52 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:45249 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727058AbfBMKjw (ORCPT ); Wed, 13 Feb 2019 05:39:52 -0500 Received: by mail-wr1-f65.google.com with SMTP id w17so1853268wrn.12 for ; Wed, 13 Feb 2019 02:39:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=rF6hDIv3cmYj7Li/1ZKjWzmBdQxwnPKRNjT1kF5p5lU=; b=xjqUn6bdlHOok8qczM5bVvUhouKJLqXSv4YKiQFX0aNHKdzTOwnxPeSPkJ+jm1NFvz yutU9YqkHq3kNPyDwzJBaPLiS6tIWYNMRQhQ+flx4wXHWQ6lwcJduCmQ9N4YpTiiy+H8 8E8OxE1wSFIxjB3cM/k979U2ny9QVyQG+NUcPBSm42pewB2d1lmulKBfAUr9Gf01Xb07 yvWyx0IGTJ7+hzrwpsT8VCtsugF0cMq4upbM0cD5/Ndpten+nMHw8pNSfLzkaKFWAfc5 laAQPePuzgufgIMltAmq0w7mDAmtEI3GXJuroQFx4/s8iGxO5JVL56GLqCWT/bWmk4Gt hwbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=rF6hDIv3cmYj7Li/1ZKjWzmBdQxwnPKRNjT1kF5p5lU=; b=kbgb6Wcgoy1K3/LxF126dCAFvM2VvH6+UPoCNWFntctlIRnsjb5MZq78ltVV84gsaV p5UZ2f0K2uiq273vfyEetVE/gGELmvm7rALRzt/G7lOpgH96vNaS4Z9zZaH7q3GFda5A FH+SEdzZC6rXrqLOxfM0bhO7et2AI//dSdyxxhuLutnkVL4mGwAqaRf9oAXtuGyf9sII HcEgN6ygymTelaDhfrQBeiVPjn2I5HeO/L2p667QoEI9iIf2ZrS27FV1NpKYd7xYjQXD Zchyt7hEqIg6AZy6dQw2m3BiskjNeFC5DvqjpYEfGnLB3m2DRFZdfKn8UppYA5C7xRO5 qM7g== X-Gm-Message-State: AHQUAubVhJN/Gzaxw6V/aHE4ZLbe3nhKG7qnhsPkXWuiU6fjJsyvsRU7 fNFkiAuySPPlQnr9cUXlh1j7Pw== X-Received: by 2002:a5d:5285:: with SMTP id c5mr6152013wrv.167.1550054389610; Wed, 13 Feb 2019 02:39:49 -0800 (PST) Received: from dell ([2.27.35.171]) by smtp.gmail.com with ESMTPSA id f134sm4881743wme.31.2019.02.13.02.39.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Feb 2019 02:39:49 -0800 (PST) Date: Wed, 13 Feb 2019 10:39:46 +0000 From: Lee Jones To: Bartosz Golaszewski Cc: Bartosz Golaszewski , Rob Herring , Mark Rutland , Linus Walleij , Dmitry Torokhov , Jacek Anaszewski , Pavel Machek , Sebastian Reichel , Liam Girdwood , Greg Kroah-Hartman , Linux Kernel Mailing List , "open list:GPIO SUBSYSTEM" , devicetree , Linux Input , Linux LED Subsystem , Linux PM list , Mark Brown Subject: Re: [PATCH v4 05/10] mfd: max77650: new core mfd driver Message-ID: <20190213103946.GG1863@dell> References: <20190212101835.GB20638@dell> <20190212111403.GC20638@dell> <20190212132016.GA4781@dell> <20190213092553.GE1863@dell> <20190213095330.GF1863@dell> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 13 Feb 2019, Bartosz Golaszewski wrote: > śr., 13 lut 2019 o 10:53 Lee Jones napisał(a): > > > > On Wed, 13 Feb 2019, Bartosz Golaszewski wrote: > > > > > śr., 13 lut 2019 o 10:25 Lee Jones napisał(a): > > > > > > > > On Tue, 12 Feb 2019, Lee Jones wrote: > > > > > > > > > On Tue, 12 Feb 2019, Bartosz Golaszewski wrote: > > > > > > > > > > > wt., 12 lut 2019 o 12:14 Lee Jones napisał(a): > > > > > > > > > > > > > > On Tue, 12 Feb 2019, Bartosz Golaszewski wrote: > > > > > > > > > > > > > > > wt., 12 lut 2019 o 11:18 Lee Jones napisał(a): > > > > > > > > > > > > > > > > > > On Tue, 12 Feb 2019, Bartosz Golaszewski wrote: > > > > > > > > > > > > > > > > > > > wt., 12 lut 2019 o 10:55 Lee Jones napisał(a): > > > > > > > > > > > > > > > > > > > > > > * The declaration of a superfluous struct > > > > > > > > > > > * 100 lines of additional/avoidable code > > > > > > > > > > > * Hacky hoop jumping trying to fudge VIRQs into resources > > > > > > > > > > > * Resources were designed for HWIRQs (unless a domain is present) > > > > > > > > > > > * Loads of additional/avoidable CPU cycles setting all this up > > > > > > > > > > > > > > > > > > > > While the above may be right, this one is negligible and you know it. :) > > > > > > > > > > > > > > > > > > You have nested for() loops. You *are* wasting lots of cycles. > > > > > > > > > > > > > > > > > > > > Need I go on? :) > > > > > > > > > > > > > > > > > > > > > > Surely the fact that you are using both sides of an API > > > > > > > > > > > (devm_regmap_init_i2c and regmap_irq_get_*) in the same driver, must > > > > > > > > > > > set some alarm bells ringing? > > > > > > > > > > > > > > > > > > > > > > This whole HWIRQ setting, VIRQ getting, resource hacking is a mess. > > > > > > > > > > > > > > > > > > > > > > And for what? To avoid passing IRQ data to a child driver? > > > > > > > > > > > > > > > > > > > > What do you propose? Should I go back to the approach in v1 and pass > > > > > > > > > > the regmap_irq_chip_data to child drivers? > > > > > > > > > > > > > > > > > > I'm saying you should remove all of this hackery and pass IRQs as they > > > > > > > > > are supposed to be passed (like everyone else does). > > > > > > > > > > > > > > > > I'm not sure what you mean by "like everyone else does" - different > > > > > > > > mfd drivers seem to be doing different things. Is a simple struct > > > > > > > > containing virtual irq numbers passed to sub-drivers fine? > > > > > > > > > > > > > > How do you plan on deriving the VIRQs to place into the struct? > > > > > > > > > > > > Exampe: > > > > > > > > > > > > struct max77650_gpio_pdata { > > > > > > int gpi_irq; > > > > > > }; > > > > > > > > > > > > In MFD driver: > > > > > > > > > > > > struct max77650_gpio_pdata *gpio_data = devm_kmalloc(dev, sizeof(*gpio_data)); > > > > > > > > > > > > gpio_data->gpi_irq = regmap_irq_get_virq(irqchip_data, GPI_NUM); > > > > > > > > > > > > gpio_cell.platform_data = gpio_data; > > > > > > > > > > > > In GPIO driver: > > > > > > > > > > > > struct max77650_gpio_pdata *gpio_data = pdev->dev.platform_data; > > > > > > > > > > > > int irq = gpio_data->gpi_irq; > > > > > > > > > > Definitely not. What you're trying to do is a hack. > > > > > > > > > > If you're using Regmap to handle your IRQs, then you should use Regmap > > > > > in the client to pull them out. Setting them via Regmap, then pulling > > > > > them out again in the *same driver*, only to store them in platform > > > > > data to be passed to a child device is bonkers. > > > > > > > > > > *Either* use the MFD provided platform-data helpers *or* pass and > > > > > handle them via the Regmap APIs, *not* both. > > > > > > > > Right, a plan has been formed. > > > > > > > > Hopefully this works and you can avoid all this dancing around. > > > > > > > > Firstly, you need to make a small change to: > > > > > > > > drivers/base/regmap/regmap-irq.c > > > > > > > > Add the following function: > > > > > > > > struct irq_domain *regmap_irq_get_domain(struct regmap *map) > > > > > > We already do have such function and a lot of mfd drivers actually use it. > > > > Even better. > > > > > > As you can see, it will return the IRQ Domain for the chip. > > > > > > > > You can then pass this IRQ domain to mfd_add_devices() and it will do > > > > the HWIRQ => VIRQ mapping for you on the fly. Meaning that you can > > > > remove all the nastiness in max77650_setup_irqs() and have the Input > > > > device use the standard (e.g. platform_get_irq()) APIs. > > > > > > > > How does that Sound? > > > > > > This does sound better! Why didn't you lead with that in the first place? > > > > I'm not even going to dignify that stupid question with a response. > > It's not a stupid question and you're being unnecessarily rude. As an > expert in the subsystem you maintain you could have answered simply > with a "this is wrong, retrieve the irq domain from the regmap > irq_chip and pass it over to mfd_add_devices, the mfd core will create > appropriate mappings". Could be culture clash, but I found the question offensive which is why I chose not to answer it. The reason is actually explained below: "It's only the craziness in this patch which forced me to look into how Regmap handles IRQs and come up with a subsequent solution which fits your use-case." Thus the fact that a) Regmap used IRQ domains and b) the IRQ domain could be fetched and reused here didn't enter my thought process until I delved into the inner workings of Regmap. Yes, I know MFD pretty well, but I only tend to deep-dive into other subsystems, particularly ones as complicated as Regmap, when it's necessary to do so. Now I know a little more about it, I can provide the feedback you suggest going forward. > > > It's a pity it's not documented, I had to look at the code to find out > > > irq resources would get translated in mfd_add_devices() if a domain is > > > present. > > > > Where is it likely to be documented? MFD is pretty simple and seldom > > needs explanation. A 3 second look at the API you're trying to use > > (instead of blind copy & paste) would have told you that it's possible > > to take an IRQ domain as an argument. > > > > It's only the craziness in this patch which forced me to look into how > > Regmap handles IRQs and come up with a subsequent solution which fits > > your use-case. > > > > > In that case - I really don't see a reason to create a superfluous > > > structure to only hold the main regmap - we can very well get it from > > > the parent device in sub-drivers as I do now. > > > > The whole point of this solution is that you don't need to pass > > anything non-standard (i.e. not provided by the current APIs) to the > > child device. > > I don't understand what you're saying here. I'm saying that the structure you speak of is no longer required. -- Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog