From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f169.google.com (mail-yw1-f169.google.com [209.85.128.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF4393C4174 for ; Fri, 10 Jul 2026 16:01:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783699287; cv=none; b=X7sQN/TnuVm4Gse6vL18O7xK5iBxZHaYM+3OenagVUATuTUFNa3/OmH61iXz7t6cEHBnDVcTFcM4gPGUidcd0swlbaJEoN4yYRJrnJzpDX5WztdVDzKAGx8K2TT0cvy/Wd5lcB43NemkyZguFByXL/58UW+0qPRS3Z4EyHGa1jw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783699287; c=relaxed/simple; bh=uLPdwznAA16rRBewYyJb6MPaGc4jA+si+tOg5Gq5fas=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=hHy+wGB00icaxvbLOzIyB8c6Vf6RqZJlhxgugEJ0f7lTxMN8yolYXNG3Pjjn2u7uqnsnwxCKecvYyPJYEcjmKwen3s9Ift1iFuysPeLaIHDwfkV1dZZkqpdS9dAAWA3czS784TjKqVz171SyXogVOLyiZz5UwKqBA/PK5dX9z7U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com; spf=pass smtp.mailfrom=riscstar.com; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b=eeAGLQYu; arc=none smtp.client-ip=209.85.128.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=riscstar.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b="eeAGLQYu" Received: by mail-yw1-f169.google.com with SMTP id 00721157ae682-80cbb0688c8so16790617b3.1 for ; Fri, 10 Jul 2026 09:01:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=riscstar-com.20251104.gappssmtp.com; s=20251104; t=1783699281; x=1784304081; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=1hTfHUanZhIXs0ZjukXO0cd1RP2eKmvIle5TeFGqJ2E=; b=eeAGLQYuJ4vka6TfcQh4UHsghaBRYcGSOxj/YmbMhPNh+TQnfR3LJ9RvbB1LUpiFBx et/01zbqBRmupbSEHve5DtRs/fUC+L2mwRl9lYTfB6YaD4fAjKBPqYVZrw2rtRqFFfVG HzzW7P0aIa4wCW0U12b2zB65FKrIVhYrmlrgLoWIKj41CIVPmh8rvhJfMia3aXynIgky chgBIMX1vtnYjkeH6MuViBzT0DCCdARk9DzpQqUVex19HyZsO46j+24mixTy2VB8769M vnuNkrPlrIKnx0J/8qhMNQEsj8YZlmcKZaPwnh7UJlFFyCofxN3NvqklY/wiYKySpoo6 JfSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783699281; x=1784304081; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=1hTfHUanZhIXs0ZjukXO0cd1RP2eKmvIle5TeFGqJ2E=; b=CiUxwh6Obdo6N1BRGFh+o6BPlXyrGlvYJhBAqqgumy5s+yPblNJC9NjZfyVV22bS89 jwnJrHyWxXpebnrCuwfp0hmyKjdWJ+wWg4ksxQzAB/AlWjLTBHxtYrueCMz5o9YLyHKj YLELnboIosxJZZClKbEMRIRT9jUM18y/LbKtb8Ul1ZPdB+t7yvBg1dcrWS30H1A4biFh PFt5x1RHuEy3pIvdJpVn2MbmtmCaV0IC7pHjqY03aM302Is7oECoZuE9h3kBqpzgSNLw xTaJDHGvqkND23F83/g5+5o4uzRtTWrcywCWtoa1vf6Bue62liloirimE5919uUlhPxd PeJw== X-Forwarded-Encrypted: i=1; AHgh+RpFJ/45AcfMYmSlGqki2wZ3T++yRMWPQiXj3LiCELWFMhPlIwdfQfBlYkY9k94qgjIvvzxCHCVbuWIS@vger.kernel.org X-Gm-Message-State: AOJu0YxxCcWRCpVr7vZcjW+WZ8cqPpZfzqTWyP6wa4yWSR6emAO8answ Lhq63eH5NBMOz7IBDAHuQ3lISdcneTEWUPqAfbhHi2jcxtBRoFfdrFkkXMpWzx/5aZJsNvyru80 Vf4D1V6k= X-Gm-Gg: AfdE7cmTy+RgmrNfjer9HuAOu6r2b0uty4BjwahdZ6BR9VwDUCClP3KuGcxC4FmcLwH VlOTr764FlGEZrDdOB3vmPEfVAv/qFGXzoxYG3MOpOlIA05aMHdaIWHCDdLVasN+4qtNP1MJsMa UJDTOjNMY88FIQIONRREksKYfcATzX4DovJvEfEPXHU42IBAJx4xRqaO8UQUQv5C/CgguAAvF2Q o0Hd6qnHFQiwQMl3Z2VurZlMaWZHvy2RAxKXC3qr5HlwVBmXdG36MoaXi89KQ22CoEcvDg+VR7t hi9XPLCv48yOol1dsEsJnS3OT0G2R6KCxejRp9LMmSQY/8rjgEUIbx+OA4fnvBZJh4WFY3HBeus 1pMYHogyL7s4dL/k39q//zbG+ZXZxJx9PdRXbfOJXAS1JMpTBQ7+1JQWz52szjMgCuVGtfLi/TB Gnnq0XYlWPpWuZVh3PSDGgj3A= X-Received: by 2002:a05:690c:6384:b0:81e:8112:c5c9 with SMTP id 00721157ae682-81e8112ef15mr20197907b3.3.1783699280936; Fri, 10 Jul 2026 09:01:20 -0700 (PDT) Received: from [172.22.22.28] ([73.62.185.64]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-9036e27f765sm8965376d6.11.2026.07.10.09.01.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 10 Jul 2026 09:01:20 -0700 (PDT) Message-ID: <338687f9-e80e-40e8-b14e-1218e61e4e0c@riscstar.com> Date: Fri, 10 Jul 2026 11:01:16 -0500 Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 1/6] PCI: spacemit-k1: Add device data support To: Inochi Amaoto , Jingoo Han , Manivannan Sadhasivam , Bjorn Helgaas , Lorenzo Pieralisi , =?UTF-8?Q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Yixun Lan , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Christian Bruel , Frank Li , Nam Cao , Qiang Yu , Krishna Chaitanya Chundru , Xincheng Zhang , Siddharth Vadapalli , Andy Shevchenko , Vidya Sagar , Neil Armstrong , Gustavo Pimentel Cc: linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, spacemit@lists.linux.dev, Yixun Lan , Longbin Li References: <20260709040027.958400-1-inochiama@gmail.com> <20260709040027.958400-2-inochiama@gmail.com> Content-Language: en-US From: Alex Elder In-Reply-To: <20260709040027.958400-2-inochiama@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 7/8/26 11:00 PM, Inochi Amaoto wrote: > To reuse the K1 PCIe driver logic for K3 PCIe controller, add device > data to handle the K1 specific logic and make room for the incoming > logic for K3. > > Signed-off-by: Inochi Amaoto I have two suggestions/questions, but I think this looks good overall (please add the space that Andy suggested). If you drop the data field in the k1_pcie structure you can keep this tag: Reviewed-by: Alex Elder > --- > drivers/pci/controller/dwc/pcie-spacemit-k1.c | 30 ++++++++++++++++--- > 1 file changed, 26 insertions(+), 4 deletions(-) > > diff --git a/drivers/pci/controller/dwc/pcie-spacemit-k1.c b/drivers/pci/controller/dwc/pcie-spacemit-k1.c > index be20a520255b..f6ae8ff3589a 100644 > --- a/drivers/pci/controller/dwc/pcie-spacemit-k1.c > +++ b/drivers/pci/controller/dwc/pcie-spacemit-k1.c > @@ -49,8 +49,17 @@ > #define PCIE_CONTROL_LOGIC 0x0004 > #define PCIE_SOFT_RESET BIT(0) > > +struct k1_pcie; > + > +struct k1_pcie_device_data { > + const struct dw_pcie_host_ops *host_ops; > + const struct dw_pcie_ops *ops; > + int (*parse_port)(struct k1_pcie *k1); > +}; > + > struct k1_pcie { > struct dw_pcie pci; > + const struct k1_pcie_device_data *data; Is it strictly necessary to keep a copy of the data pointer in the k1_pcie structure? It can be convenient to do so if you reuse the fields in that structure rather than duplicating them, but often the constant platform data is meant only for initialization, and never needed after that. > struct phy *phy; > void __iomem *link; > struct regmap *pmu; /* Errors ignored; MMIO-backed regmap */ > @@ -278,14 +287,21 @@ static int k1_pcie_parse_port(struct k1_pcie *k1) > > static int k1_pcie_probe(struct platform_device *pdev) > { > + const struct k1_pcie_device_data *data; > struct device *dev = &pdev->dev; > struct k1_pcie *k1; > int ret; > > + data = device_get_match_data(dev); > + if (!data) > + return -ENODEV; > + > k1 = devm_kzalloc(dev, sizeof(*k1), GFP_KERNEL); > if (!k1) > return -ENOMEM; > > + k1->data = data; > + > k1->pmu = syscon_regmap_lookup_by_phandle_args(dev_of_node(dev), > SYSCON_APMU, 1, > &k1->pmu_off); > @@ -299,11 +315,11 @@ static int k1_pcie_probe(struct platform_device *pdev) > "failed to map \"link\" registers\n"); > > k1->pci.dev = dev; > - k1->pci.ops = &k1_pcie_ops; > + k1->pci.ops = data->ops; > k1->pci.pp.num_vectors = MAX_MSI_IRQS; > dw_pcie_cap_set(&k1->pci, REQ_RES); > > - k1->pci.pp.ops = &k1_pcie_host_ops; > + k1->pci.pp.ops = data->host_ops; > > /* Hold the PHY in reset until we start the link */ > regmap_set_bits(k1->pmu, k1->pmu_off + PCIE_CLK_RESET_CONTROL, > @@ -320,7 +336,7 @@ static int k1_pcie_probe(struct platform_device *pdev) > > platform_set_drvdata(pdev, k1); > > - ret = k1_pcie_parse_port(k1); > + ret = data->parse_port(k1); > if (ret) > return dev_err_probe(dev, ret, "failed to parse root port\n"); > > @@ -338,8 +354,14 @@ static void k1_pcie_remove(struct platform_device *pdev) > dw_pcie_host_deinit(&k1->pci.pp); > } > > +static const struct k1_pcie_device_data k1_pcie_device_data = { > + .host_ops = &k1_pcie_host_ops, > + .ops = &k1_pcie_ops, > + .parse_port = k1_pcie_parse_port, > +}; > + > static const struct of_device_id k1_pcie_of_match_table[] = { > - { .compatible = "spacemit,k1-pcie", }, > + { .compatible = "spacemit,k1-pcie", .data = &k1_pcie_device_data}, In addition to the missing space that Andy mentioned, adding a comma means the line won't need to change when you add another entry to the array. > { } > }; >