Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3691344imu; Tue, 18 Dec 2018 02:33:29 -0800 (PST) X-Google-Smtp-Source: AFSGD/V7483vH1EUEqG+nU0LKk3ZEIutxjT/x4+/FPhT3L+3aW+aTYi2T43unYVLFRhx3RHhApPa X-Received: by 2002:a17:902:f44:: with SMTP id 62mr16189238ply.38.1545129208976; Tue, 18 Dec 2018 02:33:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545129208; cv=none; d=google.com; s=arc-20160816; b=hJDn8fNk/T3c4ZXpFAYf/Mk2/Rxr8nZmpL9m7yjdbIuXRnfNLujoucD7mYa+vMWQ3p WIlBFFAH5wOnt4fyrwrVT0vMej+IbH6LRqHXZ/lzKi0yWcDUuG/FTIEfqFipVYXlbJlo BQqjqP5UHqLogYlOxdrbf0PbztBAesMuZo0QyKRd4kRvEZDRTopSlNIIIIrH0+M+PYaS UQZ9TmRJHiv4FzKPqz25CVW2UllE5wENFygljDf0KNg+RrS0ujOGDX7W5Jz/Wr0b5y3c YAd+yQH+erf8mkb5Y2SKH2uGKRpfkVddfY4wAHlz8Sj8j71js7fICnkSQ0kzV9XvWDLk QP6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=6YTuC8veEqcdC00DnB8iCpbVjsjm1RFbphabmuAgDsY=; b=j8JJsm+fgax+hTG1foYektdpuvS5X1uF0O4s1L6HkHXAS6OuXw0emftx1x9sL/Pn6g 15RQZ4fhzaXvOTFhmqg3Ni6RmnGQ20o9sG0LWj8+RJ2ZczVF7aZRw7Z5VIRPRfaZWu9x YApjhRkjxy/NAkioeq42xt46X93wYtE+ZDchfjBBktAsHLyKeCeFJveAKyPiY9lDbDnn Kmc9mo8qSeeM+1VnN0bTVXMsSRghIBfjeCgFzYi7QXNLdtL4g4mz7T9YgIknvvGEqPdv Ky6FHPTeN69Q+Y0arm1OoAGWVlIQb3GpfcBhqVs5mkwNjd+FI91Ytd0TEKP4jPrms9ap csIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=Wg7PnavM; 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 g187si13230673pfc.43.2018.12.18.02.33.13; Tue, 18 Dec 2018 02:33:28 -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=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=Wg7PnavM; 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 S1726451AbeLRKcX (ORCPT + 99 others); Tue, 18 Dec 2018 05:32:23 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:38482 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726427AbeLRKcX (ORCPT ); Tue, 18 Dec 2018 05:32:23 -0500 Received: by mail-wr1-f65.google.com with SMTP id v13so15316979wrw.5 for ; Tue, 18 Dec 2018 02:32:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6YTuC8veEqcdC00DnB8iCpbVjsjm1RFbphabmuAgDsY=; b=Wg7PnavMsDxylnR64ewsOx6DVp9Ym5mrsCv5anM6FNWkBF+s2w4wdJjgz6BcJ8fQ8R WATAxridgmlUOqtvY2gdSEaQRAW6iyZSmohh6SOWCyYNTYmN22HvsT/Edx4W9b1Bq8sK +Nse9P6eeXSObtFHUY4c6apd0AsrHHdjSoGQ0fCg8qmbsg1nzP2D5i/fqEK3qNjupdnb 6+31LhYqwpDv2UyncJ0PZRADXCu7j3Cjy3XNNJvEKEpHjjeo58SZ06n+NxDIjJ2YxPjl mduXfJ5ANr1vPcE1aXjeWMXVJidAOs9V0uddYbwZ4hWGvyTDxmvFvw3+7xfsrXdj3r55 L2tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6YTuC8veEqcdC00DnB8iCpbVjsjm1RFbphabmuAgDsY=; b=sggUYQaiB7nK27TX3xEZCSpM4+5aHh7564WpO84KSAzqIyTuSankJ2mpkGiYlzg8w9 ZWSC+ULsEP7WHh+Ad2khU+lktQpEWlmY7ZjJWG10fbLGFFgNzxheC7u5v9wAiviH1Q0T CxhxfydxJKfcNPqiPGlGaJpFMy1I9KRpQ3fDT2bFOEV5uANphROj5m6Ej7QkGNYd57IL URiOhJAm0RE8tJD4mB8DFcag+7r2XZBi2QAldNch6OuFZaJDYW+bHA9OYO7Qta9R5qbA l9v1XdGULLZTiA5+hKs9TP4aMVNE+GrgUxLTCTkf/oMZLM+/86viwu6YOYmSNBc+n4yI jvDQ== X-Gm-Message-State: AA+aEWamxBCE0nqh6MLKY3KeMeIZi4aTK1WP4HzyJQ1+O1MlY387Brr3 39uiz0ICn4ydpT5ODzJp4y0laEXH3Y7enycqIocV1A== X-Received: by 2002:adf:ee07:: with SMTP id y7mr14648797wrn.187.1545129140582; Tue, 18 Dec 2018 02:32:20 -0800 (PST) MIME-Version: 1.0 References: <20181130080207.20505-1-anup@brainfault.org> <20181130080207.20505-7-anup@brainfault.org> <20181217183220.GE7086@infradead.org> In-Reply-To: <20181217183220.GE7086@infradead.org> From: Anup Patel Date: Tue, 18 Dec 2018 16:02:09 +0530 Message-ID: Subject: Re: [PATCH v3 6/6] irqchip: sifive-plic: Implement irq_set_affinity() for SMP host To: Christoph Hellwig Cc: Palmer Dabbelt , Albert Ou , Daniel Lezcano , Thomas Gleixner , Jason Cooper , Marc Zyngier , Atish Patra , linux-riscv@lists.infradead.org, "linux-kernel@vger.kernel.org List" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 18, 2018 at 12:02 AM Christoph Hellwig wrote: > > On Fri, Nov 30, 2018 at 01:32:07PM +0530, Anup Patel wrote: > > This patch provides irq_set_affinity() implementation for PLIC driver. > > It also updates irq_enable() such that PLIC interrupts are only enabled > > for one of CPUs specified in IRQ affinity mask. > > But normally our affinity masks are that - masks of CPUs that can take > it. It seems a bit odd to then just pick the first one, as this means > with default all-CPU masks we'll have all interrupts handled by the > first CPU only. Yes, affinity mask are CPUs which can take but there is also effective affinity mask which represent CPUs which will actually receive IRQ. Interrupt controllers (unlike PLIC) can support hardware IRQ balancing. For such interrupt controllers, we inform all CPUs that can take IRQ but interrupt controller will only deliver IRQ to only one of the CPUs. There are quite a few interrupt controllers which only allow IRQ to be taken by exactly one CPU. For such interrupt controllers, the interrupt controller driver has to to pick one CPU out of CPUs which can take IRQ (Example GICv2, GICv3, etc). > > > > --- a/drivers/irqchip/irq-sifive-plic.c > > +++ b/drivers/irqchip/irq-sifive-plic.c > > @@ -106,14 +106,42 @@ static void plic_irq_toggle(const struct cpumask *mask, int hwirq, int enable) > > > > static void plic_irq_enable(struct irq_data *d) > > { > > - plic_irq_toggle(irq_data_get_affinity_mask(d), d->hwirq, 1); > > + unsigned int cpu = cpumask_any_and(irq_data_get_affinity_mask(d), > > + cpu_online_mask); > > + WARN_ON(cpu >= nr_cpu_ids); > > I think this should be WARN_ON_ONCE and actually return instead of then > proceeding using the invalid cpu index. Sure, will update. > > > +#ifdef CONFIG_SMP > static int plic_set_affinity(struct irq_data *d, const struct cpumask *mask_val, > > + bool force) > > +{ > > + unsigned int cpu; > > + > > + if (!force) > > + cpu = cpumask_any_and(mask_val, cpu_online_mask); > > + else > > + cpu = cpumask_first(mask_val); > > maybe swap the two branches around to avoid the inversion of the force > flag? Sure, will update. Regards, Anup