From patchwork Thu Mar 2 03:02:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaoqin Huang X-Patchwork-Id: 13156663 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98569C7EE23 for ; Thu, 2 Mar 2023 03:03:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229775AbjCBDDj (ORCPT ); Wed, 1 Mar 2023 22:03:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229706AbjCBDDh (ORCPT ); Wed, 1 Mar 2023 22:03:37 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AA6E55040 for ; Wed, 1 Mar 2023 19:02:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677726169; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hAGv1iCZBmtezd5cdZX633/N33Ksxy9PkYDSRbpiY7k=; b=UIl78oGMZaiJLZbVzYZsP1VMcmYM1YboP2oFR9KXn/Qftz37B66wXdyKe/ZBvSw9wzJIrY M5BpKVm4kzoDxzSAC5x1ghSrjOjFj4/u4/+iUFi4Oc6DMEdAGgEgpLOC9tzJMh687oUbP7 jwIbqIyelwhTJom10u/QKERZhzXtudY= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-119-ynCklZYaMTejg9pK7Ip8hA-1; Wed, 01 Mar 2023 22:02:46 -0500 X-MC-Unique: ynCklZYaMTejg9pK7Ip8hA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 13CE13C02529; Thu, 2 Mar 2023 03:02:46 +0000 (UTC) Received: from virt-mtcollins-01.lab.eng.rdu2.redhat.com (virt-mtcollins-01.lab.eng.rdu2.redhat.com [10.8.1.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id 07C182026D4B; Thu, 2 Mar 2023 03:02:46 +0000 (UTC) From: Shaoqin Huang To: kvmarm@lists.linux.dev Cc: Shaoqin Huang , Andrew Jones , Eric Auger , kvm@vger.kernel.org (open list:ARM) Subject: [RESEND kvm-unit-tests 1/3] arm: gic: Write one bit per time in gic_irq_set_clr_enable() Date: Wed, 1 Mar 2023 22:02:35 -0500 Message-Id: <20230302030238.158796-2-shahuang@redhat.com> In-Reply-To: <20230302030238.158796-1-shahuang@redhat.com> References: <20230302030238.158796-1-shahuang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org When use gic_irq_set_clr_enable() to disable an interrupt, it will disable all interrupt since it first read from Interrupt Clear-Enable Registers and then write this value with a mask back. So diretly write one bit per time to enable or disable interrupt. Fixes: cb573c2 ("arm: gic: Introduce gic_irq_set_clr_enable() helper") Signed-off-by: Shaoqin Huang Reviewed-by: Eric Auger --- lib/arm/gic.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/arm/gic.c b/lib/arm/gic.c index 1bfcfcf..89a15fe 100644 --- a/lib/arm/gic.c +++ b/lib/arm/gic.c @@ -176,7 +176,6 @@ void gic_ipi_send_mask(int irq, const cpumask_t *dest) void gic_irq_set_clr_enable(int irq, bool enable) { u32 offset, split = 32, shift = (irq % 32); - u32 reg, mask = BIT(shift); void *base; assert(irq < 1020); @@ -199,8 +198,7 @@ void gic_irq_set_clr_enable(int irq, bool enable) assert(0); } base += offset + (irq / split) * 4; - reg = readl(base); - writel(reg | mask, base); + writel(BIT(shift), base); } enum gic_irq_state gic_irq_state(int irq) From patchwork Thu Mar 2 03:02:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaoqin Huang X-Patchwork-Id: 13156664 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E026C7EE2F for ; Thu, 2 Mar 2023 03:03:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229820AbjCBDDk (ORCPT ); Wed, 1 Mar 2023 22:03:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229728AbjCBDDh (ORCPT ); Wed, 1 Mar 2023 22:03:37 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 731FD532BD for ; Wed, 1 Mar 2023 19:02:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677726169; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BjH0nnzPusbWF/jE0RgG4N51G4iTWbmo5gcYjsYR43I=; b=BZUhVx4c2BoC2Mu99Sh66qxPmvvDHew6SJ+dW4ouTrBXfDCthxILDU1f3ILC31XUAZ98r7 wX6dXiPDYx72Z9rdPul8t4+qd9KCepTlfXvtrTXO6KPMFtBqgG3uEOKtJzVU8Ndez/wbUV Un8p3Yw19kAUG2G3Em74B79gr+/C+7g= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-518-Ma9pgQ9-PISgsADUOzW3OQ-1; Wed, 01 Mar 2023 22:02:46 -0500 X-MC-Unique: Ma9pgQ9-PISgsADUOzW3OQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2A69429ABA14; Thu, 2 Mar 2023 03:02:46 +0000 (UTC) Received: from virt-mtcollins-01.lab.eng.rdu2.redhat.com (virt-mtcollins-01.lab.eng.rdu2.redhat.com [10.8.1.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2471D2026D4B; Thu, 2 Mar 2023 03:02:46 +0000 (UTC) From: Shaoqin Huang To: kvmarm@lists.linux.dev Cc: Shaoqin Huang , Andrew Jones , kvm@vger.kernel.org (open list:ARM) Subject: [RESEND kvm-unit-tests 2/3] arm64: timer: Use gic_enable/disable_irq() macro in timer test Date: Wed, 1 Mar 2023 22:02:36 -0500 Message-Id: <20230302030238.158796-3-shahuang@redhat.com> In-Reply-To: <20230302030238.158796-1-shahuang@redhat.com> References: <20230302030238.158796-1-shahuang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Use gic_enable/disable_irq() to clean up the code. Signed-off-by: Shaoqin Huang Reviewed-by: Eric Auger --- arm/timer.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/arm/timer.c b/arm/timer.c index c4e7b10..c0a8388 100644 --- a/arm/timer.c +++ b/arm/timer.c @@ -14,9 +14,6 @@ #include #include -static void *gic_isenabler; -static void *gic_icenabler; - static bool ptimer_unsupported; static void ptimer_unsupported_handler(struct pt_regs *regs, unsigned int esr) @@ -139,12 +136,12 @@ static struct timer_info ptimer_info = { static void set_timer_irq_enabled(struct timer_info *info, bool enabled) { - u32 val = 1 << PPI(info->irq); + u32 irq = PPI(info->irq); if (enabled) - writel(val, gic_isenabler); + gic_enable_irq(irq); else - writel(val, gic_icenabler); + gic_disable_irq(irq); } static void irq_handler(struct pt_regs *regs) @@ -366,17 +363,6 @@ static void test_init(void) gic_enable_defaults(); - switch (gic_version()) { - case 2: - gic_isenabler = gicv2_dist_base() + GICD_ISENABLER; - gic_icenabler = gicv2_dist_base() + GICD_ICENABLER; - break; - case 3: - gic_isenabler = gicv3_sgi_base() + GICR_ISENABLER0; - gic_icenabler = gicv3_sgi_base() + GICR_ICENABLER0; - break; - } - install_irq_handler(EL1H_IRQ, irq_handler); set_timer_irq_enabled(&ptimer_info, true); set_timer_irq_enabled(&vtimer_info, true); From patchwork Thu Mar 2 03:02:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaoqin Huang X-Patchwork-Id: 13156662 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DE57C678D4 for ; Thu, 2 Mar 2023 03:03:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229769AbjCBDDj (ORCPT ); Wed, 1 Mar 2023 22:03:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229712AbjCBDDh (ORCPT ); Wed, 1 Mar 2023 22:03:37 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F04C55061 for ; Wed, 1 Mar 2023 19:02:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677726169; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=niJ4CwDrV8hObCKV5F3GjJwG9H2mwT9UYhhF5sffOCQ=; b=KldTCHHugjB4u5EI0pWhajiTTWS6makKO4J+UL0+LVz21r//tnS+GoKbmBx1e/3AIFYsdh kfN+S26cimN/LZt9UTF1zDwyTiX/m7++5+P1oK9Z19Fo18UOHDTrD8IQFz/Hhw9EspSBSW OKHsWyfqPgftfzV8ndeJJsSAALnUHCM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-590-JDug1fVlPjexpXL47mN3VA-1; Wed, 01 Mar 2023 22:02:46 -0500 X-MC-Unique: JDug1fVlPjexpXL47mN3VA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3FB2A85A5B1; Thu, 2 Mar 2023 03:02:46 +0000 (UTC) Received: from virt-mtcollins-01.lab.eng.rdu2.redhat.com (virt-mtcollins-01.lab.eng.rdu2.redhat.com [10.8.1.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id 39AE42026D4B; Thu, 2 Mar 2023 03:02:46 +0000 (UTC) From: Shaoqin Huang To: kvmarm@lists.linux.dev Cc: Shaoqin Huang , Andrew Jones , kvm@vger.kernel.org (open list:ARM) Subject: [RESEND kvm-unit-tests 3/3] arm64: microbench: Use gic_enable_irq() macro in microbench test Date: Wed, 1 Mar 2023 22:02:37 -0500 Message-Id: <20230302030238.158796-4-shahuang@redhat.com> In-Reply-To: <20230302030238.158796-1-shahuang@redhat.com> References: <20230302030238.158796-1-shahuang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Use gic_enable_irq() to clean up code. Signed-off-by: Shaoqin Huang Reviewed-by: Eric Auger --- arm/micro-bench.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/arm/micro-bench.c b/arm/micro-bench.c index 8436612..090fda6 100644 --- a/arm/micro-bench.c +++ b/arm/micro-bench.c @@ -212,24 +212,11 @@ static void lpi_exec(void) static bool timer_prep(void) { - void *gic_isenabler; - gic_enable_defaults(); install_irq_handler(EL1H_IRQ, gic_irq_handler); local_irq_enable(); - switch (gic_version()) { - case 2: - gic_isenabler = gicv2_dist_base() + GICD_ISENABLER; - break; - case 3: - gic_isenabler = gicv3_sgi_base() + GICR_ISENABLER0; - break; - default: - assert_msg(0, "Unreachable"); - } - - writel(1 << PPI(TIMER_VTIMER_IRQ), gic_isenabler); + gic_enable_irq(PPI(TIMER_VTIMER_IRQ)); write_sysreg(ARCH_TIMER_CTL_IMASK | ARCH_TIMER_CTL_ENABLE, cntv_ctl_el0); isb();