Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp123155imj; Wed, 13 Feb 2019 05:47:27 -0800 (PST) X-Google-Smtp-Source: AHgI3IbeivOeCXLzKziQOcf6SAPjQFf/KXJ86GFBxAMsxLJTlK4tJH+eTAmUbDBCUYgxqVU2edEx X-Received: by 2002:a17:902:380c:: with SMTP id l12mr615729plc.326.1550065647202; Wed, 13 Feb 2019 05:47:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550065647; cv=none; d=google.com; s=arc-20160816; b=0lRkrwBQI85REKNLKj0Hruxy3lpv+dt+CG4lLq+R81BucMBmfUvdSape35VwSSPGXQ TdFUSbYwYb1KWk38u+OrbwpfnP2o8bQXy2zBf5e0EmKcIo6hPP2ak11BhtVjBNK5REDf 1TIZp9tndgGLBJCUiIzaVZ3gqcWteHhJPskyI9FAPX5A6ozhpr/8GPdfn8b5p3TwTXHd NvhFpjzg1Q6lDW4k7OC+bVGEVAXCISu+WiZrKaTff5B+ZcRryXuTyAbdpFQOUhPqqMjI FU3Oo5NMbIdVNTJyJGa22GxcAPbnWYUs349J5yJF8Yj0EhCBwODgL5qSu5i8vmV6sWDv oAsg== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=098FFW+ZJ4L6I/eXR7TVCD8JEV2OI+nP65I7uNmUxUU=; b=KEpXSPj/T5sKoPbZEtkPjfGEfDl8/N02Y9IXQxr94J+azPTYAgERbN3vMj/aEFEG3K vNufKYTqk8bxrWZwbx3lzubW5fZT0RAzhID7l/dMV5H/KSKnP06z+FImLIcjqiIwGLdI JzKbcfCRTQz/N1+wsUBdPcifhrbLgaCA0D/VH/jnXpk++ig0gMRBJjQCIIJlhFTGdu4C 3Tsb56BASgRgUllDREgplx2kC0vIfnuYgBaNwJtyr2qALSdrBEAfz27fJCQZ0aMdBnFZ cIEliCJZA7UbLib24ncq4WVWnuddRiFQIiOwnL3PPxrMqPR1Adpi/n3wJIawcCO9ZjFl SRLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=Q5AW5IiG; 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 e6si4126226pgp.504.2019.02.13.05.47.10; Wed, 13 Feb 2019 05:47:27 -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=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=Q5AW5IiG; 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 S2391524AbfBMKqn (ORCPT + 99 others); Wed, 13 Feb 2019 05:46:43 -0500 Received: from mail-it1-f194.google.com ([209.85.166.194]:56083 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727058AbfBMKqm (ORCPT ); Wed, 13 Feb 2019 05:46:42 -0500 Received: by mail-it1-f194.google.com with SMTP id o131so4736063itc.5 for ; Wed, 13 Feb 2019 02:46:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=098FFW+ZJ4L6I/eXR7TVCD8JEV2OI+nP65I7uNmUxUU=; b=Q5AW5IiG2qAZl9kx00Xx9g5JbZGron/CK2H+WVwvyWfkFCaE5+33S8IaO0RlQWwO5f 2tg79jfhdPsAxi9EJIjZwhHxIUQPsR+PGUcq3KG41fjpH6sR3yC+auKEiIlv14wsle/Y HSG6O7Wsg7Iz9knRR+tdT04DTtxuI5wYlxtd1n7bMoA3G22aJ3HQIxvSXcMppVrCIbuV dnofL3MG6qbPcnvl+jW9FayxtJUxVYQwUWGZGCG8FZaHHKKvHiLvSuOieE6NYf3eueFs zj8tz1OMOQOU+RquJGHdb9wgjVI2M7GElcosxqp878/f5HdFOm1jfpnYLYBvt5F2f4fU 7u1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=098FFW+ZJ4L6I/eXR7TVCD8JEV2OI+nP65I7uNmUxUU=; b=e11k7vgyD5qLSf/rOqRKO1qjOBG1ycgBExqHyhyV8g+WTXBWsCXI2LUex6P5FCNDkd Zw0fTgWTI6vyqr+ol89OLyJCyjMWbg5CIj2F8QRHvDtZd0J353Z/FZgN84vmG8TDXo7R FkCup75rcxrGFljE7ZksdbT9JtaS94jOqG7vzZNPrBmpgpKz8Dr0LjFAx3gzVhZfQgvW gVyaXZoDb374FSdhSPF8jHP64Aoks+5R+ZlUBgIWU7lDzyzF6ORTnWy5+fQgK8sQOHvm dSbxvk1yZMFbr/qZdasz4MaLirrrHUx9ckuOhmO6Lh/En4HBZFMHhfQIvql2cso7lTCM EVjw== X-Gm-Message-State: AHQUAuZ9mQVYHzMW6lay08k4Irq3pmDDBpkT114GeruS9VenoPXxf2ly zbD3k4zOz8t1TK+HBvvOUxH+e2KLECKF+uxJ6SAQlQ== X-Received: by 2002:a02:c78d:: with SMTP id n13mr4184328jao.57.1550054801293; Wed, 13 Feb 2019 02:46:41 -0800 (PST) MIME-Version: 1.0 References: <20190212101835.GB20638@dell> <20190212111403.GC20638@dell> <20190212132016.GA4781@dell> <20190213092553.GE1863@dell> <20190213095330.GF1863@dell> <20190213103946.GG1863@dell> In-Reply-To: <20190213103946.GG1863@dell> From: Bartosz Golaszewski Date: Wed, 13 Feb 2019 11:46:30 +0100 Message-ID: Subject: Re: [PATCH v4 05/10] mfd: max77650: new core mfd driver To: Lee Jones 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org =C5=9Br., 13 lut 2019 o 11:39 Lee Jones napisa=C5=82= (a): > > On Wed, 13 Feb 2019, Bartosz Golaszewski wrote: > > > =C5=9Br., 13 lut 2019 o 10:53 Lee Jones napisa= =C5=82(a): > > > > > > On Wed, 13 Feb 2019, Bartosz Golaszewski wrote: > > > > > > > =C5=9Br., 13 lut 2019 o 10:25 Lee Jones napi= sa=C5=82(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 nap= isa=C5=82(a): > > > > > > > > > > > > > > > > On Tue, 12 Feb 2019, Bartosz Golaszewski wrote: > > > > > > > > > > > > > > > > > wt., 12 lut 2019 o 11:18 Lee Jones = napisa=C5=82(a): > > > > > > > > > > > > > > > > > > > > On Tue, 12 Feb 2019, Bartosz Golaszewski wrote: > > > > > > > > > > > > > > > > > > > > > wt., 12 lut 2019 o 10:55 Lee Jones napisa=C5=82(a): > > > > > > > > > > > > > > > > > > > > > > > > * The declaration of a superfluous struct > > > > > > > > > > > > * 100 lines of additional/avoidable code > > > > > > > > > > > > * Hacky hoop jumping trying to fudge VIRQs into re= sources > > > > > > > > > > > > * Resources were designed for HWIRQs (unless a dom= ain 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 ha= cking 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 pa= ss 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 simpl= e struct > > > > > > > > > containing virtual irq numbers passed to sub-drivers fine= ? > > > > > > > > > > > > > > > > How do you plan on deriving the VIRQs to place into the str= uct? > > > > > > > > > > > > > > Exampe: > > > > > > > > > > > > > > struct max77650_gpio_pdata { > > > > > > > int gpi_irq; > > > > > > > }; > > > > > > > > > > > > > > In MFD driver: > > > > > > > > > > > > > > struct max77650_gpio_pdata *gpio_data =3D devm_kmalloc(dev, s= izeof(*gpio_data)); > > > > > > > > > > > > > > gpio_data->gpi_irq =3D regmap_irq_get_virq(irqchip_data, GPI_= NUM); > > > > > > > > > > > > > > gpio_cell.platform_data =3D gpio_data; > > > > > > > > > > > > > > In GPIO driver: > > > > > > > > > > > > > > struct max77650_gpio_pdata *gpio_data =3D pdev->dev.platform_= data; > > > > > > > > > > > > > > int irq =3D 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 plat= form > > > > > > data to be passed to a child device is bonkers. > > > > > > > > > > > > *Either* use the MFD provided platform-data helpers *or* pass a= nd > > > > > > 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 wil= l do > > > > > the HWIRQ =3D> VIRQ mapping for you on the fly. Meaning that you= can > > > > > remove all the nastiness in max77650_setup_irqs() and have the In= put > > > > > 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 wasn't meant to be offensive. I guess when dealing with non-native English speakers over e-mail it's best to assume good faith. > "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 possibl= e > > > to take an IRQ domain as an argument. > > > > > > It's only the craziness in this patch which forced me to look into ho= w > > > 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 fr= om > > > > 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. > Thanks for clarifying. Bartosz