Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1639710ybl; Thu, 5 Dec 2019 04:48:31 -0800 (PST) X-Google-Smtp-Source: APXvYqzprIVnRCJFUJ5bkhORqWVp/fKmN4RTmnFIZrb3ujdyUBUd6H+v9IjOV64vzwWlJ5IYzatu X-Received: by 2002:a05:6830:4d1:: with SMTP id s17mr6691796otd.188.1575550110981; Thu, 05 Dec 2019 04:48:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575550110; cv=none; d=google.com; s=arc-20160816; b=KgRRvlHGfFHkVQ+1H4gMfhuU0HU3flg9qSTDaYsuz24opWGBgRAuNXkabUfeURAP9Q XZeg1pqrXlg1E+9Otg07lsd7vfzl2exRyPgaTsas7xIqdFVhpvlWIJ/qmLzcRzGMf7qx oAJ9ASjYzO0+VytP9wWF+vXnJngMANvs7NisQSZHPIjRT8EaW+Tqj5OFex91xrnLwzVM XSSART89Tl0ywLLkRcyyRJhEKY8wL9IXgtqPreK0RffcXy7Bq5T5PEjw1sg+X2Tdt7w/ ZFSzVKCAXGfBQ6EisoONXdQX266Ztuy1OsM+aZzUi06VChs1blYAeujhGDZaBw/3JCXe WBzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:cc:from:date:content-transfer-encoding:mime-version :subject:to; bh=NomYZTzFj9INDDj0PjWSkY1OO/l3oLiR0avZEgGbUww=; b=nc5gZzjnWfLh2PZLBLZAAUm7PGSdU6OdFNu1L8ESX6FkHw1h3HSxtgEgD0hr2M57hE hSwr7hqwyE1Wf7cIXaT51m7nwy1ZwvrOc+YSlcBi9f7p8MzNTBQ6JtIh5wUcycGxOM1m 6bf5A7JxRwBLoiiuCgKu01jWXQQzTvXOLTuPbUbkV8Iw0b9xuBCPiTuWFVjj72QUWpmm 2JfoK5pFDwJCxV6M8aNhn4isW/72daADSmMgIdL2mmfWOxDiUgXN4HHknZS9odmeC0XK VdN11YHIWbK9qVAJkk8y+Re7cwvFeF0Y7RfTTQQ/LJAtGDI8qaGdmtZWLrpzhlewwZ2n TrTw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w5si4867012oia.239.2019.12.05.04.48.18; Thu, 05 Dec 2019 04:48: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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729327AbfLEMrm (ORCPT + 99 others); Thu, 5 Dec 2019 07:47:42 -0500 Received: from inca-roads.misterjones.org ([213.251.177.50]:42311 "EHLO inca-roads.misterjones.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729096AbfLEMrm (ORCPT ); Thu, 5 Dec 2019 07:47:42 -0500 Received: from www-data by cheepnis.misterjones.org with local (Exim 4.80) (envelope-from ) id 1icqXi-00068a-Dx; Thu, 05 Dec 2019 13:47:38 +0100 To: Gaurav Kohli Subject: Re: [PATCH v0] irqchip/gic-v3: Avoid check of lpi configuration for non existent cpu X-PHP-Originating-Script: 0:main.inc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 05 Dec 2019 12:47:38 +0000 From: Marc Zyngier Cc: , , In-Reply-To: <1575543357-31892-1-git-send-email-gkohli@codeaurora.org> References: <1575543357-31892-1-git-send-email-gkohli@codeaurora.org> Message-ID: <60f61282c1b1e512ca6ce638b6dfca09@www.loen.fr> X-Sender: maz@kernel.org User-Agent: Roundcube Webmail/0.7.2 X-SA-Exim-Connect-IP: X-SA-Exim-Rcpt-To: gkohli@codeaurora.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on cheepnis.misterjones.org); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Gaurav, On 2019-12-05 10:55, Gaurav Kohli wrote: > As per GIC specification, we can configure gic for more no of cpus > then the available cpus in the soc, But this can cause mem abort > while iterating lpi region for non existent cpu as we don't map Which LPI region? We're talking about RDs, right... Or does LPI mean something other than GIC LPIs for you? > redistrubutor region for non-existent cpu. > > To avoid this issue, put one more check of valid mpidr. Sorry, but I'm not sure I grasp your problem. Let me try and rephrase it: - Your GIC is configured for (let's say) 8 CPUs, and your SoC has only 4. - As part of the probing, the driver iterates on the RD regions and explodes because something isn't mapped? That'd be a grave bug, but I believe the issue is somewhere else. > > Signed-off-by: Gaurav Kohli > > diff --git a/drivers/irqchip/irq-gic-v3.c > b/drivers/irqchip/irq-gic-v3.c > index 1edc993..adc9186 100644 > --- a/drivers/irqchip/irq-gic-v3.c > +++ b/drivers/irqchip/irq-gic-v3.c > @@ -766,6 +766,7 @@ static int gic_iterate_rdists(int (*fn)(struct > redist_region *, void __iomem *)) > { > int ret = -ENODEV; > int i; > + int cpu = 0; > > for (i = 0; i < gic_data.nr_redist_regions; i++) { > void __iomem *ptr = gic_data.redist_regions[i].redist_base; > @@ -780,6 +781,7 @@ static int gic_iterate_rdists(int (*fn)(struct > redist_region *, void __iomem *)) > } > > do { > + cpu++; > typer = gic_read_typer(ptr + GICR_TYPER); > ret = fn(gic_data.redist_regions + i, ptr); > if (!ret) > @@ -795,7 +797,8 @@ static int gic_iterate_rdists(int (*fn)(struct > redist_region *, void __iomem *)) > if (typer & GICR_TYPER_VLPIS) > ptr += SZ_64K * 2; /* Skip VLPI_base + reserved page */ > } > - } while (!(typer & GICR_TYPER_LAST)); > + } while (!(typer & GICR_TYPER_LAST) && > + cpu_logical_map(cpu) != INVALID_HWID); > } > > return ret ? -ENODEV : 0; This makes little sense. A redistributor region contains a bunch of RDs, each of which maps onto a given CPU. We iterate on the RDs, and not on the CPUs, as it is the RD that tells us which CPU it is affine with, not the other way around. If a RD is for some reason unavailable, then it shouldn't be described in the firmware the first place. If you end-up exposing RD regions that do not have the last RD having GICR_TYPER.Last set, then your SoC is broken, and this needs yet another quirk. M. -- Jazz is not dead. It just smells funny...