Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp494499yba; Fri, 12 Apr 2019 07:41:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqw2Jld+a5xe8MVbnQE0pFo4vOxW+iBybTvCrp6qE+eWBVrbgSZFSlikOlfL9dwgxLvxdl9M X-Received: by 2002:a63:da4e:: with SMTP id l14mr51370994pgj.96.1555080118431; Fri, 12 Apr 2019 07:41:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555080118; cv=none; d=google.com; s=arc-20160816; b=BFM/w98ZS9/XpEPeL8zexPlS9xmqc5h6t16XUie7K/mbgZAuGvjE3iLAtymZsh6q/q 3URRO3/lcaPw/Sg1LaKrrAf+a2S6LwpxgEza4rIWs3xhac21zGu6jccAKIBksvMJ8wvb rm6VVpoEafJoX7zMpDiuGgDbnsGdVh7zqQJXPSvw4odNBmoVeaD5EazEhIaDaMBbhwhf 6YXNlGtzz9tdKwl+o1iTOZyYr474H2MZC9lO54iOc8cnFfnmAYTRPFWVT9y1jVKm83Fu adGEywOg0vgkZE+3/3qrY/QKUbxV+6WSDCYdpWMdLwOKRbHKGt2wBnZCS9GLZzJyOPBP dOYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=BXbeXUrjBjLrWlL0TmLgzo3uh8ojGyU8TTFaDmZ16kk=; b=v+ND0y6noHAiEPebJ24fqdSVgzCSJloyjBEpLl92Jso792oVdpLrWQjOxltVvzlfm+ QxHpubx+qKaBoYPeqDasODCGQ9VqkAVbGjs1dLwHtg70v6xw3gN9PpW3zG7qSpyqWNX8 yg1jjFZ7gK8baHULq2hQg+TsgLan19so4Wth1X4iDQo8lFuwXClcu0kqRPk/X9oTsZ08 N/FjJrW0wm2NUwOewrixn2CY4DipnSrSw3AuJNDanqhtiydg8k9BwKMryD/gZ5xeyj/p fr+K7GpgkzLGCPGWZr6li+JBwyC9IujtWtPSyF8NaISFL+kd2ezJ6wfeHYPzMA0D2Wox Os8Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r17si18065708pgh.311.2019.04.12.07.41.38; Fri, 12 Apr 2019 07:41:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727091AbfDLOji (ORCPT + 99 others); Fri, 12 Apr 2019 10:39:38 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:39664 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726624AbfDLOjf (ORCPT ); Fri, 12 Apr 2019 10:39:35 -0400 Received: by mail-qt1-f193.google.com with SMTP id t28so11457446qte.6; Fri, 12 Apr 2019 07:39:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BXbeXUrjBjLrWlL0TmLgzo3uh8ojGyU8TTFaDmZ16kk=; b=Sn1t/7K4jJGZGLf0mmEZHzMpyPllARc5qskuEOjKGV0yWzrjnNVzLk+k4RtWsSB/hr hN9MV0gmBLEsxRBUaThqRWhcs1FfmHpXffeE+WjPsq/4oZMoThSGMLbBYI8ACZyXPQTu FBSOj07PDrCM/OyagyPaovxL+EcPkMKlqyRvSo9TUGIULlntXdo2vOM63ktoF8sN9SSW RZBgiAgSgZp72+ytoByMAqON2y8ek7AAHFvhiEGTtCe53tXEXK1vsKRlp8ZDW7GKpewJ 0Nzc+HrXQzK9ELoNtRSz7MsvW8/5R74HuIq0pxAP63waxNlKPv4KF6KQznFPYzZMSF74 NSOQ== X-Gm-Message-State: APjAAAV/aHI0Au3R0ps9r/zuP+nhWtB4aONZ3Lf8QsDstVehiX/aEdIM t4vf/ngZSPP+0vcusPDwphsq268YrfUtIW0C9uw= X-Received: by 2002:ac8:276b:: with SMTP id h40mr48268242qth.319.1555079973925; Fri, 12 Apr 2019 07:39:33 -0700 (PDT) MIME-Version: 1.0 References: <20190412095332.41370-1-Zhiqiang.Hou@nxp.com> <20190412095332.41370-2-Zhiqiang.Hou@nxp.com> In-Reply-To: <20190412095332.41370-2-Zhiqiang.Hou@nxp.com> From: Arnd Bergmann Date: Fri, 12 Apr 2019 16:39:16 +0200 Message-ID: Subject: Re: [PATCHv5 1/6] PCI: mobiveil: Refactor Mobiveil PCIe Host Bridge IP driver To: "Z.q. Hou" Cc: "linux-pci@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "bhelgaas@google.com" , "robh+dt@kernel.org" , "mark.rutland@arm.com" , "l.subrahmanya@mobiveil.co.in" , "shawnguo@kernel.org" , Leo Li , "lorenzo.pieralisi@arm.com" , "catalin.marinas@arm.com" , "will.deacon@arm.com" , "M.h. Lian" , Xiaowei Bao , Mingkai Hu Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 12, 2019 at 11:53 AM Z.q. Hou wrote: > +int mobiveil_pcie_host_probe(struct mobiveil_pcie *pcie) > { > - struct mobiveil_pcie *pcie; > struct pci_bus *bus; > struct pci_bus *child; > struct pci_host_bridge *bridge; > - struct device *dev = &pdev->dev; > + struct device *dev = &pcie->pdev->dev; > resource_size_t iobase; > int ret; > > - /* allocate the PCIe port */ > - bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie)); > - if (!bridge) > - return -ENOMEM; > - > - pcie = pci_host_bridge_priv(bridge); > - > - pcie->pdev = pdev; > + INIT_LIST_HEAD(&pcie->resources); > > ret = mobiveil_pcie_parse_dt(pcie); > if (ret) { > @@ -928,7 +560,10 @@ static int mobiveil_pcie_probe(struct platform_device *pdev) > return ret; > } > > - INIT_LIST_HEAD(&pcie->resources); > + /* allocate the PCIe port */ > + bridge = devm_pci_alloc_host_bridge(dev, 0); > + if (!bridge) > + return -ENOMEM; > > +static int mobiveil_pcie_probe(struct platform_device *pdev) > +{ > + struct mobiveil_pcie *pcie; > + struct device *dev = &pdev->dev; > + > + pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); > + if (!pcie) > + return -ENOMEM; > + > + pcie->pdev = pdev; > + > + return mobiveil_pcie_host_probe(pcie); > +} I think you need to pull the allocation of the host structure out into the main driver here, to keep both allocations together, otherwise the release function will free the mobiveil_pcie structure before freeing the pci_host_bridge if that is still in use. > + > +struct mobiveil_pcie { > + struct platform_device *pdev; > + struct list_head resources; These two should not be needed here, as they are already part of the pci_host_bridge structure. Arnd