Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp113184imj; Wed, 13 Feb 2019 05:36:59 -0800 (PST) X-Google-Smtp-Source: AHgI3IYwlUizZOaUVeyETbq1GC4/zT3CK/ZDdsDudDblHrCJkh82UoeC/z2QY7i8AHBw9+Mi1yAJ X-Received: by 2002:a65:64d9:: with SMTP id t25mr546471pgv.244.1550065019190; Wed, 13 Feb 2019 05:36:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550065019; cv=none; d=google.com; s=arc-20160816; b=DwR1b1Vx77/eJCoWBpe1zkARM7uYpNNIzvHF2zpZkCMTXPbDDQCRY9D32UgowKoh08 rCosvLtCl8VTnKlQhA66UFOdbuVOAYJPD0CoMtIAEicpZ9K6HlWE6SlZYySmGna4UbgJ w119dh0x4SFl6+Kv6q09LEvlDsrzRiEu/T4ZDeqcXdz7/QR7/8HS4q6jsyI43Jwekx3J 4QOtyNA5hWob7Wjq57qMa3xahCeV0/5fA5CDvrlH9RTYSsv1ppt5hCoBlvPZSSMUZvjN gwYbffmZefKN3E8jtOQenfBgPs4t+mggY5WfQhetrCsXDu3XhHOBGTec/7ieLeF+3kpg wC0Q== 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=hx7G0whfY6I3zwZKz00ap7A9CQvAiNh6dmR960MQEDo=; b=NkRgsPnrWVZYwslt8wtQ9UynsYuX4r51DgGc9Sht+dypC2u421bs0008E1aZDtKwFE FX5UXIJoY5b77EKqFR0X6eu/84hqh/1rmHOL0kYuBhcq97ImG5Fya3HVb0LfGPL2x3Dh hbN7mnv8oHu72IFFoTh9O+j7CwU6iQg4ol4CUrozTlSxEp/rcPZyu9FuHSFzcOwKV0EL jIEW806DmGZrJQDGffmW/7QCVjPxktf61EoCst8H675HSH2qO/PRYQdZqDzcLuP8FXXC 7DaaS2R9c6jHB0IBbsr34kMNdfL/6a2yjDt+DEq8ChAoNglyEjrwnU3xHeHpggu8jIqH D8vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ktm4SudR; 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 t24si2205775pgv.66.2019.02.13.05.36.42; Wed, 13 Feb 2019 05:36:59 -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=ktm4SudR; 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 S2387689AbfBMJxg (ORCPT + 99 others); Wed, 13 Feb 2019 04:53:36 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:39548 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729649AbfBMJxe (ORCPT ); Wed, 13 Feb 2019 04:53:34 -0500 Received: by mail-wm1-f65.google.com with SMTP id f16so1673820wmh.4 for ; Wed, 13 Feb 2019 01:53:33 -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=hx7G0whfY6I3zwZKz00ap7A9CQvAiNh6dmR960MQEDo=; b=ktm4SudR7tZVQbeQ+LACuslEuTLfIykOouJt0PnexDGs+5ssD9yD3WRD6CK/gB4dUz AdX5H/KZWSwhf4rPjaf80hRzd2s0xtsLWtK0xNMutIJJ/2Gza6PdG6TbcOi3xAIQaSWs zwkHry5QE/u+sI0BiypGoINZoTG4pH4bcQsN1COEjLYD/CS2ZER3WAOPQC+WI+FacvH3 U4AtMwxwZReyyhyBe0DIt0RBAVWXCJf+hRWyUw3KqUSiEsIVHddSI7HKRYfwwF27dowo dRR6T05ZDaeJA82Zn8A/iBouq27ZmGfNJajfGQWDdbuhnUg0cWADVGsUjknAarULujOB MZeA== 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=hx7G0whfY6I3zwZKz00ap7A9CQvAiNh6dmR960MQEDo=; b=Tdz2Kmw0+shHaQwiZEjHgYCh+tH+HiJ7r8Ris8Ucy/AyDXteau7acZDuZMS3Bf1UPG GW82S/YZ9x1/VPDfUbLuyUHfszoaMqe7McwznuOGDswUt4SO6euFSRqVQMNSSYMSaKtv aAEHpjdvm5552Ww+SU980ndjzfVdDtYtrTcmTmV0hW1fZ0j6JNHmp+NdIpHnzIV3ru6T fYIOGh5tmOVmF6YWIf4tNroz8UQ2m8r4aasBEylsZ5T2GSLQcSHEBx0m9cTchH7rlVO0 5IdQMayHFyafIs2nx/0NTm7IOYqkR81bukRtVlQ/EpldCAYqZ/MGxC+7o0Jnb1su0GHp GdCQ== X-Gm-Message-State: AHQUAub1dj2XtXIeNfl2S+aG50knQz8sslfC0oyVLKlHjEMANKCoKhGa 9qAZ8k+AEWLrvNX0srPNkaMGtw== X-Received: by 2002:a1c:9692:: with SMTP id y140mr2667949wmd.67.1550051612753; Wed, 13 Feb 2019 01:53:32 -0800 (PST) Received: from dell ([2.27.35.171]) by smtp.gmail.com with ESMTPSA id 2sm36787848wrg.89.2019.02.13.01.53.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Feb 2019 01:53:32 -0800 (PST) Date: Wed, 13 Feb 2019 09:53:30 +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: <20190213095330.GF1863@dell> References: <20190212095457.GA20638@dell> <20190212101835.GB20638@dell> <20190212111403.GC20638@dell> <20190212132016.GA4781@dell> <20190213092553.GE1863@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: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 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. -- Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog