Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3833070imm; Mon, 11 Jun 2018 02:32:26 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ15NwgkhahcxoGjtoYsPWJpd590RAxjeQj1i4DtSyd4AL4gQ0bksNBnt9CaZ7jTeTU+3Yh X-Received: by 2002:a62:d913:: with SMTP id s19-v6mr16721983pfg.39.1528709546007; Mon, 11 Jun 2018 02:32:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528709545; cv=none; d=google.com; s=arc-20160816; b=hivru2mC5+kaI420HjCkrVmBvu0VDTIjMNPVDkbkonPTh9grtAapobxOmxRslq2yXq G+fxolELLyNGIG0SbI3I1Z/1MhnVyxMDQ5A+DROHJD6lONzaXC7sM+bedZCClwe2czE6 izNUbOhAurpeFEaUXZGCJf8oe+uHn+nwA/fuO1iuxj0/r0OBDBp4zttVyFie59dj7oQK CbdBVLiGiucGo45OJCiJRr6wl4YZDd7TjmysKHlObCqvmoM80iNT0euI77bCv6R2Hp+w rvc4uJcv4Bh7v8Bj+qhRucW6/Np/cMpQ4zPXvc47omLhfCU5utxlusmbnruYw9sK7Uwu RmeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :arc-authentication-results; bh=QSTFrsAEvzqjL6gcEgsBZNGkqH9AGlZdJ4XU3p0KOXU=; b=bL4elCBZl/luF+SCmoc2xSCCgq76/6FuY7prLMachAMSH+Ycx/uvJFIq+GjWG/T1bt oLe9N12GI0CfrCOYA/0v9mrW8j8xiLa7OAr63RLrijchA4pa78tsJL1fTzFebM7lMEgW c3tk2kNHtSEqt6uN4+YGTI6T0kv+Zir/GqT2K4JJ1b6BdWwhSFqlZlxqZJDh1V/YTtYt XILfit7ZNK2Sj2QGBKqvgjtRhdVZz2lbtnUGYvnig0w1KFde9e8BDeJCmWP4nknUlnk9 2C8L8WIZGrez30XYdzBw5X2XppSPUNzaGIwRZZCyMcHEtCJ7zoF3j+p1+CkX2tn9Y9g4 SxFA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t7-v6si19247479pgv.668.2018.06.11.02.32.11; Mon, 11 Jun 2018 02:32:25 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932674AbeFKJbs (ORCPT + 99 others); Mon, 11 Jun 2018 05:31:48 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:49454 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932272AbeFKJbr (ORCPT ); Mon, 11 Jun 2018 05:31:47 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D39F61435; Mon, 11 Jun 2018 02:31:46 -0700 (PDT) Received: from [10.1.206.75] (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E769A3F53D; Mon, 11 Jun 2018 02:31:45 -0700 (PDT) Subject: Re: [PATCH v2] irqchip/gic-v3-its: fix ITS queue timeout To: Yang Yingliang , julien.thierry@arm.com Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Hanjun Guo References: <1528252824-15144-1-git-send-email-yangyingliang@huawei.com> From: Marc Zyngier Organization: ARM Ltd Message-ID: <0ebd8eef-1a86-3c7e-cd3b-f9580c497b5c@arm.com> Date: Mon, 11 Jun 2018 10:31:44 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <1528252824-15144-1-git-send-email-yangyingliang@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/06/18 03:40, Yang Yingliang wrote: > When the kernel booted with maxcpus=x, 'x' is smaller > than actual cpu numbers, the TAs of offline cpus won't > be set to its->collection. > > If LPI is bind to offline cpu, sync cmd will use zero TA, > it leads to ITS queue timeout. Fix this by choosing a > online cpu, if there is no online cpu in cpu_mask. > > Signed-off-by: Yang Yingliang > --- > drivers/irqchip/irq-gic-v3-its.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c > index 5416f2b..d8b9539 100644 > --- a/drivers/irqchip/irq-gic-v3-its.c > +++ b/drivers/irqchip/irq-gic-v3-its.c > @@ -2309,7 +2309,9 @@ static int its_irq_domain_activate(struct irq_domain *domain, > cpu_mask = cpumask_of_node(its_dev->its->numa_node); > > /* Bind the LPI to the first possible CPU */ > - cpu = cpumask_first(cpu_mask); > + cpu = cpumask_first_and(cpu_mask, cpu_online_mask); > + if (cpu >= nr_cpu_ids) > + cpu = cpumask_first(cpu_online_mask); I've thought about this one a bit more, and apart from breaking TX1 in a very bad way, I think it is actually correct. It is just that the commit message doesn't make much sense. The way I understand it is: - this is a NUMA system, with at least one node not online - the SRAT table indicates that this ITS is local to an offline node In that case, we need to pick an online CPU, and any will do (again, ignoring the silly Cavium erratum). Explained like this, the above hunk is sensible, and just needs to handle the TX1 quirk. Something like: diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 5416f2b2ac21..21b7b5151177 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -2309,7 +2309,13 @@ static int its_irq_domain_activate(struct irq_domain *domain, cpu_mask = cpumask_of_node(its_dev->its->numa_node); /* Bind the LPI to the first possible CPU */ - cpu = cpumask_first(cpu_mask); + cpu = cpumask_first_and(cpu_mask, cpu_online_mask); + if (cpu >= nr_cpu_idx) { + if (its_dev->its->flags & ITS_FLAGS_WORKAROUND_CAVIUM_23144) + return -EINVAL; + + cpu = cpumask_first(cpu_online_mask); + } its_dev->event_map.col_map[event] = cpu; irq_data_update_effective_affinity(d, cpumask_of(cpu)); > its_dev->event_map.col_map[event] = cpu; > irq_data_update_effective_affinity(d, cpumask_of(cpu)); > > @@ -2466,7 +2468,10 @@ static int its_vpe_set_affinity(struct irq_data *d, > bool force) > { > struct its_vpe *vpe = irq_data_get_irq_chip_data(d); > - int cpu = cpumask_first(mask_val); > + int cpu = cpumask_first_and(mask_val, cpu_online_mask); > + > + if (cpu >= nr_cpu_ids) > + cpu = cpumask_first(cpu_online_mask); > > /* > * Changing affinity is mega expensive, so let's be as lazy as > This hunk, on the other hand, is completely useless. Look how this is called from vgic_v4_flush_hwstate(): err = irq_set_affinity(irq, cpumask_of(smp_processor_id())); The mask is always that of the CPU we run on, and we're in a non-premptible section. So no way we can be targeting an offline CPU. If you quickly respin this patch with a decent commit log, I'll take it. Thanks, M. -- Jazz is not dead. It just smells funny...