Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4669477iob; Sun, 8 May 2022 21:19:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsWRrSaoZjifPQIYKTVu9FXf3cba3ZLI8DosQ8CslKVdBye1zhenF2bTIVVE9qEoPrtmWo X-Received: by 2002:a17:90a:db95:b0:1d9:782f:a4c8 with SMTP id h21-20020a17090adb9500b001d9782fa4c8mr24002841pjv.154.1652069987274; Sun, 08 May 2022 21:19:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652069987; cv=none; d=google.com; s=arc-20160816; b=02cB6XXYVR6diLHC/T+w4ZeH5XqWWNdmEmhveGBaIV5NNrOkXTVzWNeuX79BHWAUhb MudM4levE65bffeT2Q4aGPE9V1/oOEeVPpE8rDuWVGYweMK0Fz3ZyGMuNuM7Z8P6uBzR WWHwvwwLZcQWyXSPCseR7uisi/2V8KChG6CVX56iZZBD5FMN94vhCg/6n5lAWFmF5x+L o1Off48gf1ZfHDyXdzZtthi+axTtEuKf0cLdoyjGapB4zf324v5xZSHg+ltrYqwRTUVC gH+c9iIdv7sBK5fdrK3kXubEMXye+gtDdcRCi8IYsCAQKi7oVV6ZbqB7ZJwYamM7vAzo pr0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=UU7O/1+BR59f8BODmLe7RyvioFhw5bYMWFiyW9cy5dc=; b=WvmgycNUnW2yCzOGWw8vagzkkkf2+LseAZE9ZOjvflg91YMZE3df1OXkZXSIFmceYE svDSPndOw80ZvKAraNaNneI7qakdZz1gFurr0gP1PwZWoWXyY7qrXsTabdpJ++hpc87u VJsAbIFbVtiJ6Ix5p9JR9puUf/m+LS2eUNnKjBW4XGKW2UcxXtZjd0iQ7mbfTWG0rAxb 6+XQeAjOOBnonIUKav+ee5nP2zlLd03Cb/xqSCpuxCCiaJttEP0VuCmI2gfg1su0ykFL AADNn7XbTn6eayjzaHYZD1anzSKEZUEoLNg6Q7jDPoevVXBNYW1TxtN4B8CsVFD9PEio 9VTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EMQWTlsJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e17-20020aa798d1000000b0050a3e40daffsi10964874pfm.156.2022.05.08.21.19.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 21:19:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EMQWTlsJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0400E119227; Sun, 8 May 2022 21:17:31 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387081AbiEFABh (ORCPT + 99 others); Thu, 5 May 2022 20:01:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1387042AbiEFAB1 (ORCPT ); Thu, 5 May 2022 20:01:27 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AD3C60DAA for ; Thu, 5 May 2022 16:57:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651795066; x=1683331066; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=zlyJMMAdck3m7Lj6IAc06Z99mVZqGJ1kJoeEJPS6nAw=; b=EMQWTlsJIFEbbzkVX/qDkiVTjIupuSyobroCQk2Chn46yZXbG1L5B5ih J5o6Hn8/dKD/2lTg0UQ6YR+UNYgBmY04x/sVc7ovwDbazPi9tOTrpn/vW b5zF4NjgxR/4U/2Ax3qtqyJq3ENzFdETdbw7u7AvT+MSCfJOK5ic60X/r awXYLbbzdO8vJSXPzOIsC5YkRblhBrXMj+4q7zdppescKjvTe4STHI92j OjtR/3ECqpNHRSHw6Q6upqU4/E6QYzgLCRhQdwRW3J3vs3xCFC+91sTdT 9xytodTz9CUu6CfgNJylVmGAJTOlOqI8hpkAp27eMuyFUQhywS8e+8vlZ A==; X-IronPort-AV: E=McAfee;i="6400,9594,10338"; a="250283612" X-IronPort-AV: E=Sophos;i="5.91,203,1647327600"; d="scan'208";a="250283612" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2022 16:57:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,203,1647327600"; d="scan'208";a="694914325" Received: from ranerica-svr.sc.intel.com ([172.25.110.23]) by orsmga004.jf.intel.com with ESMTP; 05 May 2022 16:57:44 -0700 From: Ricardo Neri To: Thomas Gleixner , x86@kernel.org Cc: Tony Luck , Andi Kleen , Stephane Eranian , Andrew Morton , Joerg Roedel , Suravee Suthikulpanit , David Woodhouse , Lu Baolu , Nicholas Piggin , "Ravi V. Shankar" , Ricardo Neri , iommu@lists.linux-foundation.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Ricardo Neri Subject: [PATCH v6 02/29] x86/apic: Add irq_cfg::delivery_mode Date: Thu, 5 May 2022 16:59:41 -0700 Message-Id: <20220506000008.30892-3-ricardo.neri-calderon@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220506000008.30892-1-ricardo.neri-calderon@linux.intel.com> References: <20220506000008.30892-1-ricardo.neri-calderon@linux.intel.com> X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Currently, the delivery mode of all interrupts is set to the mode of the APIC driver in use. There are no restrictions in hardware to configure the delivery mode of each interrupt individually. Also, certain IRQs need to be configured with a specific delivery mode (e.g., NMI). Add a new member, delivery_mode, to struct irq_cfg. Subsequent changesets will update every irq_domain to set the delivery mode of each IRQ to that specified in its irq_cfg data. To keep the current behavior, when allocating an IRQ in the root domain (i.e., the x86_vector_domain), set the delivery mode of the IRQ as that of the APIC driver. Cc: Andi Kleen Cc: "Ravi V. Shankar" Cc: Stephane Eranian Cc: iommu@lists.linux-foundation.org Cc: linuxppc-dev@lists.ozlabs.org Cc: x86@kernel.org Reviewed-by: Ashok Raj Reviewed-by: Tony Luck Signed-off-by: Ricardo Neri --- Changes since v5: * Updated indentation of the existing members of struct irq_cfg. * Reworded the commit message. Changes since v4: * Rebased to use new enumeration apic_delivery_modes. Changes since v3: * None Changes since v2: * Reduced scope to only add the interrupt delivery mode in struct irq_alloc_info. Changes since v1: * Introduced this patch. --- arch/x86/include/asm/hw_irq.h | 5 +++-- arch/x86/kernel/apic/vector.c | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h index d465ece58151..5ac5e6c603ee 100644 --- a/arch/x86/include/asm/hw_irq.h +++ b/arch/x86/include/asm/hw_irq.h @@ -88,8 +88,9 @@ struct irq_alloc_info { }; struct irq_cfg { - unsigned int dest_apicid; - unsigned int vector; + unsigned int dest_apicid; + unsigned int vector; + enum apic_delivery_modes delivery_mode; }; extern struct irq_cfg *irq_cfg(unsigned int irq); diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c index 3e6f6b448f6a..838e220e8860 100644 --- a/arch/x86/kernel/apic/vector.c +++ b/arch/x86/kernel/apic/vector.c @@ -567,6 +567,7 @@ static int x86_vector_alloc_irqs(struct irq_domain *domain, unsigned int virq, irqd->chip_data = apicd; irqd->hwirq = virq + i; irqd_set_single_target(irqd); + /* * Prevent that any of these interrupts is invoked in * non interrupt context via e.g. generic_handle_irq() @@ -577,6 +578,14 @@ static int x86_vector_alloc_irqs(struct irq_domain *domain, unsigned int virq, /* Don't invoke affinity setter on deactivated interrupts */ irqd_set_affinity_on_activate(irqd); + /* + * Initialize the delivery mode of this irq to match the + * default delivery mode of the APIC. Children irq domains + * may take the delivery mode from the individual irq + * configuration rather than from the APIC driver. + */ + apicd->hw_irq_cfg.delivery_mode = apic->delivery_mode; + /* * Legacy vectors are already assigned when the IOAPIC * takes them over. They stay on the same vector. This is -- 2.17.1