Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp36745371rwd; Tue, 11 Jul 2023 05:19:21 -0700 (PDT) X-Google-Smtp-Source: APBJJlFaQjkh1c5OFDes+YXbCFai3FTI8bWtgNkt5RcmRk0CuhlKjL/C74bgob3SdVByeYb81Ka9 X-Received: by 2002:a92:1a4f:0:b0:345:b6e8:6d54 with SMTP id z15-20020a921a4f000000b00345b6e86d54mr15399132ill.31.1689077960926; Tue, 11 Jul 2023 05:19:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689077960; cv=none; d=google.com; s=arc-20160816; b=nOwFHJDB+BYk9yvt+VSd13bisz6XaFvil73mP05ohhY+nHSmO4xK+iRiDArLVjJvu+ iMBJAuqV8GxYujcinZ+j7TbL2nXUmKbctZXvc8VtN5bWDEwmJXRbMZmUB7Axumfzjuuc VpZ1eWcm/CXtSQMPoInMXjkcBvUlDtD6ZtF9pruwfghHE13l8ykvBA7NAonU7/tl8pBn 8+ysnjYfWLpImKP/MMvjja7FhjWJD6NR+TlhkThHwVmqdjG/Fn4Fx29lBceBxu/faHYM hiOA6GYjcyEKqPEvb4MPoEEzWES/bSuzSgoJYcFcNWINooFrCpqYZaeA0UAZ7OyaP+Kz VeTw== 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=DnkjJIu15w//EPnydfOrfv24PzJVWbYbAJLftusk9ng=; fh=WrELnb4ZUhcKoy8qr+86JwLN9Krfq2ED1i0xcLj9B70=; b=zFZZAZ2OP39508LlOQZHKP9S2F4agm8j7NtIHa8mHBoa1wawGC5KzzCG7vi0ibRgEU Sn9PiACp3V3VIpbQ+hLOtO0NrLX2tW9TbTMV7dc8Da1boichYwASEUTrhErrHK5GI5qW dduE1sxldyxnA46VKZhcGJQ+ta4vgCjTJW4ex97h4v+r3coim/8WEYEX6A191CtxhZJJ 1Pc+LU1M50Ebx59ejSZ7ocS8SnMt9WNBMgAPU/IudJgkpf4SP/YM9S1C3tVHuIr/Z5Et c+qdMeff6fJSW5YeZsU1CtPMRKdhiSutQXOxcDpH0SPnqdUVtkZPWuq+bGsZowQ8jUCe DDNA== 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 j36-20020a63fc24000000b0055799d9b4basi1323726pgi.893.2023.07.11.05.18.45; Tue, 11 Jul 2023 05:19:20 -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 S230306AbjGKMIP (ORCPT + 99 others); Tue, 11 Jul 2023 08:08:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230072AbjGKMIM (ORCPT ); Tue, 11 Jul 2023 08:08:12 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A538FE67; Tue, 11 Jul 2023 05:08:09 -0700 (PDT) Received: from loongson.cn (unknown [10.2.9.158]) by gateway (Coremail) with SMTP id _____8BxHOsoRq1kiH8DAA--.4850S3; Tue, 11 Jul 2023 20:08:08 +0800 (CST) Received: from kvm-1-158.loongson.cn (unknown [10.2.9.158]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxfSMnRq1k+6goAA--.1095S3; Tue, 11 Jul 2023 20:08:08 +0800 (CST) From: Bibo Mao To: Huacai Chen , Jiaxun Yang , Marc Zyngier Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Jianmin Lv , loongson-kernel@lists.loongnix.cn Subject: [PATCH v3 1/2] irqchip/loongson-eiointc: Fix return value checking of eiointc_index Date: Tue, 11 Jul 2023 20:08:06 +0800 Message-Id: <20230711120807.1805186-2-maobibo@loongson.cn> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230711120807.1805186-1-maobibo@loongson.cn> References: <20230711120807.1805186-1-maobibo@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8DxfSMnRq1k+6goAA--.1095S3 X-CM-SenderInfo: xpdruxter6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBj93XoW7uw4Duw48Zr45uFWkAF4fJFc_yoW8Xr15pF W7AFZF9w15Ga4xurZ2kF48JryYywn3t3y7K3yxJay7Xan8Jw1DJr4rA3Wqyr1IkrW7uFy2 gF4rXFWUC3Z8AwcCm3ZEXasCq-sJn29KB7ZKAUJUUUUr529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUU9Yb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVWxJr0_GcWln4kS14v26r1Y6r17M2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12 xvs2x26I8E6xACxx1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r12 6r1DMcIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64 vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1l4IxYO2xFxVAFwI0_ Jrv_JF1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1V AY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_JFI_Gr1lIxAI cVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42 IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIev Ja73UjIFyTuYvjxUc0eHDUUUU 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 eioint initialization problem on qemu virt-machine where there is only one eioint node and more than 4 vcpus. Nodemap of eioint 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. Signed-off-by: Bibo Mao --- drivers/irqchip/irq-loongson-eiointc.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/irqchip/irq-loongson-eiointc.c b/drivers/irqchip/irq-loongson-eiointc.c index 92d8aa28bdf5..1c5a5b59f199 100644 --- a/drivers/irqchip/irq-loongson-eiointc.c +++ b/drivers/irqchip/irq-loongson-eiointc.c @@ -144,12 +144,14 @@ 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 eio intc and more than four cpus + * irq from eio can only be routed to cpu 0-3 on virt machine + */ + if (index < 0) + return 0; if ((cpu_logical_map(cpu) % CORES_PER_EIO_NODE) == 0) { eiointc_enable(); -- 2.27.0