Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp106320imj; Wed, 13 Feb 2019 05:30:30 -0800 (PST) X-Google-Smtp-Source: AHgI3IZcXgIN3PdVBJRaaUEq6T7VQE6WQ75a3U0GFGUk4mQ0sZay1C2+JJM1ii4P00TENFGvNrmP X-Received: by 2002:a17:902:8641:: with SMTP id y1mr534805plt.159.1550064630583; Wed, 13 Feb 2019 05:30:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550064630; cv=none; d=google.com; s=arc-20160816; b=y9v2FPWwiyDPtlyMdR/JaW1RKC69lzZNpowYGxbyf/4E3/AEYJmmZ2T6oIspLWnbW7 gEHnelLBJyjpOAEh77bh+BHNbDoQfwb9XP/UglmPZoJ5uTd6xlohRsVzYg9lMwy45CSV XNPLym2CVH/SjhQcE3JG27c25Fbs3Xm3Iz4PStJcgKmneELahNB+N8gIT6IVFHLWKJXw h7XE90SVR1gVI+WzHV/vrv9zbRSeMGo7icGynJ7FY2blp33FjgyQl3ogUjak4F0bAg2b fC/i4tgkAXQ5f7Enhx6skm+z5DXEF6roSg9kfUz2NN46u9IFykzWclyNRwWvnba63VdY i5iQ== 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=N/24VafAe3SbghCeTmnYviQLVXiAQGmM8THLiXIbj28=; b=krDxIVTAIsoLuXsG+Gp9+cXAY1PVczSN2TujdV0STQQRhZOVuvnugnTFWYVRc6f4GV F7wprklARsezZdRuKBFdNyE2WPzw5q9c1YGCfjF6KjuFVQgnRYV/WZot2Qr+mckkKaxn 9GJXCWRZ1uT75hruh/Rmk2dy6oDSuMXyg81DfcHmOsZ98MjpMj+J9uW/oQS9uW9LUZ9l Zj4BTMW0jSBDvomHPA2QkX5NTh+XQB4yWX+tOVB3HkoyjO+JKHxwlk+WhKQui1cPhHEV tiGIzvhU/NFuc/aUiB0eCnW7e2UaR9Fsry2POHkqL7puATtOls1R5Yh+palPG+OmvcmM /2sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MF9o1fqX; 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 u2si14650154pgp.592.2019.02.13.05.30.13; Wed, 13 Feb 2019 05:30:30 -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=MF9o1fqX; 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 S1729473AbfBMJ0A (ORCPT + 99 others); Wed, 13 Feb 2019 04:26:00 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:33123 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728977AbfBMJZ7 (ORCPT ); Wed, 13 Feb 2019 04:25:59 -0500 Received: by mail-wm1-f66.google.com with SMTP id h22so1403539wmb.0 for ; Wed, 13 Feb 2019 01:25:57 -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=N/24VafAe3SbghCeTmnYviQLVXiAQGmM8THLiXIbj28=; b=MF9o1fqXqDMnX8uDQo5tq6toCuEqUHnshHwlMFXoeEgkxWTHhh02AAmKCq7dC+VVp4 U0qAcMyJlrw5VORFEDk6DqgaJ5aA5V8fzgfykdvW8uLCvvwZd7AdFOHu2snxMYznUiJ+ Oqn/U/s5WP1NXZihrNDdn0jI3cABn8h2F7NbInJgciiZtVE30qNqaTQYmU2qx4OV4SfF qLjSIE+zkhBCfPwdOk/zvyamW+FJMUurqMYrdev5WDn5jcnJt06R+/QE+z8JzqY8ADRv dFU8tPMKAnW11JCMl60Z6eSA18akYZUrOCry3LGaWyEt401hJh0XIqoN8Lzwt6VWBcWU /lgQ== 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=N/24VafAe3SbghCeTmnYviQLVXiAQGmM8THLiXIbj28=; b=ot9dgtkGDEMwfzsU8rcGcAU7p1zZHuMvfs6TeUZOjnIzBISUQvzrqmexfQ/sg2ddO7 +uFYSu0nTgIRuCsU0SMoh6XMeXlF+ufqUp9ijNwk8K0Beglc/DNArbN7LkK0axQOjA+2 ZrMRSroCkG4RewaeMyMnE+lQBElWrs7gLvbHcJlsguJE5vNfrzn98Bh93+g37VpLT+61 x9jIfiNNVIltwP/3sPpAL3FNHqd44FWqzP9UdwgjIveZvSAUUXRFwTh3L9bIWuhzEFYj A9EgcGIFF9UO/jcsRq3sHthSUgl04sBPKsC4iWDI0ZNM8F0zdXWTRL3kPLMTu8RTvnvN xnmQ== X-Gm-Message-State: AHQUAuYSc26Tpwu+yJoXUuH4een2+uWaoJNrnnz6DypORerBw4EmSuQF djfGe+8x1B7ddKQ2kgci8QuW3Q== X-Received: by 2002:a1c:e910:: with SMTP id q16mr2535037wmc.68.1550049956751; Wed, 13 Feb 2019 01:25:56 -0800 (PST) Received: from dell ([2.27.35.171]) by smtp.gmail.com with ESMTPSA id y18sm2881256wmi.5.2019.02.13.01.25.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Feb 2019 01:25:55 -0800 (PST) Date: Wed, 13 Feb 2019 09:25:53 +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 , broonie@kernel.org Subject: Re: [PATCH v4 05/10] mfd: max77650: new core mfd driver Message-ID: <20190213092553.GE1863@dell> References: <20190205091237.6448-6-brgl@bgdev.pl> <20190212083642.GT20638@dell> <20190212095457.GA20638@dell> <20190212101835.GB20638@dell> <20190212111403.GC20638@dell> <20190212132016.GA4781@dell> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190212132016.GA4781@dell> 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 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) 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? -- Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog