From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E85EC433E2 for ; Fri, 4 Sep 2020 13:59:03 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 555C62065E for ; Fri, 4 Sep 2020 13:59:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="kSYyOoVI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 555C62065E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=Huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=RxB9pG61gAQF9436wNmb+BEXNpTPzZGWJxRf2YFU9zo=; b=kSYyOoVIeETR+0H8Fng6iDeqB rzlj7o+posR3d1QPP9hOjtwDVItrKLR5GAGppAB43fi0653e1o/0LbdcfRqMnlhwoBCbP4+CaEF0I TiCUAdTDNM4a3b7TaF/lKfttmzS1ss+wCoiBWjPbLa8N+dFOmKlXLHGqc8F0dlvpO2Rhot5qhEtxP EVRvsTBoEJ6sKuxrJUilVGlc/N6cNCl8NrKH7DdEsHsZdUkXAHrOJgK1FNuVM4j1bd4Esp+GhtT8h xmgw2XcQ8O4Jr6U8U1opGS4aNRjk+7b9rYOM3LRcvzRCCYzIq1zTq4bXn0MhJlA8bQEG4TjHmLi7o Z71zo/+BA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kECDz-0003DW-8r; Fri, 04 Sep 2020 13:57:55 +0000 Received: from lhrrgout.huawei.com ([185.176.76.210] helo=huawei.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kECDw-0003CF-K3 for linux-arm-kernel@lists.infradead.org; Fri, 04 Sep 2020 13:57:53 +0000 Received: from lhreml710-chm.china.huawei.com (unknown [172.18.7.107]) by Forcepoint Email with ESMTP id 1D9F829501C8A7DD5F64; Fri, 4 Sep 2020 14:57:51 +0100 (IST) Received: from localhost (10.52.125.29) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1913.5; Fri, 4 Sep 2020 14:57:50 +0100 Date: Fri, 4 Sep 2020 14:56:16 +0100 From: Jonathan Cameron To: Marc Zyngier Subject: Re: [PATCH 03/23] irqchip: Add Reduced Virtual Interrupt Distributor support Message-ID: <20200904145616.00007950@Huawei.com> In-Reply-To: <20200903152610.1078827-4-maz@kernel.org> References: <20200903152610.1078827-1-maz@kernel.org> <20200903152610.1078827-4-maz@kernel.org> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; i686-w64-mingw32) MIME-Version: 1.0 X-Originating-IP: [10.52.125.29] X-ClientProxiedBy: lhreml743-chm.china.huawei.com (10.201.108.193) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200904_095752_761426_E93DB358 X-CRM114-Status: GOOD ( 22.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Pieralisi , kvm@vger.kernel.org, Suzuki K Poulose , Christoffer Dall , James Morse , Julien Thierry , kernel-team@android.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 3 Sep 2020 16:25:50 +0100 Marc Zyngier wrote: > Signed-off-by: Marc Zyngier Hi Marc, Again, only trivial stuff in here from me. Jonathan > --- > drivers/irqchip/Kconfig | 6 + > drivers/irqchip/Makefile | 1 + > drivers/irqchip/irq-rvid.c | 259 +++++++++++++++++++++++++++++++ > include/linux/irqchip/irq-rvic.h | 19 +++ > 4 files changed, 285 insertions(+) > create mode 100644 drivers/irqchip/irq-rvid.c > ... > +static int rvid_irq_set_affinity(struct irq_data *data, > + const struct cpumask *mask_val, > + bool force) > +{ > + unsigned int old_cpu, cpu; > + bool masked, pending; > + int err = 0, ret; Looks like err is set in all paths (might change in later patches of course!) > + u64 mpidr; > + > + if (force) > + cpu = cpumask_first(mask_val); > + else > + cpu = cpumask_any_and(mask_val, cpu_online_mask); > + > + if (cpu >= nr_cpu_ids) > + return -EINVAL; > + > + mpidr = cpu_logical_map(cpu) & MPIDR_HWID_BITMASK; > + old_cpu = cpumask_first(data->common->effective_affinity); > + if (cpu == old_cpu) > + return 0; > + > + /* Mask on source */ > + masked = irqd_irq_masked(data); > + if (!masked) > + irq_chip_mask_parent(data); > + > + /* Switch to target */ > + irq_data_update_effective_affinity(data, cpumask_of(cpu)); > + > + /* Mask on target */ > + irq_chip_mask_parent(data); > + > + /* Map the input signal to the new target */ > + ret = rvid_map(data->hwirq, mpidr, data->parent_data->hwirq); > + if (ret != RVID_STATUS_SUCCESS) { > + err = -ENXIO; > + goto unmask; > + } > + > + /* Back to the source */ > + irq_data_update_effective_affinity(data, cpumask_of(old_cpu)); > + > + /* Sample pending state and clear it if necessary */ > + err = irq_chip_get_parent_state(data, IRQCHIP_STATE_PENDING, &pending); > + if (err) > + goto unmask; > + if (pending) > + irq_chip_set_parent_state(data, IRQCHIP_STATE_PENDING, false); > + > + /* > + * To the target again (for good this time), propagating the > + * pending bit if required. > + */ > + irq_data_update_effective_affinity(data, cpumask_of(cpu)); > + if (pending) > + irq_chip_set_parent_state(data, IRQCHIP_STATE_PENDING, true); > +unmask: > + /* Propagate the masking state */ > + if (!masked) > + irq_chip_unmask_parent(data); > + > + return err; > +} > + ... > +static int rvid_irq_domain_alloc(struct irq_domain *domain, unsigned int virq, > + unsigned int nr_irqs, void *arg) > +{ > + struct irq_fwspec *fwspec = arg; > + unsigned int type = IRQ_TYPE_NONE; > + irq_hw_number_t hwirq; > + int i, ret; > + > + ret = irq_domain_translate_onecell(domain, fwspec, &hwirq, &type); > + if (ret) > + return ret; > + > + for (i = 0; i < nr_irqs; i++) { > + unsigned int intid = hwirq + i; > + unsigned int irq = virq + i; > + > + /* Get the rVIC to allocate any untrusted intid */ > + ret = irq_domain_alloc_irqs_parent(domain, irq, 1, NULL); > + if (WARN_ON(ret)) > + return ret; > + > + irq_domain_set_hwirq_and_chip(domain, irq, intid, > + &rvid_chip, &rvid); > + irqd_set_affinity_on_activate(irq_get_irq_data(irq)); > + } > + > + return 0; > +} > + > +static void rvid_irq_domain_free(struct irq_domain *domain, unsigned int virq, > + unsigned int nr_irqs) > +{ > + int i; > + > + irq_domain_free_irqs_parent(domain, virq, nr_irqs); > + > + for (i = 0; i < nr_irqs; i++) { > + struct irq_data *d; Trivial but for ease of comparison with _alloc, perhaps add unsigned int int = virq + i; > + > + d = irq_domain_get_irq_data(domain, virq + i); > + irq_set_handler(virq + i, NULL); > + irq_domain_reset_irq_data(d); > + } > +} > + _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel