Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2027625ybd; Sun, 23 Jun 2019 22:46:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxmyjo+FmiAVBvShSiiLqcvhX+dVEBxYU/k5wwBDItD3DPioEbVQhqzE8615m8kzioOQVBS X-Received: by 2002:a17:902:5a4c:: with SMTP id f12mr66616946plm.332.1561355218081; Sun, 23 Jun 2019 22:46:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561355218; cv=none; d=google.com; s=arc-20160816; b=oJjfZBiomtxmtLOMOLKwuSpbKD+D4T/d18Z9BjMWtlSMuF5B0cBw5wK/cqskIX3nZQ YFLh+lDED9w3mMT4XCN4ECOFeQcvaZ2ndURtV1u805axF8pq7JGOiDCekNUrCwf2ua42 j8riS61PXVCGXyzaOCTyfclVv7pGwHXBX82ztece/aIlc1jpgpUax//AHzTq/OS4MBzD sXNVSygrsDcL4qBGJ1Z35uCv3x3gw6iCuORnvNZ7ZGwYrNOoYbj1GGFeH1H0z1BvorFm OvNXC3YE/BbKKfTnrWc9akjKxpi3Rimdh75WEbDuSLO4GrlIboopmcLtKlv4px7oDnr0 C56w== 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=NLlXiCNE17yQ2/3daiESVHrCTUjjozXBblFL7tsrKIUEiyhfpQwzTrlB2rWBgn+CvH 26lPppSgS3qWJJE6I2g44tY2OnGXieRqVBofvvfjpnuNLPC94WjyLZ98xUdJ+ulNSrWn y2lmQhUeiNF4Ke4QQ4wV11EGBkmBLFwUrQcmvy5WQ1TG6ZPq1HoLWdYoeFoN+qzhcx4p K5YeErt3sROGNou4dVMHxCDOMSqi8Ju6rhmVSyXuFlh0fnt6eLDBQV5uI4uY81zDIo5B ZZ2ySDh6MvoaLkO0JEv0LyCRPuoY4EF1OnX7LKAxxC7mpjsbAZj3xM9uGrM/2GwkCQwh CKcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=YNs3gx+c; 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 v24si9100838ply.101.2019.06.23.22.46.42; Sun, 23 Jun 2019 22:46:58 -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=YNs3gx+c; 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 S1727352AbfFXFno (ORCPT + 99 others); Mon, 24 Jun 2019 01:43:44 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:35904 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726223AbfFXFni (ORCPT ); Mon, 24 Jun 2019 01:43:38 -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=YNs3gx+cZZv1ocI36RZcvQyY9T QTQAtNYVUae846VvayO26Eo+iWXkBfk4QXQM6mmZ5W6Zx0yJsWF18x+cP04E4Yy/Qu+9KKD8R4nRm HUfGGHLa7joE4G/VLRECg18AwszpPm3Dm/vU5chIb9rtFkH8A/EDQCh6t/mX19oO6tHcN1wx9YlGf J9IRgkwvTb8sJ4unejzwORv8IR/ev5ze7WeDv/2sC7ro8hXmHsJjeh4WUn9fJNDBEKBqyzxGctyDo nOQDQkr2twVVOQPP4YTh47PUmzt9r88vq5a82lkOHFOHV54/hbA3uXyXBxpCBr+tJrhKc77DWOAZG ZY9VAwnA==; Received: from 213-225-6-159.nat.highway.a1.net ([213.225.6.159] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hfHlP-0006JM-V8; Mon, 24 Jun 2019 05:43:36 +0000 From: Christoph Hellwig To: Palmer Dabbelt , Paul Walmsley Cc: Damien Le Moal , linux-riscv@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/17] riscv: refactor the IPI code Date: Mon, 24 Jun 2019 07:43:00 +0200 Message-Id: <20190624054311.30256-7-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190624054311.30256-1-hch@lst.de> References: <20190624054311.30256-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