From patchwork Thu Jun 8 15:20:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noam Camus X-Patchwork-Id: 773334 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wk8K62Py7z9s7f for ; Fri, 9 Jun 2017 01:21:30 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="N+SzTRZy"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=0jN6dKFg0LH0CXznW+j7C/crkViHwEHAgu9oIFY5Dy0=; b=N+SzTRZyiLXq+5ZfqnEt9g7X1R VOhmdpHoJUVu9FjaSV/8jcjVdUkSAUsXNnBXGHcgFjyM1ekQ+OzrpO9b3verWnS+4Uc9R9J3RrUNQ nOYF5SfXNK9q8SJwNg7O2AukNbkDcgnwAZ06SwwMjIv9VU5HnCW5e/+k3OuZAna2UbM5jWM4ZLDAK FjUHVkCyGyKwd7gxHMhVbuYvJYt2/tE2cU0SBqXgbpkvVhA+csJ2Em9yvfYQ35L817iDUzo/q6tKv QOueK0h73o8KshDwPQfBtFyLGW4w9yI0qyToCfNy1so3UZjq7RSOZxb0Z3q+ZpIQKA+MIxKy/UAxj 34reyNQQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dIzFY-0006rC-Vi; Thu, 08 Jun 2017 15:21:29 +0000 Received: from mail-il-dmz.mellanox.com ([193.47.165.129] helo=mellanox.co.il) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dIzFP-0006gp-AW for linux-snps-arc@lists.infradead.org; Thu, 08 Jun 2017 15:21:27 +0000 Received: from Internal Mail-Server by MTLPINE1 (envelope-from noamca@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Jun 2017 18:20:53 +0300 Received: from nps20.mtl.labs.mlnx. (l-nps20.mtl.labs.mlnx [10.7.191.20]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v58FKrai020738; Thu, 8 Jun 2017 18:20:53 +0300 From: Noam Camus To: linux-snps-arc@lists.infradead.org Subject: [PATCH 09/11] ARC: [plat-eznps] Save/Restore extra auxiliary registers Date: Thu, 8 Jun 2017 18:20:33 +0300 Message-Id: <1496935235-46507-10-git-send-email-noamca@mellanox.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1496935235-46507-1-git-send-email-noamca@mellanox.com> References: <1496935235-46507-1-git-send-email-noamca@mellanox.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170608_082119_850125_EE4C6B01 X-CRM114-Status: GOOD ( 14.39 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Noam Camus , linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Noam Camus thread_struct got new field for data plane of eznps platform. This field got place for data plane auxiliary registers and for any extra registers that might be changed in kernel code. We save EFLAGS, and GPA1 auxiliary registers since they may be changed by the new task while using atomic operations e.g. cmpxchg. Signed-off-by: Noam Camus --- arch/arc/include/asm/arcregs.h | 7 +++++++ arch/arc/include/asm/processor.h | 3 +++ arch/arc/include/asm/switch_to.h | 11 +++++++++++ arch/arc/plat-eznps/Makefile | 2 +- arch/arc/plat-eznps/ctop.c | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 55 insertions(+), 1 deletions(-) create mode 100644 arch/arc/plat-eznps/ctop.c diff --git a/arch/arc/include/asm/arcregs.h b/arch/arc/include/asm/arcregs.h index ba8e802..9437d42 100644 --- a/arch/arc/include/asm/arcregs.h +++ b/arch/arc/include/asm/arcregs.h @@ -123,6 +123,13 @@ #define PAGES_TO_MB(n_pages) (PAGES_TO_KB(n_pages) >> 10) +#ifdef CONFIG_ARC_PLAT_EZNPS +struct eznps_dp { + unsigned int eflags; + unsigned int gpa1; +}; +#endif + /* *************************************************************** * Build Configuration Registers, with encoded hardware config diff --git a/arch/arc/include/asm/processor.h b/arch/arc/include/asm/processor.h index fd7bdfa..130bb55 100644 --- a/arch/arc/include/asm/processor.h +++ b/arch/arc/include/asm/processor.h @@ -38,6 +38,9 @@ struct thread_struct { #ifdef CONFIG_ARC_FPU_SAVE_RESTORE struct arc_fpu fpu; #endif +#ifdef CONFIG_ARC_PLAT_EZNPS + struct eznps_dp dp; +#endif }; #define INIT_THREAD { \ diff --git a/arch/arc/include/asm/switch_to.h b/arch/arc/include/asm/switch_to.h index 1b171ab..4c53080 100644 --- a/arch/arc/include/asm/switch_to.h +++ b/arch/arc/include/asm/switch_to.h @@ -26,13 +26,24 @@ #endif /* !CONFIG_ARC_FPU_SAVE_RESTORE */ +#ifdef CONFIG_ARC_PLAT_EZNPS +extern void dp_save_restore(struct task_struct *p, struct task_struct *n); +#define ARC_DP_PREV(p, n) dp_save_restore(p, n) +#define ARC_DP_NEXT(t) +#else +#define ARC_DP_PREV(p, n) +#define ARC_DP_NEXT(n) +#endif /* !CONFIG_ARC_PLAT_EZNPS */ + struct task_struct *__switch_to(struct task_struct *p, struct task_struct *n); #define switch_to(prev, next, last) \ do { \ + ARC_DP_PREV(prev, next); \ ARC_FPU_PREV(prev, next); \ last = __switch_to(prev, next);\ ARC_FPU_NEXT(next); \ + ARC_DP_NEXT(next); \ mb(); \ } while (0) diff --git a/arch/arc/plat-eznps/Makefile b/arch/arc/plat-eznps/Makefile index 21091b1..8d43717 100644 --- a/arch/arc/plat-eznps/Makefile +++ b/arch/arc/plat-eznps/Makefile @@ -2,6 +2,6 @@ # Makefile for the linux kernel. # -obj-y := entry.o platform.o +obj-y := entry.o platform.o ctop.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_EZNPS_MTM_EXT) += mtm.o diff --git a/arch/arc/plat-eznps/ctop.c b/arch/arc/plat-eznps/ctop.c new file mode 100644 index 0000000..8b13a08 --- /dev/null +++ b/arch/arc/plat-eznps/ctop.c @@ -0,0 +1,33 @@ +/* + * Copyright(c) 2015 EZchip Technologies. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * The full GNU General Public License is included in this distribution in + * the file called "COPYING". + */ + +#include +#include +#include + +void dp_save_restore(struct task_struct *prev, struct task_struct *next) +{ + struct eznps_dp *prev_task_dp = &prev->thread.dp; + struct eznps_dp *next_task_dp = &next->thread.dp; + + /* Here we save all Data Plane related auxiliary registers */ + prev_task_dp->eflags = read_aux_reg(CTOP_AUX_EFLAGS); + write_aux_reg(CTOP_AUX_EFLAGS, next_task_dp->eflags); + + prev_task_dp->gpa1 = read_aux_reg(CTOP_AUX_GPA1); + write_aux_reg(CTOP_AUX_GPA1, next_task_dp->gpa1); +} +