From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E4867C05027 for ; Wed, 15 Feb 2023 01:42:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HHwC7AslU8aAiY+qS35VHL8VsjL5jobJMLWi/9Nr7gI=; b=G0R8+vSOqbYjmG q0pQLLnRRudFQvDJMhhGtxfKqJEw2ovpuJPl44RVIKNXz3AITStIhEaD1BVgeyGQtiW6be+VM5G8a XLCeF5gdhsjY4rFpIkVadU3cT9cZe7MMO08y8L2hH1p2xckaikO1FePvceiayWdpmj1Doe3q82ZcK 7gut1VjL1atT13iNCWRQKAcwDhxC/VTa1AWCfzyUChYHiRUjaJ0/A+KDPsTz5OV11/WVOCPKqa3XQ 0ci4OBUE4YUJysapFzuhIt/lws1f6ofU4tJLrhq12LISob7sGcRbaUaeG6phv9Pyno80sHQYZ1+TF +k6KMLv9/20BHMyD9LvA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pS6m0-004IO5-53; Wed, 15 Feb 2023 01:39:52 +0000 Received: from esa5.hgst.iphmx.com ([216.71.153.144]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pS6lu-004INF-Mw for linux-arm-kernel@lists.infradead.org; Wed, 15 Feb 2023 01:39:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1676425186; x=1707961186; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=oy+5bs8bztFCfWMEixVu7mADVC2yPYRnwRT4aa/6byw=; b=jS+P+4ipKccX/IqkXOxyZPUHfCS7oGtWFrPtGiVwswFdBvocqK546I/k AEfPfz8S5ldm5hatZ+1UxwZHUoPu+/Zl+uGmuSK8zUuSU+P4Kuc+Za4Hl B0PC1TIAUOI5V+jpGHLgN8zGEWcvP40J6cvZZhP5muObtRVUxB4dBGBCJ ZhiMQaTDKR0FOpwg7zbz8tn8n3mX+6mc9McO+pIfJPRjn9u/fi8NAvLPM BDu+Tgf5hqgQZrfQdFUiVSdpoYkPuYXN3tP1DGxZ1q4ugX6OL8lZMoKfB NRpEzz1qY0y/sWem9cR3weKqK7SO0b4VstlTT18NldI0SmdiWAyz5Lt7R Q==; X-IronPort-AV: E=Sophos;i="5.97,298,1669046400"; d="scan'208";a="223117981" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 15 Feb 2023 09:39:46 +0800 IronPort-SDR: 9jawyPyRjDNCFoNOICQ7f89e9yBFPT8tsEOAt/jCL4J9JfObl8BY3QAr9G69sDPN8s4gBTkWoo EtQXQjmlcGuJcYXO6wC17Dq65NrNh4Rlnvd8e9bbY4QwGzVyCwRskoZHu5sHDdCFEOM1BBbXGE c8xF0Y3Elt0G/HDtu3JG8CEy3GPwK3z9iRevlmxuLezgTKd3h0bKG0jIuXT/5QTbLIQ/d32HpP T4AR00D3dDqq85QkuY4fHu38abSGcALllnNeaRuGD83VnK5T/sDZVSvAYe2PRmra2CfzdVvgvi z8Y= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 14 Feb 2023 16:51:08 -0800 IronPort-SDR: t2Za7+LNzSpqYJ9iJpGU82MS/E+PXmNncMDxlO8p/jpWYAa/3L5pexQeo+949+zy+HEH14xOOW ftBpyLS/Yw+31h7WIbnt9s2sR0r3Jsa9QN6wi+i9t8UGvqESUnHQBUMzVFlaoazirxRwFq36dg PaxeCv2gGAGGUf0caUWZDJNXSfAZZnj9HaC9LJmgqkL9WdmOj4JQYBsBqrQXy2zccw2diADm78 9raVDWKX7zBfFXVuVlBEzssnxd0fPLSe7YQZ1z2rbzgA5SJb+JABZxn7hxGVfUMfgufzptKdJd WV0= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 14 Feb 2023 17:39:46 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4PGgjs3Wmlz1RwtC for ; Tue, 14 Feb 2023 17:39:45 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :in-reply-to:organization:from:references:to:content-language :subject:user-agent:mime-version:date:message-id; s=dkim; t= 1676425184; x=1679017185; bh=oy+5bs8bztFCfWMEixVu7mADVC2yPYRnwRT 4aa/6byw=; b=fOcVMEdSFlGAd1ybZTpNogWSvYjl6ZCDZG1CJdrrh3tdQynF8wa MiE+19cVjiqq46ifzKZt3mxvuVEwCLksA7+QuHAQFOrZXLb3FSsKJ9slXisXT5RL XtBXMPaA9sCvCGH4/YoQC/LBjVRj/wkb8gVLj5pjWMOFbRu7bhcOw2qStLyVJbNf An1Mz9pv71TC3lt6OYaeHptV0N2JoQwSvZc2ceRcyXlNadb74ugk8Bi6Da47/Iq1 SX01+63gwt+kDdCYfffcA0zaZJo/RUHyNng7i880SK1HA1qWSrszc+APpciLlVrt aaI4vSIi1tGdYbKPTNcod6fNrykE32mZZPQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id QaokTjibBdj5 for ; Tue, 14 Feb 2023 17:39:44 -0800 (PST) Received: from [10.225.163.116] (unknown [10.225.163.116]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4PGgjn1BCDz1RvLy; Tue, 14 Feb 2023 17:39:40 -0800 (PST) Message-ID: Date: Wed, 15 Feb 2023 10:39:39 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [PATCH v2 9/9] PCI: rockchip: Add parameter check for RK3399 PCIe endpoint core set_msi() Content-Language: en-US To: Rick Wertenbroek , alberto.dassatti@heig-vd.ch Cc: xxm@rock-chips.com, rick.wertenbroek@heig-vd.ch, Rob Herring , Krzysztof Kozlowski , Heiko Stuebner , Shawn Lin , Lorenzo Pieralisi , =?UTF-8?Q?Krzysztof_Wilczy=c5=84ski?= , Bjorn Helgaas , Jani Nikula , Greg Kroah-Hartman , Rodrigo Vivi , Mikko Kovanen , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org References: <20230214140858.1133292-1-rick.wertenbroek@gmail.com> <20230214140858.1133292-10-rick.wertenbroek@gmail.com> From: Damien Le Moal Organization: Western Digital Research In-Reply-To: <20230214140858.1133292-10-rick.wertenbroek@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230214_173946_841682_0DFFFEBC X-CRM114-Status: GOOD ( 26.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2/14/23 23:08, Rick Wertenbroek wrote: > The RK3399 PCIe endpoint core supports only a single PCIe physcial > function (function number 0), therefore return -EINVAL if set_msi() is > called with a function number greater than 0. > The PCIe standard only allows the multi message capability (MMC) value > to be up to 0x5 (32 messages), therefore return -EINVAL if set_msi() is > called with a MMC value of over 0x5. > > Signed-off-by: Rick Wertenbroek > --- > drivers/pci/controller/pcie-rockchip-ep.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/drivers/pci/controller/pcie-rockchip-ep.c b/drivers/pci/controller/pcie-rockchip-ep.c > index b7865a94e..80634b690 100644 > --- a/drivers/pci/controller/pcie-rockchip-ep.c > +++ b/drivers/pci/controller/pcie-rockchip-ep.c > @@ -294,6 +294,16 @@ static int rockchip_pcie_ep_set_msi(struct pci_epc *epc, u8 fn, u8 vfn, > struct rockchip_pcie *rockchip = &ep->rockchip; > u32 flags; > > + if (fn) { > + dev_err(&epc->dev, "This endpoint controller only supports a single physical function\n"); > + return -EINVAL; > + } Checking this here is late... Given that at most only one physical function is supported, the check should be in rockchip_pcie_parse_ep_dt(). Something like: err = of_property_read_u8(dev->of_node, "max-functions", &ep->epc->max_functions); if (err < 0 || ep->epc->max_functions > 1) ep->epc->max_functions = 1; And all the macros with the (fn) argument could also be simplified (argument fn removed) since fn will always be 0. > + > + if (mmc > 0x5) { > + dev_err(&epc->dev, "Number of MSI IRQs cannot be more than 32\n"); Long line. Please split it after the comma. > + return -EINVAL; > + } > + > flags = rockchip_pcie_read(rockchip, > ROCKCHIP_PCIE_EP_FUNC_BASE(fn) + > ROCKCHIP_PCIE_EP_MSI_CTRL_REG); Another nice cleanup: define ROCKCHIP_PCIE_EP_MSI_CTRL_REG to include the ROCKCHIP_PCIE_EP_FUNC_BASE(fn) addition so that we do not have to do it here all the time. -- Damien Le Moal Western Digital Research _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel