From patchwork Tue Sep 15 11:20:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ivan T. Ivanov" X-Patchwork-Id: 7183921 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 228F2BEEC1 for ; Tue, 15 Sep 2015 11:22:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2A09220706 for ; Tue, 15 Sep 2015 11:22:54 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 408D1206FF for ; Tue, 15 Sep 2015 11:22:53 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZboIG-0004AX-EN; Tue, 15 Sep 2015 11:21:00 +0000 Received: from ns.mm-sol.com ([37.157.136.199] helo=extserv.mm-sol.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZboIC-00047O-Ro for linux-arm-kernel@lists.infradead.org; Tue, 15 Sep 2015 11:20:58 +0000 Received: from [192.168.27.93] (unknown [37.157.136.206]) by extserv.mm-sol.com (Postfix) with ESMTPSA id EC0ACC910; Tue, 15 Sep 2015 14:20:30 +0300 (EEST) Message-ID: <1442316018.15519.4.camel@mm-sol.com> Subject: Re: [PATCH] spmi-pmic-arb: support configurable number of peripherals From: "Ivan T. Ivanov" To: Stephen Boyd Date: Tue, 15 Sep 2015 14:20:18 +0300 In-Reply-To: <55F77451.9070900@codeaurora.org> References: <1442267672-11287-1-git-send-email-sboyd@codeaurora.org> <55F77451.9070900@codeaurora.org> X-Mailer: Evolution 3.13.7-fta1.2~trusty Mime-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150915_042057_303227_0343D62A X-CRM114-Status: GOOD ( 21.77 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kroah-Hartman , Gilad Avidov , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Sagar Dharia , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Mon, 2015-09-14 at 18:28 -0700, Stephen Boyd wrote: > On 09/14/2015 02:54 PM, Stephen Boyd wrote: > > The current driver implementation supports only 128 peripherals. > > Add support for more than 128 peripherals by taking a lazy > > caching approach to the mapping tables. Instead of reading the > > tables at boot given some fixed size, read them on an as needed > > basis and cache the results. We still assume a max number of 512 > > peripherals, trading off some space for simplicity. > > > > Based on a patch by Gilad Avidov and > > Sagar Dharia . > > > > Signed-off-by: Stephen Boyd > > --- > > Hi Ivan, > > This patch causes 8916 to crash, because there isn't a mapping for ppid > 257 in the ppid to channel table. It seems that we're reading the revid > from the slave id 1 pmic by going through channel 0, which seems to be > setup for ppid 9 (slave id 0 and the peripheral starting at 0x900). Can > we stop reading the revid registers from non-zero slave id pmic devices? > That would be one solution to fix this problem. Or maybe we need to > special case this in the pmic arbiter code to fold ppid 0xN01 (slave id > N and address 0x100) onto channel 0 all the time? > Yes, we can. We are not using this information at the moment. Right now, revision read is more or less for debug purposes. Would following patch work for you? Of course it will be difficult to guaranties that some other driver misbehave and touch non-existing register, right? Regards, Ivan Tested-by: Stephen Boyd From d7c9c59b7134f093cf3f829832f4f7771a65664e Mon Sep 17 00:00:00 2001 From: "Ivan T. Ivanov" Date: Tue, 15 Sep 2015 09:43:10 +0300 Subject: [PATCH] mfd: qcom-spmi-pmic: Do not access non existing registers Cc: linux-kernel@vger.kernel.org Revision ID registers are available only on devices with Slave ID Zero, so don't make access to unavailable registers. Signed-off-by: Ivan T. Ivanov --- drivers/mfd/qcom-spmi-pmic.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/mfd/qcom-spmi-pmic.c b/drivers/mfd/qcom-spmi-pmic.c index af6ac1c4b45c..d7ad72af5682 100644 --- a/drivers/mfd/qcom-spmi-pmic.c +++ b/drivers/mfd/qcom-spmi-pmic.c @@ -122,12 +122,22 @@ static int pmic_spmi_probe(struct spmi_device *sdev) { struct device_node *root = sdev->dev.of_node; struct regmap *regmap; + u32 sid; + int ret; + + ret = of_property_read_u32(root, "reg", &sid); + if (ret < 0) { + dev_err(&sdev->dev, "Missing SID\n"); + return ret; + } regmap = devm_regmap_init_spmi_ext(sdev, &spmi_regmap_config); if (IS_ERR(regmap)) return PTR_ERR(regmap); - pmic_spmi_show_revid(regmap, &sdev->dev); + /* Only devices with Slave ID Zero contain this information */ + if (sid == 0) + pmic_spmi_show_revid(regmap, &sdev->dev); return of_platform_populate(root, NULL, NULL, &sdev->dev); } -- 1.9.1