Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp3983058pxy; Tue, 4 May 2021 14:47:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlJjBfKrt6UkcLtqXjZ3JmsGm1IlkiXAnjK4UfABb03HuwgVTsf2SOH+ZeaanHlXLMU2Lw X-Received: by 2002:a17:906:1e49:: with SMTP id i9mr23956788ejj.536.1620164847885; Tue, 04 May 2021 14:47:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620164847; cv=none; d=google.com; s=arc-20160816; b=Ge0/89exNC6Lrao04qAMe1nP0wf1KyNqzxk0rR3hJarR0kIt8C2sPpvwftnq3d8nXB lWQm/kg0TSI0ZvC6g79pVmrjJSOrRl2KFpOu5TBX9lNM4hdwOus9lkAgueGsaXHy80Yh U+YUAXti+Z4S4tGe1L5y2w8NzQDOwIt2EhD9iKSzJJBXIIWUZfguCw1pQkehpo0DmfCv wtAjIJ33r5HFt+0mHSFVlz/08O8yA4kMG8uqi2QTLgM5mduV2yO2p3okT4/EnveGxlrl PeQm2sa1v2sxSP8oPH6P7krOchplnzpuMK/XpKbz7vopf2QmXKAWi6t7O9l43JOBH6nd 7hXQ== 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:ironport-sdr:ironport-sdr; bh=/wWqjpsxD2PI8VksjV6tqayCzsx4ypon/7++T90ZxZ8=; b=UpE4zlsz0B+P9wrrLUjjpaaezh4CtmU/gGXvzG5KCKHg/SLtK4zZLgTr9p4yxPuDom DJjDFgD7HpIY3XCY7CzlYj5SDD6Ud8WakivsL41gQXi8Sa8w0t3dCzNNvIHpB9LTs+uT Gup4R142LedKZotOohTEuPuljpWh2+diNYBYSJf+Gop5Rs1ubIMsIB4nIdYDpYYsDUe8 KjFEqePmLUGBP+yAmo4woFFo4nBpFNciqeM9Uchw3rvbAhNebChSa0U+PH1Ql+qiGsgm DYapZm2KYl0udbKOfVdA9Hof/ioPcWvv5QGfm7w6cPEdRO1VVAQMtCKrPFev8l7d8oMW JUTA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jj1si3523154ejc.236.2021.05.04.14.47.04; Tue, 04 May 2021 14:47:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232244AbhEDTMj (ORCPT + 99 others); Tue, 4 May 2021 15:12:39 -0400 Received: from mga03.intel.com ([134.134.136.65]:9835 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231849AbhEDTMg (ORCPT ); Tue, 4 May 2021 15:12:36 -0400 IronPort-SDR: 5SLc0gNAvmQoupwjaAw7blTg4QL5XMAxZQnkQ6jF/9oPtPM2VcvGEJa5QKTuCRX0NP6K+SPGgj 3Bu1IhQJMlhQ== X-IronPort-AV: E=McAfee;i="6200,9189,9974"; a="198115952" X-IronPort-AV: E=Sophos;i="5.82,272,1613462400"; d="scan'208";a="198115952" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 May 2021 12:11:40 -0700 IronPort-SDR: QRMhQ60IP6XEM0FH9wzLjak7I1PeorEfIptzOegX1syGKho/lGCLE079Kjyrq5+yQl75p6zrQl 5WEtluDgxtTA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,272,1613462400"; d="scan'208";a="396245278" Received: from ranerica-svr.sc.intel.com ([172.25.110.23]) by fmsmga007.fm.intel.com with ESMTP; 04 May 2021 12:11:40 -0700 From: Ricardo Neri To: Joerg Roedel , Will Deacon Cc: woodhouse@vger.kernel.org, Jacob Pan , Lu Baolu , Stephane Eranian , Thomas Gleixner , Ingo Molnar , Borislav Petkov , iommu@lists.linux-foundation.org, x86@kernel.org, linux-kernel@vger.kernel.org, "Ravi V. Shankar" , Ricardo Neri , Ricardo Neri , Andi Kleen , David Woodhouse , "x86 @ kernel . orgReviewed-by : Ashok Raj" Subject: [RFC PATCH v5 1/7] x86/apic: Add irq_cfg::delivery_mode Date: Tue, 4 May 2021 12:10:43 -0700 Message-Id: <20210504191049.22661-2-ricardo.neri-calderon@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210504191049.22661-1-ricardo.neri-calderon@linux.intel.com> References: <20210504191049.22661-1-ricardo.neri-calderon@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Until now, the delivery mode of APIC interrupts is set to the default mode set in the APIC driver. However, there are no restrictions in hardware to configure each interrupt with a different delivery mode. Specifying the delivery mode per interrupt is useful when one is interested in changing the delivery mode of a particular interrupt. For instance, this can be used to deliver an interrupt as non-maskable. Add a new member, delivery_mode, to struct irq_cfg. This new member can be used to update the configuration of the delivery mode in each interrupt domain. Currently, all interrupt domains set the delivery mode of interrupts using the APIC setting. Interrupt domains use an irq_cfg data structure to configure their own data structures and hardware resources. Thus, in order to keep the current behavior, set the delivery mode of the irq configuration that as the APIC setting. In this manner, irq domains can obtain the delivery mode from the irq configuration data instead of the APIC setting, if needed. Cc: Andi Kleen Cc: Borislav Petkov Cc: David Woodhouse (supporter:INTEL IOMMU (VT-d)) Cc: "Ravi V. Shankar" Cc: Ingo Molnar Cc: Jacob Pan Cc: Lu Baolu (supporter:INTEL IOMMU (VT-d)) Cc: Stephane Eranian Cc: Thomas Gleixner Cc: iommu@lists.linux-foundation.org (open list:INTEL IOMMU (VT-d)) Cc: x86@kernel.orgReviewed-by: Ashok Raj Signed-off-by: Ricardo Neri --- 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 | 1 + arch/x86/kernel/apic/vector.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h index d465ece58151..370f4db0372b 100644 --- a/arch/x86/include/asm/hw_irq.h +++ b/arch/x86/include/asm/hw_irq.h @@ -90,6 +90,7 @@ struct irq_alloc_info { struct irq_cfg { 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 6dbdc7c22bb7..d47ed07a56a4 100644 --- a/arch/x86/kernel/apic/vector.c +++ b/arch/x86/kernel/apic/vector.c @@ -567,6 +567,16 @@ 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); + + /* + * Initialize the delivery mode of this irq to match the + * default delivery mode of the APIC. This is useful for + * children irq domains which want to take the delivery + * mode from the individual irq configuration rather + * than from the APIC. + */ + apicd->hw_irq_cfg.delivery_mode = apic->delivery_mode; + /* * Prevent that any of these interrupts is invoked in * non interrupt context via e.g. generic_handle_irq() -- 2.17.1