Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp547149pxa; Wed, 19 Aug 2020 08:25:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzu2sqtPYiPajvoUEcmzNJExBak0mjgYc/Ld26n1kwdh7ZAbshmauN9DPYC9dR0flVO2To5 X-Received: by 2002:a17:906:aad2:: with SMTP id kt18mr26717879ejb.537.1597850728996; Wed, 19 Aug 2020 08:25:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597850728; cv=none; d=google.com; s=arc-20160816; b=Bi+WYO+4niTSZDuQmSrc/l7xJkujVO2GxqubcD+I+FpkaJ2oInrTDYJJupNSc6Uyr3 U2Jd4eqa9Wl1j81oASKWO4inVRTUlFpFHuKGsjUQVM/yvhgtr/dNHMLfGA0ZI/6NWbnz 2OACWJx9DnabTxTdBr+lPHZqNdV/EaMQmaGo3eCOxePHIGh17L9gYyx95x3DmZhUpWNi E3qZXqfGbEN1Tm+8h9JcLtLMJL+bqtHGkpfapmFpuhpHKUCaef6oyPNAvtIovBwK+I8e CGhFmkhQYBcS2GAIL9sJMkWE+Gcj8wy+rFLAlwPYUmNUKVNl3nRqakp6rE/pH6xe2XJU zn6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature; bh=GjPvUuwm8ptwqya6NDEsUcUlHMN19wUxaDahiLjwW7g=; b=v/LRSvj/G0DECt6iT9V9ZDTg8w9d6+e6uKdXha/q+oFdMpwRHCpGXkpE2a00rbpRbo fkehSUpk6nHAuY/qJTa4XlNcpfU32VC1nQwdm2LSzjvUOMtw1f/NU8bTyRyNdsj91i2V mXrMYk/JsPBtI/9DKA72jjBWPrHDgSB7//7xz7oU8css/e9pxxwb8c3OBNvPEE3zuPCG 1sU3KWd7OA3sCHh40N1D2UViWqtpSLVAGV/0mTIIOASkC8Kwx0TLDGo4mb6Q1wO+wYDe oTP6C+BH3z/RRaHhSPGeBygA21tiul5KYWwOM+GicecqWPktfJvKNe+M6piH73q8s0Qw zVCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SzbRLU6u; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id zh8si18111217ejb.475.2020.08.19.08.25.04; Wed, 19 Aug 2020 08:25:28 -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; dkim=pass header.i=@kernel.org header.s=default header.b=SzbRLU6u; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726951AbgHSPYY (ORCPT + 99 others); Wed, 19 Aug 2020 11:24:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:35280 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726636AbgHSPYU (ORCPT ); Wed, 19 Aug 2020 11:24:20 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E18B220897; Wed, 19 Aug 2020 15:24:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597850660; bh=hHa5rHHEdmaLPV8IAAgl2hoR1WMKnusCrOaK/4DnvIM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=SzbRLU6uplI9w6fF5ALOG9qTdPUx4A/TcBFXF5MUcMy7oWkEp2G5W2+VgF7Jwd7fn Ktrm0XTFXwDXpE1EcWltK4ppy8NwfHG9YElNZ5Wyc7T1xGGOzPNAF9wK59JeqeOP8C tFbNuQD+Eq5tGugI17/6zzsdxmKZcc49JnubXs+Y= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1k8Pwn-004Fc2-Tn; Wed, 19 Aug 2020 16:24:18 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 19 Aug 2020 16:24:17 +0100 From: Marc Zyngier To: Mark-PK Tsai Cc: alix.wu@mediatek.com, daniel@0x0f.com, devicetree@vger.kernel.org, jason@lakedaemon.net, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, matthias.bgg@gmail.com, robh+dt@kernel.org, tglx@linutronix.de, yj.chiang@mediatek.com Subject: Re: [PATCH 1/2] irqchip: irq-mst: Add MStar interrupt controller support In-Reply-To: <20200819145525.26315-1-mark-pk.tsai@mediatek.com> References: <20200819145525.26315-1-mark-pk.tsai@mediatek.com> User-Agent: Roundcube Webmail/1.4.7 Message-ID: <85749ec80ad0b9c85e3984c808d02b9c@kernel.org> X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: mark-pk.tsai@mediatek.com, alix.wu@mediatek.com, daniel@0x0f.com, devicetree@vger.kernel.org, jason@lakedaemon.net, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, matthias.bgg@gmail.com, robh+dt@kernel.org, tglx@linutronix.de, yj.chiang@mediatek.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-08-19 15:55, Mark-PK Tsai wrote: > From: Marc Zyngier > >> On 2020-08-19 14:31, Mark-PK Tsai wrote: >>> From: Marc Zyngier >>> >>>> > + >>>> > +static int mst_intc_domain_alloc(struct irq_domain *domain, unsigned >>>> > int virq, >>>> > + unsigned int nr_irqs, void *data) >>>> > +{ >>>> > + int i; >>>> > + irq_hw_number_t hwirq; >>>> > + struct irq_fwspec parent_fwspec, *fwspec = data; >>>> > + struct mst_intc_chip_data *cd = (struct mst_intc_chip_data >>>> > *)domain->host_data; >>>> >>>> No cast necessary here. >>>> >>>> > + >>>> > + /* Not GIC compliant */ >>>> > + if (fwspec->param_count != 3) >>>> > + return -EINVAL; >>>> > + >>>> > + /* No PPI should point to this domain */ >>>> > + if (fwspec->param[0]) >>>> > + return -EINVAL; >>>> > + >>>> > + if (fwspec->param[1] >= cd->nr_irqs) >>>> >>>> This condition is bogus, as it doesn't take into account the nr_irqs >>>> parameter. >>>> >>> >>> >>> The hwirq number need to be in the irq map range. (property: >>> mstar,irqs-map-range) >>> If it's not, it must be incorrect configuration. >> >> I agree. And since you are checking whether the configuration is >> correct, >> it'd better be completely correct. >> >>> So how about use the condition as following? >>> >>> if (hwirq >= cd->nr_irqs) >>> return -EINVAL; >> >> Again, this says nothing of the validity of (hwirq + nr_irqs - 1)... >> > > How about move this to mst_intc_domain_translate? Then all the > irq_fwspec > point to domain mst_intc should be valid. > > The mst_intc_domain_translate will be as following: > > static int mst_intc_domain_translate(struct irq_domain *d, > struct irq_fwspec *fwspec, > unsigned long *hwirq, > unsigned int *type) > { > struct mst_intc_chip_data *cd = d->host_data; > > if (is_of_node(fwspec->fwnode)) { > if (fwspec->param_count != 3) > return -EINVAL; > > /* No PPI should point to this domain */ > if (fwspec->param[0] != 0) > return -EINVAL; > > if (fwspec->param[1] >= cd->nr_irqs) > return -EINVAL; > > *hwirq = fwspec->param[1]; > *type = fwspec->param[2] & IRQ_TYPE_SENSE_MASK; > return 0; > } > > return -EINVAL; > } It would make more sense. M. -- Jazz is not dead. It just smells funny...