Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1197555ybl; Tue, 13 Aug 2019 08:50:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqwxA1uYD/9qSqijqkEK/0klQIQUee59UBun5d/L9TLFXNUquhWxFbgQBhXMBmU8piIX0PUv X-Received: by 2002:a17:90a:e397:: with SMTP id b23mr2836719pjz.117.1565711423520; Tue, 13 Aug 2019 08:50:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565711423; cv=none; d=google.com; s=arc-20160816; b=i8IaVOkLcsbgZ3tOotTCnxTfgbI07Cxi8thNfSEYhjMUUdkFnH951MDnicvumqhZQ7 Uhx6BrMOR9T8qSM1noxsQcGef3hia8IbkwZCK12HCAyw0kPmFkhETdn9T56PH8s8175o u/8U1dDPyaA7u8M3Sd+Z4lJOe/McE1wNgEhlqnPiCCu59bXahpiKr9QMI5NiO5Ksp9J1 FN99DatFlGoi2tN9k/5ITRaJh4W8kgC+0XQ4y/SsSvq/wzRqYsqAsr2fSPBBna+GeRcW hbvc9t/wkaU926G/ZMAbdK6e6MD4VPEUNJ85yoCrZg7Z8hraoBNZKZIz2tnkpwlZC5+I 9/dQ== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5WJArPRhLKawZExF1a/OJKFWf27gCJZIRATflv1f+LA=; b=v9oE3sRY0dGQG+52vkRki4OOV/WmkgMwu5NLuHiT6bPEEaaoYhKOFwqdwvzHqehmcM CnafsibakSDGtQQUtsP0iFKcxesHV5dnovtsoUegDPg6cDO+y8qsadGSFrHlW3oO/LPJ t1eVBlnnaJr2mseWfhDMqdQ11SgVObt8DVMHeX11ZDeXVnr9IuF7ll7d6K5HsWY9Ygun 0ej7ZkSwRyDoWI9X790iwHo2XB1nxrVbfOiKxeDK3SHkX9XyuoBzymtX3H8pHU7N05N6 JqjeDX/zSLf+Y3vSH+Ow9LeCTQZ9dE8Bs4ABPTdQtuskg5I8nSm7jfdqsvoWuX/bRTmV kOew== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=RzP4Th7b; 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 r200si61342316pgr.518.2019.08.13.08.50.07; Tue, 13 Aug 2019 08:50:23 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=RzP4Th7b; 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 S1730154AbfHMPsB (ORCPT + 99 others); Tue, 13 Aug 2019 11:48:01 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:43566 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727452AbfHMPr7 (ORCPT ); Tue, 13 Aug 2019 11:47:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=5WJArPRhLKawZExF1a/OJKFWf27gCJZIRATflv1f+LA=; b=RzP4Th7bqODmJzNVsK8TV1ptQF R26dnbQ3MCGl4xdzMlU3Y/uSZYPpHlBZKa2isB3TLZf5r6P2aNSgMsXMElEOVciZABYjcBBrEcHDM MvrJrx3pEOysJ9ONEFvsWf5LYZVhqHmcWOLC6RFRWKJ/x8y2iGD+bW5ILhF2R7yiKrwxSIamwLVf7 sPqRSWAiHIGiKowC3l4gmzal5J1H4fhrakuY/DzjAVT1IVamSn+Yhy3FPQ/VunpE+RANiT8OoVIbS XMW1qj0+yC+pkt/2LSUIVns+S38Jy3Z3a33dg++8/Kuhn/D1Hqk7VKnf84cTM5b/EMF/QLzlrTKYW 3NqtagCg==; Received: from [2001:4bb8:180:1ec3:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hxZ1h-0004ma-Cp; Tue, 13 Aug 2019 15:47:57 +0000 From: Christoph Hellwig To: Palmer Dabbelt , Paul Walmsley Cc: Damien Le Moal , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/15] riscv: refactor the IPI code Date: Tue, 13 Aug 2019 17:47:35 +0200 Message-Id: <20190813154747.24256-4-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190813154747.24256-1-hch@lst.de> References: <20190813154747.24256-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This prepare for adding native non-SBI IPI code. Signed-off-by: Christoph Hellwig --- arch/riscv/kernel/smp.c | 55 +++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c index 5a9834503a2f..8cd730239613 100644 --- a/arch/riscv/kernel/smp.c +++ b/arch/riscv/kernel/smp.c @@ -78,13 +78,38 @@ static void ipi_stop(void) wait_for_interrupt(); } +static void send_ipi_mask(const struct cpumask *mask, enum ipi_message_type op) +{ + int cpuid, hartid; + struct cpumask hartid_mask; + + cpumask_clear(&hartid_mask); + mb(); + for_each_cpu(cpuid, mask) { + set_bit(op, &ipi_data[cpuid].bits); + hartid = cpuid_to_hartid_map(cpuid); + cpumask_set_cpu(hartid, &hartid_mask); + } + mb(); + sbi_send_ipi(cpumask_bits(&hartid_mask)); +} + +static void send_ipi_single(int cpu, enum ipi_message_type op) +{ + send_ipi_mask(cpumask_of(cpu), op); +} + +static inline void clear_ipi(void) +{ + csr_clear(CSR_SIP, SIE_SSIE); +} + void riscv_software_interrupt(void) { unsigned long *pending_ipis = &ipi_data[smp_processor_id()].bits; unsigned long *stats = ipi_data[smp_processor_id()].stats; - /* Clear pending IPI */ - csr_clear(CSR_SIP, SIE_SSIE); + clear_ipi(); while (true) { unsigned long ops; @@ -118,23 +143,6 @@ void riscv_software_interrupt(void) } } -static void -send_ipi_message(const struct cpumask *to_whom, enum ipi_message_type operation) -{ - int cpuid, hartid; - struct cpumask hartid_mask; - - cpumask_clear(&hartid_mask); - mb(); - for_each_cpu(cpuid, to_whom) { - set_bit(operation, &ipi_data[cpuid].bits); - hartid = cpuid_to_hartid_map(cpuid); - cpumask_set_cpu(hartid, &hartid_mask); - } - mb(); - sbi_send_ipi(cpumask_bits(&hartid_mask)); -} - static const char * const ipi_names[] = { [IPI_RESCHEDULE] = "Rescheduling interrupts", [IPI_CALL_FUNC] = "Function call interrupts", @@ -156,12 +164,12 @@ void show_ipi_stats(struct seq_file *p, int prec) void arch_send_call_function_ipi_mask(struct cpumask *mask) { - send_ipi_message(mask, IPI_CALL_FUNC); + send_ipi_mask(mask, IPI_CALL_FUNC); } void arch_send_call_function_single_ipi(int cpu) { - send_ipi_message(cpumask_of(cpu), IPI_CALL_FUNC); + send_ipi_single(cpu, IPI_CALL_FUNC); } void smp_send_stop(void) @@ -176,7 +184,7 @@ void smp_send_stop(void) if (system_state <= SYSTEM_RUNNING) pr_crit("SMP: stopping secondary CPUs\n"); - send_ipi_message(&mask, IPI_CPU_STOP); + send_ipi_mask(&mask, IPI_CPU_STOP); } /* Wait up to one second for other CPUs to stop */ @@ -191,6 +199,5 @@ void smp_send_stop(void) void smp_send_reschedule(int cpu) { - send_ipi_message(cpumask_of(cpu), IPI_RESCHEDULE); + send_ipi_single(cpu, IPI_RESCHEDULE); } - -- 2.20.1