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 X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B5D9C10F11 for ; Mon, 22 Apr 2019 17:16:27 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 19DFE20684 for ; Mon, 22 Apr 2019 17:16:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="riOWgbO4"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="fsvnORW7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 19DFE20684 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UVaWfn1d88nEn0UIEyD72PEjR0On5y6k/36vqxFCE3M=; b=riOWgbO48QGF5b ZsuxetTpMkSCu1VhzsMMYBBnTNKT7c5DU3Onmeu0BRh9aLLPnR8GGtVPcSEi8i1P8nIv5x+u0X8fG QYr72MPFN5WU6HJSqtPBYGvlcrkldsMXdl841jzF08vOV8ePkaUkrGAFRO0AjkeTV104xAlKv4g8z yEyigesehy4cZL+pnLS+xT0pfg0reevXSika93eft9zcTx7rpSrbFt6Zr5Mw8jUj5cAfzkzMG+cSl RU67tx/mYDtgz+z8RYbQBUSrDd9O3dJbqpPxH/QlisZpUwLJLkwiT8HwZAyXHQK0xSC3XnZfENuuH KdomA8ShcY6w/kpxYM5A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hIcYC-0002mE-RG; Mon, 22 Apr 2019 17:16:16 +0000 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hIcY8-0002lb-O8 for linux-arm-kernel@lists.infradead.org; Mon, 22 Apr 2019 17:16:14 +0000 Received: by mail-pg1-x543.google.com with SMTP id y3so6128596pgk.12 for ; Mon, 22 Apr 2019 10:16:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=wVloC1KUfn/SdUdelAyuOxL0Ryse20nIZtNqvnIv+2o=; b=fsvnORW71ekt3bcqcPAi1ZNx00lM/vLDDamcclpAWvbCCNennkVT+PwfvBaQOExD7V Z8dakc+2zaXaOtPdgouwBhshIRuoRSUFtqY7k4zJj2CMtgcp+4jIb35ENRad/ubJTpdk AvnTiVKlmldWZIpccbQQFPS4ZVjzBY0MoJIz12I501U+j7HaT/juZXunxEyvxqW40O+a RUC/4G9WF2+E0coL4o26yCynbi1VKHaXIyDser7iSF/tB6CLPBaIqz4ltfaxalyV9CqY WSx9Jg+Hbyuk3cWitU0LER7mslQVpCsYyRS1agZdSUaEVYbPw3YAGpz7RNgj3aU155k1 5p3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=wVloC1KUfn/SdUdelAyuOxL0Ryse20nIZtNqvnIv+2o=; b=IhQid6f+129dL4/hiLrQoB3xftzfresxABk5JavVA9sc42exMAiQvIr+I2G9AMnkbM q10muM4Y3DcECJabY3s0eicPV0+IC6haYJaVh7WMQwXaujctQE/sI43C1aTP/uzND0Ml vIcep7ZrTTfkfVtacvrH6ibSmINojyUA3jS2vaI3j5TQ5ezJwLTjn8b0ecKadDa1/pvN gHHvgoE/sefxbS3gxmlvYELtx/iwHYJKligzL6aqxTm4b/xuBbJckmuavg+c0ktwkc0p 6aKzz4b1/jbTJPNSdqO+aKno7hXMMJW4BwKO6djMPH0z+R4QquKaCDNaYOpl0c/QAxZX I7rw== X-Gm-Message-State: APjAAAXNAQZx+GWQIl6D+NrkBvCtmhkmCOLoMg+WGyYi/DGQuU0cwNDB ANj5Ao8SG5NZMwMTFnyT9SeIQxS5QVc= X-Google-Smtp-Source: APXvYqz4l8rZulhpDnaZGybdlXh+BB5VsEr2FUIl5pZ9/WvlCNNLYJgHnAknTbwEJasCtP07GhQCYg== X-Received: by 2002:aa7:814e:: with SMTP id d14mr21873993pfn.101.1555953371115; Mon, 22 Apr 2019 10:16:11 -0700 (PDT) Received: from xps15 (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id a6sm24895202pgd.67.2019.04.22.10.16.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Apr 2019 10:16:10 -0700 (PDT) Date: Mon, 22 Apr 2019 11:16:08 -0600 From: Mathieu Poirier To: Suzuki K Poulose Subject: Re: [PATCH v2 25/36] coresight: Rearrange platform data probing Message-ID: <20190422171608.GB6402@xps15> References: <1555344260-12375-1-git-send-email-suzuki.poulose@arm.com> <1555344260-12375-26-git-send-email-suzuki.poulose@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1555344260-12375-26-git-send-email-suzuki.poulose@arm.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190422_101612_802918_E10FE3A2 X-CRM114-Status: GOOD ( 22.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: coresight@lists.linaro.org, rjw@rjwysocki.net, linux-kernel@vger.kernel.org, robert.walker@arm.com, linux-arm-kernel@lists.infradead.org, mike.leach@linaro.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Apr 15, 2019 at 05:04:08PM +0100, Suzuki K Poulose wrote: > We are about to introduce methods to clean up the platform data > as we switch to tracking the device reference from "name" to "fwnode > handles" for device connections. This requires us to drop the fwnode > handle references when the data is no longer required - i.e, when > the device probe fails or the device gets unregistered. > > In order to consolidate the invocation of the cleanup, we delay the > platform probing to the very last minute, possibly before invoking > the coresight_register. Then, we leave the coresight core code to > do the clean up. i.e, if the coresight_register fails, it takes > care of freeing the data. Otherwise, coresight_unregister will > do the necessary operations. > > Cc: Mathieu Poirier > Signed-off-by: Suzuki K Poulose > --- > drivers/hwtracing/coresight/coresight-catu.c | 14 +++++++------- > drivers/hwtracing/coresight/coresight-etb10.c | 10 +++++----- > drivers/hwtracing/coresight/coresight-etm3x.c | 12 +++++++----- > drivers/hwtracing/coresight/coresight-etm4x.c | 10 +++++----- > drivers/hwtracing/coresight/coresight-funnel.c | 10 +++++----- > drivers/hwtracing/coresight/coresight-replicator.c | 12 +++++++----- > drivers/hwtracing/coresight/coresight-stm.c | 11 +++++++---- > drivers/hwtracing/coresight/coresight-tmc.c | 16 ++++++++-------- > drivers/hwtracing/coresight/coresight-tpiu.c | 9 ++++----- > 9 files changed, 55 insertions(+), 49 deletions(-) > > diff --git a/drivers/hwtracing/coresight/coresight-catu.c b/drivers/hwtracing/coresight/coresight-catu.c > index 03f5b95..f249be6 100644 > --- a/drivers/hwtracing/coresight/coresight-catu.c > +++ b/drivers/hwtracing/coresight/coresight-catu.c > @@ -505,13 +505,6 @@ static int catu_probe(struct amba_device *adev, const struct amba_id *id) > struct device *dev = &adev->dev; > void __iomem *base; > > - pdata = coresight_get_platform_data(dev); > - if (IS_ERR(pdata)) { > - ret = PTR_ERR(pdata); > - goto out; > - } > - dev->platform_data = pdata; > - > drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); > if (!drvdata) { > ret = -ENOMEM; > @@ -544,6 +537,13 @@ static int catu_probe(struct amba_device *adev, const struct amba_id *id) > if (ret) > goto out; > > + pdata = coresight_get_platform_data(dev); > + if (IS_ERR(pdata)) { > + ret = PTR_ERR(pdata); > + goto out; > + } > + dev->platform_data = pdata; > + > drvdata->base = base; > catu_desc.pdata = pdata; > catu_desc.dev = dev; > diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c > index 91a5d7a..e5b46c7 100644 > --- a/drivers/hwtracing/coresight/coresight-etb10.c > +++ b/drivers/hwtracing/coresight/coresight-etb10.c > @@ -682,11 +682,6 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id) > struct resource *res = &adev->res; > struct coresight_desc desc = { 0 }; > > - pdata = coresight_get_platform_data(dev); > - if (IS_ERR(pdata)) > - return PTR_ERR(pdata); > - adev->dev.platform_data = pdata; > - > drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); > if (!drvdata) > return -ENOMEM; > @@ -718,6 +713,11 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id) > if (!drvdata->buf) > return -ENOMEM; > > + pdata = coresight_get_platform_data(dev); > + if (IS_ERR(pdata)) > + return PTR_ERR(pdata); > + adev->dev.platform_data = pdata; > + > desc.type = CORESIGHT_DEV_TYPE_SINK; > desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_BUFFER; > desc.ops = &etb_cs_ops; > diff --git a/drivers/hwtracing/coresight/coresight-etm3x.c b/drivers/hwtracing/coresight/coresight-etm3x.c > index 101fb01..f2d4616 100644 > --- a/drivers/hwtracing/coresight/coresight-etm3x.c > +++ b/drivers/hwtracing/coresight/coresight-etm3x.c > @@ -795,11 +795,6 @@ static int etm_probe(struct amba_device *adev, const struct amba_id *id) > if (!drvdata) > return -ENOMEM; > > - pdata = coresight_get_platform_data(dev); > - if (IS_ERR(pdata)) > - return PTR_ERR(pdata); > - > - adev->dev.platform_data = pdata; > drvdata->use_cp14 = fwnode_property_read_bool(dev->fwnode, "arm,cp14"); > dev_set_drvdata(dev, drvdata); > > @@ -849,6 +844,13 @@ static int etm_probe(struct amba_device *adev, const struct amba_id *id) > etm_init_trace_id(drvdata); > etm_set_default(&drvdata->config); > > + pdata = coresight_get_platform_data(dev); > + if (IS_ERR(pdata)) { > + ret = PTR_ERR(pdata); > + goto err_arch_supported; > + } > + adev->dev.platform_data = pdata; > + > desc.type = CORESIGHT_DEV_TYPE_SOURCE; > desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_PROC; > desc.ops = &etm_cs_ops; > diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c > index 7ff0989..7c53fb2 100644 > --- a/drivers/hwtracing/coresight/coresight-etm4x.c > +++ b/drivers/hwtracing/coresight/coresight-etm4x.c > @@ -981,11 +981,6 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id) > if (!drvdata) > return -ENOMEM; > > - pdata = coresight_get_platform_data(dev); > - if (IS_ERR(pdata)) > - return PTR_ERR(pdata); > - adev->dev.platform_data = pdata; > - > dev_set_drvdata(dev, drvdata); > > /* Validity for the resource is already checked by the AMBA core */ > @@ -1028,6 +1023,11 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id) > etm4_init_trace_id(drvdata); > etm4_set_default(&drvdata->config); > > + pdata = coresight_get_platform_data(dev); > + if (IS_ERR(pdata)) > + return PTR_ERR(pdata); Here you need to "goto err_arch_supported" instead of returning. > + adev->dev.platform_data = pdata; > + > desc.type = CORESIGHT_DEV_TYPE_SOURCE; > desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_PROC; > desc.ops = &etm4_cs_ops; > diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c > index 61a9e01..38af045 100644 > --- a/drivers/hwtracing/coresight/coresight-funnel.c > +++ b/drivers/hwtracing/coresight/coresight-funnel.c > @@ -186,11 +186,6 @@ static int funnel_probe(struct amba_device *adev, const struct amba_id *id) > struct resource *res = &adev->res; > struct coresight_desc desc = { 0 }; > > - pdata = coresight_get_platform_data(dev); > - if (IS_ERR(pdata)) > - return PTR_ERR(pdata); > - adev->dev.platform_data = pdata; > - > drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); > if (!drvdata) > return -ENOMEM; > @@ -211,6 +206,11 @@ static int funnel_probe(struct amba_device *adev, const struct amba_id *id) > drvdata->base = base; > pm_runtime_put(&adev->dev); > > + pdata = coresight_get_platform_data(dev); > + if (IS_ERR(pdata)) > + return PTR_ERR(pdata); > + adev->dev.platform_data = pdata; > + > desc.type = CORESIGHT_DEV_TYPE_LINK; > desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_MERG; > desc.ops = &funnel_cs_ops; > diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c > index 939f20d..8fbc028 100644 > --- a/drivers/hwtracing/coresight/coresight-replicator.c > +++ b/drivers/hwtracing/coresight/coresight-replicator.c > @@ -179,11 +179,6 @@ static int replicator_probe(struct device *dev, struct resource *res) > struct coresight_desc desc = { 0 }; > void __iomem *base; > > - pdata = coresight_get_platform_data(dev); > - if (IS_ERR(pdata)) > - return PTR_ERR(pdata); > - dev->platform_data = pdata; > - > drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); > if (!drvdata) > return -ENOMEM; > @@ -209,6 +204,13 @@ static int replicator_probe(struct device *dev, struct resource *res) > desc.groups = replicator_groups; > } > > + pdata = coresight_get_platform_data(dev); > + if (IS_ERR(pdata)) { > + ret = PTR_ERR(pdata); > + goto out_disable_clk; > + } > + dev->platform_data = pdata; > + > dev_set_drvdata(dev, drvdata); > desc.type = CORESIGHT_DEV_TYPE_LINK; > desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_SPLIT; > diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c > index 734227f..5c7fc4a 100644 > --- a/drivers/hwtracing/coresight/coresight-stm.c > +++ b/drivers/hwtracing/coresight/coresight-stm.c > @@ -810,10 +810,6 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id) > size_t bitmap_size; > struct coresight_desc desc = { 0 }; > > - pdata = coresight_get_platform_data(dev); > - if (IS_ERR(pdata)) > - return PTR_ERR(pdata); > - adev->dev.platform_data = pdata; > drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); > if (!drvdata) > return -ENOMEM; > @@ -866,6 +862,13 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id) > return -EPROBE_DEFER; > } > > + pdata = coresight_get_platform_data(dev); > + if (IS_ERR(pdata)) { > + ret = PTR_ERR(pdata); > + goto stm_unregister; > + } > + adev->dev.platform_data = pdata; > + > desc.type = CORESIGHT_DEV_TYPE_SOURCE; > desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE; > desc.ops = &stm_cs_ops; > diff --git a/drivers/hwtracing/coresight/coresight-tmc.c b/drivers/hwtracing/coresight/coresight-tmc.c > index 02c5cb5..94d3ebf 100644 > --- a/drivers/hwtracing/coresight/coresight-tmc.c > +++ b/drivers/hwtracing/coresight/coresight-tmc.c > @@ -396,13 +396,6 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id) > struct resource *res = &adev->res; > struct coresight_desc desc = { 0 }; > > - pdata = coresight_get_platform_data(dev); > - if (IS_ERR(pdata)) { > - ret = PTR_ERR(pdata); > - goto out; > - } > - adev->dev.platform_data = pdata; > - > ret = -ENOMEM; > drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); > if (!drvdata) > @@ -430,7 +423,6 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id) > else > drvdata->size = readl_relaxed(drvdata->base + TMC_RSZ) * 4; > > - desc.pdata = pdata; > desc.dev = dev; > desc.groups = coresight_tmc_groups; > desc.name = dev_name(dev); > @@ -461,6 +453,14 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id) > goto out; > } > > + pdata = coresight_get_platform_data(dev); > + if (IS_ERR(pdata)) { > + ret = PTR_ERR(pdata); > + goto out; > + } > + adev->dev.platform_data = pdata; > + desc.pdata = pdata; > + > drvdata->csdev = coresight_register(&desc); > if (IS_ERR(drvdata->csdev)) { > ret = PTR_ERR(drvdata->csdev); > diff --git a/drivers/hwtracing/coresight/coresight-tpiu.c b/drivers/hwtracing/coresight/coresight-tpiu.c > index 792f1d6..39a509f 100644 > --- a/drivers/hwtracing/coresight/coresight-tpiu.c > +++ b/drivers/hwtracing/coresight/coresight-tpiu.c > @@ -121,11 +121,6 @@ static int tpiu_probe(struct amba_device *adev, const struct amba_id *id) > struct resource *res = &adev->res; > struct coresight_desc desc = { 0 }; > > - pdata = coresight_get_platform_data(dev); > - if (IS_ERR(pdata)) > - return PTR_ERR(pdata); > - dev->platform_data = pdata; > - > drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); > if (!drvdata) > return -ENOMEM; > @@ -148,6 +143,10 @@ static int tpiu_probe(struct amba_device *adev, const struct amba_id *id) > /* Disable tpiu to support older devices */ > tpiu_disable_hw(drvdata); > > + pdata = coresight_get_platform_data(dev); > + if (IS_ERR(pdata)) > + return PTR_ERR(pdata); > + dev->platform_data = pdata; > > desc.type = CORESIGHT_DEV_TYPE_SINK; > desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_PORT; > -- > 2.7.4 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel