Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9120865pxu; Mon, 28 Dec 2020 07:08:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJwI59pDJKgkUn/hlsiyhIgw5AzHMD7RduP5GY0AejxNLRlhVBFR7JNgPcGRDMDt+8BzU9/i X-Received: by 2002:a17:906:1cd4:: with SMTP id i20mr42797230ejh.415.1609168127420; Mon, 28 Dec 2020 07:08:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609168127; cv=none; d=google.com; s=arc-20160816; b=u6j3v+MeCGJjWKNul8hvLxYdxTnyY+3kKWkdM0Jkyv14rPfEB0ktBGnNS609gnHdeo wasOEzJjv5ge1pzINVZyYXCdxVR5MHF5U669Zjn9lEnJx/HFvLwprLNTeQxTrgfqS0L1 3QZr2diSSAYEm7TCK+7uZx5PsW2dOeYZNG47cGWA52oYemQk/JjlKwN7mMrDnTSDuP7m nZqt+mfDPwyOMBqeMVBUOL5Fcs+vC82Y9nDITjcWkHlykbdRY1OhujUi5KchBsShrMcI MuSFLRucIQry3PksNw16i4yZSOq9Vg28UED3vLRaKwW81Xky3ELczM+1tKepDduxsSEz Icxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id:date :mime-version:subject:references:in-reply-to:cc:to:from :dkim-signature; bh=LbIGQYGVuU5ladSSucPcONHVBEN4CnC07EgGwEb9mJM=; b=VwBLMfbkTboZziu9hZin6Blz1gXUEw3uEEylrHthCnWEjnpt7kQeMcD+PSUo+SfmfK tkZM1cVXmefBnTl4bqUsRcOhLng/GnR2Orxa53+5GtPMs9CQFQGHcYg+dujPTIsTbwor q/+tQ8pjhNIZyEJsTdTdLFwZh5Wu4yCYmOcyV3jda04Xt6vH6CCZ3FKRtebnxLDBpYQe w8cVMU7lrRDGmVg0BclleSINEQwIhRMrDTt5aT8DQt7o4FwB5W+21yY7leFCN1gumvNX 2VFUG0y9RkJLv61+u2O4TmBPGybcA1ZUFCtFe6y+5QiIzmG7Q9yiJCmqYSIgTQHWrTHs Z7jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@maquefel.me header.s=mail header.b=XomDNzRh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r17si21898138edq.47.2020.12.28.07.08.24; Mon, 28 Dec 2020 07:08:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@maquefel.me header.s=mail header.b=XomDNzRh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439548AbgL1PGA (ORCPT + 99 others); Mon, 28 Dec 2020 10:06:00 -0500 Received: from forward500p.mail.yandex.net ([77.88.28.110]:53577 "EHLO forward500p.mail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2504228AbgL1PF4 (ORCPT ); Mon, 28 Dec 2020 10:05:56 -0500 Received: from iva3-4f441b146a71.qloud-c.yandex.net (iva3-4f441b146a71.qloud-c.yandex.net [IPv6:2a02:6b8:c0c:498c:0:640:4f44:1b14]) by forward500p.mail.yandex.net (Yandex) with ESMTP id 48127940423; Mon, 28 Dec 2020 18:05:08 +0300 (MSK) Received: from localhost (localhost [::1]) by iva3-4f441b146a71.qloud-c.yandex.net (mxback/Yandex) with ESMTP id 3PoAR5PxjQ-57DKFFLj; Mon, 28 Dec 2020 18:05:07 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maquefel.me; s=mail; t=1609167907; bh=LbIGQYGVuU5ladSSucPcONHVBEN4CnC07EgGwEb9mJM=; h=Message-Id:Cc:Subject:In-Reply-To:Date:References:To:From; b=XomDNzRhsgUveeGirs/jYiRH5/+75xmaf0/IO7vrtBGbnJeDfZIdHkeeQTITyiPZN 8IaIuwjACxJEFd0AhQqnzUkYNcdmVa2GfGc6LTbrSsrI3Z8WX7JvyF6k/8zCfeP72M rEuru72NrUmnKngZ0ndx7qqHRCYe735Aw217y+1o= Authentication-Results: iva3-4f441b146a71.qloud-c.yandex.net; dkim=pass header.i=@maquefel.me Received: by iva4-0814df7d67c8.qloud-c.yandex.net with HTTP; Mon, 28 Dec 2020 18:05:07 +0300 From: nikita.shubin@maquefel.me To: Andy Shevchenko Cc: Linus Walleij , Bartosz Golaszewski , "open list:GPIO SUBSYSTEM" , Linux Kernel Mailing List In-Reply-To: References: <20201224112203.7174-1-nikita.shubin@maquefel.me> <20201224112203.7174-2-nikita.shubin@maquefel.me> Subject: Re: [RFC PATCH 1/3] gpio: ep93xx: convert to multi irqchips MIME-Version: 1.0 X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Mon, 28 Dec 2020 18:05:07 +0300 Message-Id: <715101609167778@mail.yandex.ru> Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=utf-8 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 26.12.2020, 20:52, "Andy Shevchenko" : > On Thu, Dec 24, 2020 at 1:23 PM Nikita Shubin wrote: >>  Since gpiolib requires having separate irqchips for each gpiochip, we >>  need to add some we definetly need a separate one for F port, and we > > definitely > >>  could combine gpiochip A and B into one - but this will break namespace >>  and logick. >> >>  So despite 3 irqchips is a bit beefy we need a separate irqchip for each > > is a -> being a > >>  interrupt capable port. >> >>  - added separate irqchip for each iterrupt capable gpiochip > > interrupt > >>  - dropped ep93xx_gpio_port (it wasn't working correct for port F anyway) >>  - moved irq registers into separate struct ep93xx_irq_chip, togather > > irq -> IRQ (everywhere) > > together > >>    with regs current state >>  - reworked irq handle for ab gpiochips (through bit not tottaly sure this >>    is a correct thing to do) > > ab -> AB ? > > In the parentheses something like "I'm not totally sure that this is a > correct thing to do, though". > >>  - dropped has_irq and has_hierarchical_irq and added a simple index >>    which we rely on when adding irq's to gpiochip's > > IRQs to GPIO chips > > (It would be nice if you can spell check and proofread commit > messages and comments in the code. > > ... > >>  +struct ep93xx_irq_chip { >>  + void __iomem *int_type1; >>  + void __iomem *int_type2; >>  + void __iomem *eoi; >>  + void __iomem *en; >>  + void __iomem *debounce; >>  + void __iomem *status; > > This is a bit... overcomplicated. > Can we rather use regmap API? > >>  + u8 gpio_int_unmasked; >>  + u8 gpio_int_enabled; >>  + u8 gpio_int_type1; >>  + u8 gpio_int_type2; >>  + u8 gpio_int_debounce; >>  + struct irq_chip chip; >>  +}; > > ... > >>   /* Port ordering is: A B F */ >>  +static const char *irq_chip_names[3] = {"gpio-irq-a", >>  + "gpio-irq-b", >>  + "gpio-irq-f"}; > > Can you use better pattern, ie. > static const char * const foo[] = { >   ... > }; > > (there are two things: splitting per lines and additional const)? > > ... > >>  + ab_parent_irq = platform_get_irq(pdev, 0); > > Error check, please? > Also, if it's an optional resource, use platform_get_irq_optional(). > >>  + err = devm_request_irq(dev, ab_parent_irq, >>  + ep93xx_ab_irq_handler, >>  + IRQF_SHARED, eic->chip.name, gc); > >>  + > > Redundant blank line. > >>  + if (err) { >>  + dev_err(dev, "error requesting IRQ : %d\n", ab_parent_irq); >>  + return err; >>  + } > > ... > >>  + girq->num_parents = 1; >>  + girq->parents = devm_kcalloc(dev, 1, >>  + sizeof(*girq->parents), >>  + GFP_KERNEL); > > Can be squeezed to less amount of LOCs. Also consider to use > girq->num_parents as a parameter to devm_kcalloc(). > >>  + if (!girq->parents) >>  + return -ENOMEM; > > ... > >>  + girq->handler = handle_level_irq; > > Don't we want to mark them as bad by using handle_bad_irq() as default handler? > > ... > >>  + /* >>  + * FIXME: convert this to use hierarchical IRQ support! >>  + * this requires fixing the root irqchip to be hierarchial. > > hierarchical > >>  + */ > > ... > >>  + girq->num_parents = 8; >>  + girq->parents = devm_kcalloc(dev, 8, >>  + sizeof(*girq->parents), >>  + GFP_KERNEL); > > As per above. > >>  + > > Redundant blank line. > >>  + if (!girq->parents) >>  + return -ENOMEM; > > ... > >>  + /* Pick resources 1..8 for these IRQs */ >>  + for (i = 1; i <= 8; i++) >>  + girq->parents[i - 1] = platform_get_irq(pdev, i); > > I would rather like to see i + 1 as a parameter which is much easier > to read and understand. > >>  + for (i = 0; i < 8; i++) { > > Also in both cases replace 8 by ARRAY_SIZE() or predefined constant. > >>  + gpio_irq = EP93XX_GPIO_F_IRQ_BASE + i; >>  + irq_set_chip_data(gpio_irq, gc); >>  + irq_set_chip_and_handler(gpio_irq, >>  + girq->chip, >>  + handle_level_irq); >>  + irq_clear_status_flags(gpio_irq, IRQ_NOREQUEST); >>  + } > > Okay, I see that this is in the original code. Consider them as > suggestions for additional changes. > > And briefly looking into the rest of the code the recommendation is to > split this and perhaps other patches to smaller logical pieces. > > Also, try to organize your series in groups each of them respectively > represents the following > 1) fixes (can be backported, usually contain Fixes tag to the culprit commit); > 2) preparatory refactoring patches / cleanups; > 3) new features. > > -- > With Best Regards, > Andy Shevchenko Thank you, Andy, i ll rework my RFC patch according to your advices and resubmit.