Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1229772imu; Wed, 23 Jan 2019 13:02:35 -0800 (PST) X-Google-Smtp-Source: ALg8bN4ThKwU0F7ePIZAeGlMjVedwyfxqp1whT4YfJ+qNEZ6qkaBWd0ydonR+rX6jK9j2lOyWMWZ X-Received: by 2002:a63:b34f:: with SMTP id x15mr3462254pgt.243.1548277355349; Wed, 23 Jan 2019 13:02:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548277355; cv=none; d=google.com; s=arc-20160816; b=QnBYqEYvC6Rq+v2+LQI3lAn/8XgqZFwmRpV0EDeKSz2SXdIdS6J432yq8DzLGvdf60 u/gT/VsJjKfMIxHq0Vx3aiEUoaYrKa2xZxqxk6RpoQRC80b+tHIrP7SxxuKVbY/mipvr 8wh1hoRwMl7xZfwSWOb1TA022HfkBQcDaih5YlEvdZtw0VG9/FCKphRezSYyoq+lKVBV 7p5NKTTLV1yq4X9YQiiS/OiSLsPlpUBbveJrURN6UEcVS/XUDBKEO5JgHDB1AalERw0v m1XhzaxL9W+Af4zi3z0PqdVN+MsreahJfkrMcDJVnfPtVQ8HYau7i0Mcoi8UVQr6fUB2 1Xyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:to:message-id:in-reply-to:from:cc :user-agent:references:subject:content-transfer-encoding :mime-version:dkim-signature; bh=gqEucwrdi6Chws+59xYXQjnc2B6XgHyUHFcCbJE+l9Q=; b=DRwl5CBI/ImpoQDPGpAO77vbmNM7z6z+jHQHQzTMNswTrLNbtoQDQdEAWgD7Egpn4a wbNa2h8ZXljme7H8kdUqdXB4cpKyb4UwH8kHZ9W1XhtGj+RFvz/2idRf/oA75dmHNjSh QOz590O5EFauS4LFyvcZDsnI/Sj6uF4ARJHOR5NAhfH+veeBffZlvGR7DHwLEpgl7Y/4 pLaps6Lapff6ymRkh0Ig8a0USFXm7rkMKDJzHD5z+oMCkO4KMS5ijnlNPSXbmdpO85c5 bjTMa58hIzQE1tYsU2JpRVSNn06bYZCPkPVU/vEGm2hausILI9j3hK3EKx76w5h/+c+8 4Huw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=nERpfa9e; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f38si19662637pgf.206.2019.01.23.13.02.19; Wed, 23 Jan 2019 13:02:35 -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=@chromium.org header.s=google header.b=nERpfa9e; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727009AbfAWVAu (ORCPT + 99 others); Wed, 23 Jan 2019 16:00:50 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:43313 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726366AbfAWVAt (ORCPT ); Wed, 23 Jan 2019 16:00:49 -0500 Received: by mail-pl1-f193.google.com with SMTP id gn14so1759161plb.10 for ; Wed, 23 Jan 2019 13:00:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:content-transfer-encoding:subject:references :user-agent:cc:from:in-reply-to:message-id:to:date; bh=gqEucwrdi6Chws+59xYXQjnc2B6XgHyUHFcCbJE+l9Q=; b=nERpfa9eR4yguPuijdCxYM262CJLkb4tvWDUIqRdTsOmXJ8bx7rP61e9h+Ui1Sx1eV fpLJSgv7HIyLK42rPjc0+yZZ8lfd4q885/OB2UbjfvF4d+Vx3zcrpSTTl1aAsA8KekgE U6nHfERh+hFdUhhmrAJ3lXjuEqVRXTuHT0QiE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:content-transfer-encoding:subject :references:user-agent:cc:from:in-reply-to:message-id:to:date; bh=gqEucwrdi6Chws+59xYXQjnc2B6XgHyUHFcCbJE+l9Q=; b=AcJK+7af5Olr6B+ZEufvwd7zIuDh8Zh8BFrtywAUBjYXV5hDYbW69STQxXvgKAQ4Wm OnG5AUF8o8Q3gOLY3W2X+qb7DrAAwgbMJQh0O7mYW2q9AivpdBFWfWI1Ln2tbMo4LsEq g8NAF1HhNFe2lN37zTDR39f1n4QV3iClqACGPLHJ1WYf5I11N9xrwx7+gRmXMVEJd/kz WP3b8pa62plciKVhvXl+O1O4PnidTnhTHSpgnc1wS1OAY4mQnxoLOvgBj/xFfaAor6/O Vqy6VCuD/stbmqtFs+0kAeThGer7Od6mLEvvdBw84Bt/72Qj7xx6aWDIhutUosVa03rb sAqw== X-Gm-Message-State: AJcUukdI0ocRPOXN+bsQVwk7HaKdcgXPFFV+IK8PPscxw8FIUv9wJhfj cA/DJPJ2RurHZG8uybic04rWFg== X-Received: by 2002:a17:902:7791:: with SMTP id o17mr3805571pll.60.1548277248885; Wed, 23 Jan 2019 13:00:48 -0800 (PST) Received: from localhost ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id o66sm34290574pgo.75.2019.01.23.13.00.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Jan 2019 13:00:47 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: Re: [PATCH 5/7] drivers: pinctrl: msm: setup GPIO irqchip hierarchy References: <20181219221105.3004-1-ilina@codeaurora.org> <20181219221105.3004-6-ilina@codeaurora.org> <154533621302.79149.15228907259643696166@swboyd.mtv.corp.google.com> <20190116231328.GA20369@codeaurora.org> User-Agent: alot/0.8 Cc: evgreen@chromium.org, marc.zyngier@arm.com, linux-kernel@vger.kernel.org, rplsssn@codeaurora.org, linux-arm-msm@vger.kernel.org, thierry.reding@gmail.com, bjorn.andersson@linaro.org From: Stephen Boyd In-Reply-To: <20190116231328.GA20369@codeaurora.org> Message-ID: <154827724678.136743.1337362671388538883@swboyd.mtv.corp.google.com> To: Lina Iyer Date: Wed, 23 Jan 2019 13:00:46 -0800 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Lina Iyer (2019-01-16 15:13:28) > On Thu, Dec 20 2018 at 13:03 -0700, Stephen Boyd wrote: > >Quoting Lina Iyer (2018-12-19 14:11:03) > >> + > >> +static int msm_gpio_domain_alloc(struct irq_domain *domain, unsigned = int virq, > >> + unsigned int nr_irqs, void *arg) > >> +{ > >> + int ret; > >> + irq_hw_number_t hwirq; > >> + struct gpio_chip *gc =3D domain->host_data; > >> + struct msm_pinctrl *pctrl =3D gpiochip_get_data(gc); > >> + struct irq_fwspec *fwspec =3D arg; > >> + struct qcom_irq_fwspec parent =3D { }; > >> + unsigned int type; > >> + > >> + ret =3D msm_gpio_domain_translate(domain, fwspec, &hwirq, &typ= e); > >> + if (ret) > >> + return ret; > >> + > >> + ret =3D irq_domain_set_hwirq_and_chip(domain, virq, hwirq, > >> + &pctrl->irq_chip, gc); > >> + if (ret < 0) > >> + return ret; > >> + > >> + if (!domain->parent) > >> + return 0; > >> + > >> + parent.fwspec.fwnode =3D domain->parent->fwnode; > >> + parent.fwspec.param_count =3D 2; > >> + parent.fwspec.param[0] =3D hwirq; > >> + parent.fwspec.param[1] =3D type; > >> + > >> + ret =3D irq_domain_alloc_irqs_parent(domain, virq, nr_irqs, &p= arent); > >> + if (ret) > >> + return ret; > >> + > >> + if (parent.mask) > >> + set_bit(hwirq, pctrl->wakeup_masked_irqs); > >> + > >> + return 0; > >> +} > >> + > >> +/* > >> + * TODO: Get rid of this and push it into gpiochip_to_irq() > > > >Hmm.. yeah we need to do this still. I think we can have a generic two > >cell function similar to irq_domain_xlate_twocell() that does the fwspec > >creation and uses some of the things that we pass to > >gpiochip_irqchip_add(), like the default level type. This existing > >function is not good to have, so there's work to do to get rid of this. > > >=20 > >I was also thinking that maybe we can make the alloc function above take > >a struct gpio_irq_fwspec structure that tells the alloc function what > >gpiochip the irq is for. That would mean that we need to change the > >gpio_to_irq() function below to be generic and stuff the chip inside the > >fwspec wrapper structure: > > > > struct gpio_irq_fwspec { > > struct irq_fwspec fwspec; > > struct gpio_chip *chip; > > unsigned int offset; > > }; > > > >but I seem to recall that was not working for some reason. > > > I was thinking about this. If I understand you correctly, we want to > generalize the .translate and .alloc functions. We could move the > .translate to generic however, the alloc would still need to be specific > for the parent.mask. But we can do this without the gpio_irq_fwspec. I > presume you suggest this structure so we could pass the hwirq and type > to the .alloc function. but we have that in the fwspec. What am I > missing? I'm trying to flatten the irq number space into a single integer while letting it cross multiple gpio chips. Similar to how gpiolib flattens the gpio number space across multiple gpio chips. The goal being to make gpiochip_to_irq() do this all for us without having to implement it in each gpio driver, but maybe that isn't needed or wise if the goal is to move drivers away from taking a gpio number and converting it into an irq with gpio_to_irq() to begin with. FWIW, the SPMI PMIC gpio chip conversion patches didn't fix this problem and Brian just called irq_create_fwspec_mapping() from the to_irq() hook. So maybe this can be cleaned up later.