Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp7809019rwp; Wed, 19 Jul 2023 00:03:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlG4N5ZiwUKtiim6bxcTtwvnF8CkBgABMULNLaBhhT8drCucrtLjXS5/2+U5s6MdiUB6/CjF X-Received: by 2002:a05:6a20:7f85:b0:132:ef90:1d1d with SMTP id d5-20020a056a207f8500b00132ef901d1dmr2611945pzj.0.1689750220066; Wed, 19 Jul 2023 00:03:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689750220; cv=none; d=google.com; s=arc-20160816; b=FVbJpF0HdU2F/H9FOCAn8k7MKfFq8LZI0H2o4v+maJUiSgmvOq577flmVcWYT4loYv VcXeOMaiT2z/zIOSq3wmjcb8aZJNf5SC8DAGURufdHO7L9SVp+VUQSiBtoCVh13fZgla Y26tjknf7Hhvrzx4lnTY7q1OViexW+ghwlkY3pit+ocMXXQxMO3wDo3W3UmmpsXQ7AI7 Yp7TgiyY9263PNGU4QOZopLO9unMcDX2B9gXG1GvQ8hoE5AqoS/nmc7A/Q9gybztcSvm HVYkxxTrUAkYPOo2zmlDjtbhdOlhh2cKFgCKCwBwIXRg9YX8qpj9pkgzqathiZGB/m9Y /Ulg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=chjcn51OJ3EN7pOX/BdWVwa5bmrkM1TE6sVVPhnbIr4=; fh=qZLgqBrA0TDTemqgHICeSNHVLsTK7kq22SqPqkiag9M=; b=Azm9RORdHhgAxLRIpnt//PbHXZoIGTiI7Lli4kvfT88ojM3cOInl+Y3bBzGMKplmVp HdtBAq2v5npe8q4pAmEIETZ/SrlfqC7nok51AXMR/5N2ipWcTnwPvwbRbg0gzZQXEbZh +9w2c88n3rZ+2DtKyfdwi+JmgE1CV86QAQn1et/lYWjSidN79/aAj7oMDu5lEjpi5AnM 07cgkuwMQ/br+NZtHBwRCeht5DvnABsljHvmdwor3VGRDQoI89iCj46oRk2YzXWro73X mGtvzAVC2Ebxw2yv72WCeVbojqmi4a5n8JS+erpUNWbm4nGIE/i5EkZtswG5weUobPDT q+3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bd16-20020a056a00279000b0064d28479818si2939225pfb.96.2023.07.19.00.03.27; Wed, 19 Jul 2023 00:03:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230480AbjGSGge (ORCPT + 99 others); Wed, 19 Jul 2023 02:36:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229459AbjGSGgc (ORCPT ); Wed, 19 Jul 2023 02:36:32 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1F0841FCB; Tue, 18 Jul 2023 23:36:22 -0700 (PDT) Received: from loongson.cn (unknown [10.2.9.158]) by gateway (Coremail) with SMTP id _____8AxueplhLdkLiQHAA--.8702S3; Wed, 19 Jul 2023 14:36:21 +0800 (CST) Received: from kvm-1-158.loongson.cn (unknown [10.2.9.158]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxniNOhLdkQGc0AA--.38253S3; Wed, 19 Jul 2023 14:36:21 +0800 (CST) From: Bibo Mao To: Huacai Chen , Jiaxun Yang , Marc Zyngier Cc: Jianmin Lv , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v5 1/2] irqchip/loongson-eiointc: Fix return value checking of eiointc_index Date: Wed, 19 Jul 2023 14:35:57 +0800 Message-Id: <20230719063558.3131045-2-maobibo@loongson.cn> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230719063558.3131045-1-maobibo@loongson.cn> References: <20230719063558.3131045-1-maobibo@loongson.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8BxniNOhLdkQGc0AA--.38253S3 X-CM-SenderInfo: xpdruxter6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBj93XoW7uw4Duw48Zr45tw4rAF1DurX_yoW8Ww1rpF W2ka9I9r15Gay8u392kF18J34Yyrn3J3y7K3yxGay7XF98Jr1DJr4Fy3Z0vr1Ik3y7CF12 9F4rXFWUC3Z8AwcCm3ZEXasCq-sJn29KB7ZKAUJUUUUr529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUU9Fb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2kKe7AKxVWUXVWUAwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07 AIYIkI8VC2zVCFFI0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWU AVWUtwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7V AKI48JMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMxCIbckI1I0E14v2 6r1Y6r17MI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17 CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1I6r4UMIIF 0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIx AIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2 KfnxnUUI43ZEXa7IU8q2NtUUUUU== X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return value of function eiointc_index is int, however it is converted into uint32_t and then compared smaller than zero. This causes logic problem. There is eiointc initialization problem on qemu virt-machine where there is only one eiointc node and more than 4 vcpus. Nodemap of eiointc is 1, and external device intr can only be routed to vcpu 0-3, the other vcpus can not response any external device interrupts and only local processor interrupts like ipi/timer can work. Fixes: dd281e1a1a93 ("irqchip: Add Loongson Extended I/O interrupt controller support") Signed-off-by: Bibo Mao Reviewed-by: Philippe Mathieu-Daudé --- drivers/irqchip/irq-loongson-eiointc.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/irqchip/irq-loongson-eiointc.c b/drivers/irqchip/irq-loongson-eiointc.c index 92d8aa28bdf5..603d323b8f8b 100644 --- a/drivers/irqchip/irq-loongson-eiointc.c +++ b/drivers/irqchip/irq-loongson-eiointc.c @@ -144,12 +144,15 @@ static int eiointc_router_init(unsigned int cpu) int i, bit; uint32_t data; uint32_t node = cpu_to_eio_node(cpu); - uint32_t index = eiointc_index(node); + int index = eiointc_index(node); - if (index < 0) { - pr_err("Error: invalid nodemap!\n"); - return -1; - } + /* + * Qemu virt-machine has only one eiointc and more than four cpus. + * Irq from eiointc can only be routed to cpu 0-3, cpus except 0-3 + * need not initialize eiointc on virt-machine + */ + if (index < 0) + return 0; if ((cpu_logical_map(cpu) % CORES_PER_EIO_NODE) == 0) { eiointc_enable(); -- 2.27.0