Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3977856pxb; Tue, 25 Jan 2022 00:29:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJx9B+S6DH6FSnFlOOOWb9wtBMhuqVsnPxCtZLdmVWst+YW7drinCbtYAas/AVEFAWFKp5Mq X-Received: by 2002:a50:d719:: with SMTP id t25mr19189622edi.282.1643099364384; Tue, 25 Jan 2022 00:29:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643099364; cv=none; d=google.com; s=arc-20160816; b=0VLmwh8oSMNeHuzbDzGGh0Bsr7x/Jl9ELLZgFKsEnSevlvan6bG4JTM5akF0faNeDQ QQzZvkuvEw/QUbfZcB1SyLeMT3C/IsAF9rV8233XgI254ggzsWeJIgZmnhOM7PYN11V6 b9N960fegMxTKwYKUuaVvjafVvEXKc8IWq9XGHbi0u7RZBzoUyJjs8MQ64//nU13x7+m eEOmJmMbhd4gj3ukrMiR1qlxaxCGWnrgZR9zWgC4fWlIqpTcX4tImWm8kf+/tXDNund0 MVZE3fUzs+HK59qryn/vaLmry1seDHOzj2duHVG88MK4Mpnn/zWZh3qhMahNKq7mc6Sc ABMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jVBz8K8gGmgOctNV4ZcAxtHEISnWK2FFLrKqIdQYt9E=; b=PiCfDZ4DVO7BwnVdnCm/ZU31/4gBKbnaSsW9ClyLfWolD5wvprCJsfmFO8DGEyH6+H sh+JeYRL+/r81TQo9yQeOyRS+61HTp7NTzy3WELsNvLcWZgtN15RbZW3dnuy91JtnH+c KIb4CvVdappm1TnzPHOdeAuViINDf07mhbhnqDJQnhWEpI86+ChC0LhonXmCPu1IsnKW 2cANlWCbnRfjyaQ1EYOK8ysxtnZt6EgRPU6r33Gn2ZtiU0/d9lqE3DKfwwi26mXyRYXF FeMmEopFBgRzDZBYuHKSDOEI7eZ/8ao4rlqZN5o5mZSRdIG932Cl0M2kiU/4Z+6tsdaM ffIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dRJua+Hr; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o13si10105212edi.520.2022.01.25.00.28.59; Tue, 25 Jan 2022 00:29:24 -0800 (PST) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dRJua+Hr; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389372AbiAYCfn (ORCPT + 99 others); Mon, 24 Jan 2022 21:35:43 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:36486 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384916AbiAXUax (ORCPT ); Mon, 24 Jan 2022 15:30:53 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E30D6B8122C; Mon, 24 Jan 2022 20:30:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B569C340E5; Mon, 24 Jan 2022 20:30:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643056250; bh=fK6DkSfpEookxk1QDIkJ4mjhD5RwifwdmlHDTA/FB7Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dRJua+Hr5ajqi0H2JSxlJgMXyJ901SABVP+FOei/NJ0u5xxuwNdbICmA5oh3F81vR jxL1E0BXL7QGgc+gaE0CdPBiVRbrj65jDgZohD56rKC7utbtg6Uonq8+rMIxLRWt11 +Lz5Bl/lD1NuI13zevoAL4NkC9wMNqQ7yoloMZJg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maxim Levitsky , Joerg Roedel , Sasha Levin Subject: [PATCH 5.15 421/846] iommu/amd: X2apic mode: setup the INTX registers on mask/unmask Date: Mon, 24 Jan 2022 19:38:58 +0100 Message-Id: <20220124184115.507422168@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Maxim Levitsky [ Upstream commit 4691f79d62a637958f7b5f55c232a65399500b7a ] This is more logically correct and will also allow us to to use mask/unmask logic to restore INTX setttings after the resume from s3/s4. Fixes: 66929812955bb ("iommu/amd: Add support for X2APIC IOMMU interrupts") Signed-off-by: Maxim Levitsky Link: https://lore.kernel.org/r/20211123161038.48009-4-mlevitsk@redhat.com Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- drivers/iommu/amd/init.c | 65 ++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c index c1d4e66d2747b..a826de8c99c45 100644 --- a/drivers/iommu/amd/init.c +++ b/drivers/iommu/amd/init.c @@ -2012,48 +2012,18 @@ union intcapxt { }; } __attribute__ ((packed)); -/* - * There isn't really any need to mask/unmask at the irqchip level because - * the 64-bit INTCAPXT registers can be updated atomically without tearing - * when the affinity is being updated. - */ -static void intcapxt_unmask_irq(struct irq_data *data) -{ -} - -static void intcapxt_mask_irq(struct irq_data *data) -{ -} static struct irq_chip intcapxt_controller; static int intcapxt_irqdomain_activate(struct irq_domain *domain, struct irq_data *irqd, bool reserve) { - struct amd_iommu *iommu = irqd->chip_data; - struct irq_cfg *cfg = irqd_cfg(irqd); - union intcapxt xt; - - xt.capxt = 0ULL; - xt.dest_mode_logical = apic->dest_mode_logical; - xt.vector = cfg->vector; - xt.destid_0_23 = cfg->dest_apicid & GENMASK(23, 0); - xt.destid_24_31 = cfg->dest_apicid >> 24; - - /** - * Current IOMMU implemtation uses the same IRQ for all - * 3 IOMMU interrupts. - */ - writeq(xt.capxt, iommu->mmio_base + MMIO_INTCAPXT_EVT_OFFSET); - writeq(xt.capxt, iommu->mmio_base + MMIO_INTCAPXT_PPR_OFFSET); - writeq(xt.capxt, iommu->mmio_base + MMIO_INTCAPXT_GALOG_OFFSET); return 0; } static void intcapxt_irqdomain_deactivate(struct irq_domain *domain, struct irq_data *irqd) { - intcapxt_mask_irq(irqd); } @@ -2087,6 +2057,38 @@ static void intcapxt_irqdomain_free(struct irq_domain *domain, unsigned int virq irq_domain_free_irqs_top(domain, virq, nr_irqs); } + +static void intcapxt_unmask_irq(struct irq_data *irqd) +{ + struct amd_iommu *iommu = irqd->chip_data; + struct irq_cfg *cfg = irqd_cfg(irqd); + union intcapxt xt; + + xt.capxt = 0ULL; + xt.dest_mode_logical = apic->dest_mode_logical; + xt.vector = cfg->vector; + xt.destid_0_23 = cfg->dest_apicid & GENMASK(23, 0); + xt.destid_24_31 = cfg->dest_apicid >> 24; + + /** + * Current IOMMU implementation uses the same IRQ for all + * 3 IOMMU interrupts. + */ + writeq(xt.capxt, iommu->mmio_base + MMIO_INTCAPXT_EVT_OFFSET); + writeq(xt.capxt, iommu->mmio_base + MMIO_INTCAPXT_PPR_OFFSET); + writeq(xt.capxt, iommu->mmio_base + MMIO_INTCAPXT_GALOG_OFFSET); +} + +static void intcapxt_mask_irq(struct irq_data *irqd) +{ + struct amd_iommu *iommu = irqd->chip_data; + + writeq(0, iommu->mmio_base + MMIO_INTCAPXT_EVT_OFFSET); + writeq(0, iommu->mmio_base + MMIO_INTCAPXT_PPR_OFFSET); + writeq(0, iommu->mmio_base + MMIO_INTCAPXT_GALOG_OFFSET); +} + + static int intcapxt_set_affinity(struct irq_data *irqd, const struct cpumask *mask, bool force) { @@ -2096,8 +2098,7 @@ static int intcapxt_set_affinity(struct irq_data *irqd, ret = parent->chip->irq_set_affinity(parent, mask, force); if (ret < 0 || ret == IRQ_SET_MASK_OK_DONE) return ret; - - return intcapxt_irqdomain_activate(irqd->domain, irqd, false); + return 0; } static struct irq_chip intcapxt_controller = { -- 2.34.1