Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp1102787rdb; Fri, 2 Feb 2024 13:54:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IHEtkrg6HJH07KN6vCaRKslZpxeQR/fYG1e0Chj3qIcHFNXvkfKD7QBaBkpRbVghrQjbj8d X-Received: by 2002:ac8:5a0b:0:b0:42c:c0:8299 with SMTP id n11-20020ac85a0b000000b0042c00c08299mr4037832qta.25.1706910884103; Fri, 02 Feb 2024 13:54:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706910884; cv=pass; d=google.com; s=arc-20160816; b=oJ6v3n2XybRlSvFHrhetydZ7oBP2vwmiV4GNnJCvQZZw2IU4xIXO0SwupaG3IXYFiJ ZlPWbA1XonjD99O4bSu3ST9pKx/TxNigtuadBxkZweoh+MxNJI7e/Zu4/CFcy6v2tCs0 SArWmiWRoahDteYghdeQIMKkhLYAVF1fbyFnVwNa705q4e/0bkK4GGg9VXRhh+DXuzSp qyZ1lYaNwjCILE504B1X62QovuQptz2AOk0JbDFAT61UNbUIcdjggIt37W+zFkIxsxOZ l8QlLnFlWsKbD+SXBfu/SGXT9bS9XShof9CuspDA2KYQj/i6CJIzqyKnQscfIajZW7G0 xm0w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:subject:cc:to:from :date:dkim-signature; bh=82AIMsh7E1SAFKMqR82jYH9qyswpi0wPmUeWJXUHkOM=; fh=0Uz+ZPB7joV9ltAd+tJUiQEtx5JbNQ756UhwwSjtgbQ=; b=WwoYxczbCPdmm7y9RcBhPNK0eDAR1Qa9c9NgsICnKZk1+0xHmyGUKD8Mr/jFbpYZWP Np5HZjYfhnfOuO61hl3ZwfcnwK4bxp+5uiL8zWlAX+Lg6NV1ewpsjBIZIbk7GqfZKRJz r7MnPVA4dYVBPYPA5J38wf5nXPH4g6s9Uss3135SR3aOSfgt77hZABhnNmxFcmATqXg2 Evnyylj3+gockGF9Es3UrkCB8XoW7/6DQHh4NXmAtGqv4zRMzmCOZj2qNT7Q+hk1Xt7p kosvO1Xxdk15UYvFxyp6WgWgcjFS8ropBfOjHEvyy1QLh1a/quw5jQnniw4Rups7TnGj bedg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NS8zPrba; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50626-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50626-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCVYzsGvxu8933IDndRm3/G6RnzLFSzMg7EjDRSTV9ixRqux8mxZF050b+9UzwgknYZQx/VtcJNTJvMOZyDtb2l9uEGkQiZxDSwmbrnbpA== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id a12-20020a05622a02cc00b0042bebfbc190si3039162qtx.699.2024.02.02.13.54.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 13:54:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50626-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NS8zPrba; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50626-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50626-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C83EF1C23F39 for ; Fri, 2 Feb 2024 21:54:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D3C9583A0F; Fri, 2 Feb 2024 21:54:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NS8zPrba" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE2D58061F; Fri, 2 Feb 2024 21:54:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706910874; cv=none; b=bKk266JYJcoJxTm7pGc5qmQi5A1TnrWn/5/5ZQaip2WL+VahS5u0TQBVTniufXOpt2LXyFBwrgvIJnJwS2DwDgoWr9jhorLlbNUew7yyk1iITpIOm6/AVROhdKcebWmaAVrvw6Je2Al9Vzsnsxu6vJXYFG1XlNHQu/FhosXBP1Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706910874; c=relaxed/simple; bh=g2E+c2yAPlr4mynw8XRrEWwtZ0cuRU9sb/1VLjj4d+A=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=IKdNyXOUvfs9dcG9KL9NzF1C9/fEr41UyaEp2EKRHi/yverhuh7MDqPUtBXFYQlFwg/BzhIIQOoZmDVy4gZjLqSCuSMbBriMSatR4H7cG5H1tBFS9ad5yrxpwMPEJL3ooJZp5K6bg8y69DMEsnYDSt3AZlY3CjE63hN8tH6J8TQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NS8zPrba; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E936C433C7; Fri, 2 Feb 2024 21:54:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706910873; bh=g2E+c2yAPlr4mynw8XRrEWwtZ0cuRU9sb/1VLjj4d+A=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=NS8zPrbawxvDfY0Eh7Q6yuZ1sIPxS165/J7/2Y7tKanOBPLD+4dB3IXc8L5YVGy80 bSWHpRgxY9QHX90pQtSVPTYdQ/RF+IJfmh4C9vwg31doe1ucpeQzgA1E6HsCWaqTHZ WCHB5KJ5V0wkgI2ydWwMccY0UpKEymbcFn/iIF/oxzC7FMfuTNMEXPOkifc6HJT1KX AjBVnvpt9LpUJv70WYr8CkRldTO5/oVEKraxwJZLD566+Vag7nYVd32hSm516qWbzq RYeFz6sshI5fm5CjbRRLRy0SymKXAinGlASjWBOzggBE/yLhBhaEvy48n0tB++7L6V ClG0C1+ZWvgsA== Date: Fri, 2 Feb 2024 15:54:31 -0600 From: Bjorn Helgaas To: Frank Li Cc: manivannan.sadhasivam@linaro.org, bhelgaas@google.com, conor+dt@kernel.org, devicetree@vger.kernel.org, festevam@gmail.com, hongxing.zhu@nxp.com, imx@lists.linux.dev, kernel@pengutronix.de, krzysztof.kozlowski+dt@linaro.org, krzysztof.kozlowski@linaro.org, kw@linux.com, l.stach@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, lpieralisi@kernel.org, robh@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org Subject: Re: [PATCH v9 05/16] PCI: imx6: Using "linux,pci-domain" as slot ID Message-ID: <20240202215431.GA728556@bhelgaas> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240119171122.3057511-6-Frank.Li@nxp.com> On Fri, Jan 19, 2024 at 12:11:11PM -0500, Frank Li wrote: > Avoid use get slot id by compared with register physical address. If there > are more than 2 slots, compared logic will become complex. > > "linux,pci-domain" already exist at dts since commit: > commit (c0b70f05c87f3b arm64: dts: imx8mq: use_dt_domains for pci node). > > So it is safe to remove compare basic address code: > ... > if (dbi_base->start == IMX8MQ_PCIE2_BASE_ADDR) > imx6_pcie->controller_id = 1; > ... I have no idea what this is telling me. I guess you don't want to use IMX8MQ_PCIE2_BASE_ADDR to decide something? That much sounds good: the *address* of some MMIO space doesn't tell us anything about the function of that space. I expect the "compatible" string to tell the driver what the programming model of the device is. > + /* Using linux,pci-domain as PCI slot id */ > + imx6_pcie->controller_id = of_get_pci_domain_nr(node); > + /* > + * If there are no "linux,pci-domain" property specified in DT, then assume only one > + * controller is available. > + */ > + if (imx6_pcie->controller_id == -EINVAL) > + imx6_pcie->controller_id = 0; > + else if (imx6_pcie->controller_id < 0) > + return dev_err_probe(dev, imx6_pcie->controller_id, > + "linux,pci-domain have wrong value\n"); Maybe I'm missing something here. It looks like this driver uses controller_id to distinguish between hardware variants or maybe between two Root Ports (slots?) in the same SoC? imx6_pcie_grp_offset return imx6_pcie->controller_id == 1 ? IOMUXC_GPR16 : IOMUXC_GPR14; imx6_pcie_configure_type id = imx6_pcie->controller_id if (!drvdata->mode_mask[id]) # <-- looks unsafe id = 0; regmap_update_bits(drvdata->mode_off[id], ...) (This "mode_mask[id]" looks like it will reference garbage if the DT supplies "linux,pci-domain = <2>". A bogus DT shouldn't be able to cause a driver to misbehave like that.) That doesn't seem related to "linux,pci-domain" at all. Bjorn