Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp496582pxf; Thu, 11 Mar 2021 08:15:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+4ZRY3z1ABOMQEBDYZM9I9pqZCYNJ/rAu0dLLXJIB/gd2P0DNbc6iGAqRqr6YRPNcuY3n X-Received: by 2002:a05:6402:180b:: with SMTP id g11mr9164847edy.195.1615479348740; Thu, 11 Mar 2021 08:15:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615479348; cv=none; d=google.com; s=arc-20160816; b=yosz5ZPZLtlr6+DMyXoUoprt+DcAkO6rEjO4IZkqInieZUKDbiR8rLuUOOryIPMzAI oKwbxQfevQ8i3EkpxC5PvUsdPM8q9Bm1aapc1suCFe+Rn2jN8u7/zMqN/Iusojo1aasW Nr6tLL0z6fxis3Kx4SqWQgEXqhOv7NcoxexO5RNoazXRqdufJQTzRBg29p0pSeKEnp5t G0ViudLqMvDp7HV1GgBIZRGA8YZW/cGuQ8s9s3NJOOFSnd5h8yvwGIGQ0QTeiDZ1dxf3 82C9dCjV+CtDHRoT8Nx01bCwVN+mtizxaG8JkM7JdFdL5UZUrBwSJ0wiyCNUdAOiVRef 10vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=5Sg+1Ar41iWCSZuZx0x+RojB3r9XUQUySp9L6eENzSU=; b=u0bDMKTFamzo5YjOW7gxcPSQxIInV9KlY99OrqO29dj5QEPPOZvqQSH2lZNbHS1ml3 TO7zRg0sJvd7shMhh8Omr7VjW26PeHoPIsPsJRrs6HisQg09LEvetuUEyhzF8In56IQ4 dQHoapavkD/wvfuMcBHYHxW5tL4ZDq1ui226oCYDYQU+GOzznG1NwUVkqHRAFxkJZ1nA +HYgaa3L94nvd7wklTa/w8GrIrtxpFVneLbh67+RfNEBl01Cxykjfj/TqvIKkqrADik4 fT+YA4JVewC4tE3xSdNo/ED7fR6sba7gfT3g770R8LdcuuV6Jzp34enEgQTvuAN3RF8l khLQ== 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=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bi6si2139801edb.419.2021.03.11.08.15.25; Thu, 11 Mar 2021 08:15:48 -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; 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=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234471AbhCKQL4 (ORCPT + 99 others); Thu, 11 Mar 2021 11:11:56 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:45792 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S234434AbhCKQLx (ORCPT ); Thu, 11 Mar 2021 11:11:53 -0500 X-UUID: 920a9f543abd4b8eb024653144d1dcd3-20210312 X-UUID: 920a9f543abd4b8eb024653144d1dcd3-20210312 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 195972198; Fri, 12 Mar 2021 00:11:45 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs08n2.mediatek.inc (172.21.101.56) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 12 Mar 2021 00:11:42 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 12 Mar 2021 00:11:43 +0800 From: Mark-PK Tsai To: , Mark-PK Tsai CC: , , , , , , , Subject: Re: [PATCH v2] irqchip/irq-mst: Support polarity configuration Date: Fri, 12 Mar 2021 00:11:40 +0800 Message-ID: <20210311161140.32678-1-mark-pk.tsai@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: F57B12502744B967590C3F5378BE9D0A449D426B3AD3C6D8362E0B0796EBA2102000:8 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Daniel Palmer > On Thu, 11 Mar 2021 at 12:12, Mark-PK Tsai wrote: > > For a fiq controller, the input edge signal will be convert to level and > > keep the interrupt status until we do EOI operation. > > That means if a rising edge input if trigger the ouput line will keep high > > until we clear the interrupt status. > > I think maybe the fiq is always edge triggered? > It seems like it latches on an edge and holds it's output to the GIC > high until it is reset by eoi and then only triggers again on another > edge. > I can experiment to confirm that's what it actually does for the chips I have. > > Then it seems like the irq version is almost just a configurable > inverter that passes either the input signal or the inverted input > signal to the GIC. > > So maybe fiq should only accept edge type interrupts and irq could > accept either? Why irq could accept either? And if it's a fiq controller, we can just remove 'mstar,intc-no-eoi' from the device node. Whether the controller is fiq or irq, the interrupt request from mst-intc to parent GIC is level sensitive. Because if the source is edge triggered, mst-intc always latch it. > > > static int mst_irq_chip_set_type(struct irq_data *data, unsigned int type) > > { > > - if (type != IRQ_TYPE_LEVEL_LOW && type != IRQ_TYPE_LEVEL_HIGH) > > - return -EINVAL; > > - > > - if (type == IRQ_TYPE_LEVEL_LOW) { > > + if (type == IRQ_TYPE_EDGE_FALLING) { > > + mst_set_irq(data, INTC_REV_POLARITY); > > + type = IRQ_TYPE_EDGE_RISING; The interrupt triggered type of the parent GIC should be active high, I will modify it. > > + } else if (type == IRQ_TYPE_LEVEL_LOW) { > > mst_set_irq(data, INTC_REV_POLARITY); > > type = IRQ_TYPE_LEVEL_HIGH; > > } > > I think this still needs the logic to check that type is something we > can handle (not IRQ_TYPE_EDGE_BOTH) and maybe if the fiq controller Agree. > can only do edge interrupts level types should return -EINVAL? No matter what triggered type of an irq we write in dts is edge or level triggered, the init and handling flow is the same except we need to do eoi if the controller doesn't have the property 'mstar,intc-no-eoi'. So maybe we don't need to do extra work to check the type for an fiq or irq controller? And I will update the patch as following: diff --git a/drivers/irqchip/irq-mst-intc.c b/drivers/irqchip/irq-mst-intc.c index 841b9b1c2699..f46ade7b1775 100644 --- a/drivers/irqchip/irq-mst-intc.c +++ b/drivers/irqchip/irq-mst-intc.c @@ -90,13 +90,14 @@ static void mst_intc_eoi_irq(struct irq_data *d) static int mst_irq_chip_set_type(struct irq_data *data, unsigned int type) { - if (type != IRQ_TYPE_LEVEL_LOW && type != IRQ_TYPE_LEVEL_HIGH) + if (type != IRQ_TYPE_EDGE_RISING && type != IRQ_TYPE_EDGE_FALLING && + type != IRQ_TYPE_LEVEL_HIGH && type != IRQ_TYPE_LEVEL_LOW) return -EINVAL; - if (type == IRQ_TYPE_LEVEL_LOW) { + if (type == IRQ_TYPE_LEVEL_LOW || type == IRQ_TYPE_EDGE_FALLING) mst_set_irq(data, INTC_REV_POLARITY); - type = IRQ_TYPE_LEVEL_HIGH; - } + + type = IRQ_TYPE_LEVEL_HIGH; return irq_chip_set_type_parent(data, type); } @@ -219,11 +220,12 @@ static int mst_intc_domain_alloc(struct irq_domain *domain, unsigned int virq, parent_fwspec.param[1] = cd->irq_start + hwirq; /* - * If the irq signal is active low, configure it to active high - * to meet GIC SPI spec in mst_irq_chip_set_type via REV_POLARITY bit + * mst-intc latch the interrupt request if it's edge triggered, + * so the output signal to parent GIC is always level sensitive. + * And if the irq signal is active low, configure it to active high + * to meet GIC SPI spec in mst_irq_chip_set_type via REV_POLARITY bit. */ - if (fwspec->param[2] == IRQ_TYPE_LEVEL_LOW) - parent_fwspec.param[2] = IRQ_TYPE_LEVEL_HIGH; + parent_fwspec.param[2] = IRQ_TYPE_LEVEL_HIGH; return irq_domain_alloc_irqs_parent(domain, virq, nr_irqs, &parent_fwspec); }