Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp680733ybh; Wed, 22 Jul 2020 10:23:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxL21u5eHhv0La5LG2PeyKpG3zG97wS+1uIqBopDyzsT4fBAMDkl28kgr7j4XOToGysuVzO X-Received: by 2002:a17:906:7d9:: with SMTP id m25mr575812ejc.25.1595438606475; Wed, 22 Jul 2020 10:23:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595438606; cv=none; d=google.com; s=arc-20160816; b=K87P+BIzaoUoJNJhZCTcBzKlXJDBAU9pHbXwPXIWY2o3xzCzdbbJ6ExormKBVHS4mi sCUtRiS2s9tZZXAekoeSt1KuNWObxIDRPUkD/kEm0ai8sAirfOe/pujAsXr68n491eEu CLItlWSSY4dlSYQVxTGDU7te5EIkBNNiXjYOZWdiQCAIIWPqqvMQTEhVEcDa0X2O6OUM /5wNbyw7R5Tckd9FZ+/MCR3ofq48Wbo7qPDgxBs96G86zdqff3R2YJ861PzzVTz6ePIR sGg3gG7GvyDGXhgJ+wkGDIZAbdpaSK8ZlKwUzhk591wiGnRU0clG+2xMgYfqKsqwk7rg WR2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=i9YD2EolN9EMhQm+NYbtGAYrotrBboSEGvt4QHhS4k4=; b=HxHXl59GsN46osT3hEiz0twkp8qGrZxnrkK/Y5Gf3wSMKTxt1U8tRF0w+B+d3VEbHb JLXRYhHhTYt5h2RvPuV1HyMkMw5hf/kplV5SnUmFvNDX9eh1lSI1GH9BV36bqkkRyQfR +VrG3pEYwy3pmaLrItY7RMBG9TdLuyEHS7zUl1A6XumTMRO7Vdf6CqHAWjd5GyE91QMh ZwzR8QW/Xa2sg2QI3stp/R2Hq1B0Uer0mTqkt9v2Zq2GEKZ8Iu37y+tGE/JtW4s1B+/z cVPntZqDBYXFyqHpilB6E22ADU5eEJfLnH9lU30l0yWbkCdsjsJe/anOuDmJA9DgL6CZ LqzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o13si355303ejb.166.2020.07.22.10.23.04; Wed, 22 Jul 2020 10:23:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731695AbgGVRVD (ORCPT + 99 others); Wed, 22 Jul 2020 13:21:03 -0400 Received: from foss.arm.com ([217.140.110.172]:59966 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731271AbgGVRU7 (ORCPT ); Wed, 22 Jul 2020 13:20:59 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 09E11113E; Wed, 22 Jul 2020 10:20:59 -0700 (PDT) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 254CE3F66F; Wed, 22 Jul 2020 10:20:58 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, mike.leach@linaro.org, mathieu.poirier@linaro.org, coresight@lists.linaro.org, Suzuki K Poulose Subject: [RFC PATCH 03/14] coresight: tpiu: Use coresight device access abstraction Date: Wed, 22 Jul 2020 18:20:29 +0100 Message-Id: <20200722172040.1299289-4-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200722172040.1299289-1-suzuki.poulose@arm.com> References: <20200722172040.1299289-1-suzuki.poulose@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org TPIU driver access the device before the coresight device is registered. In other words, before the drvdata->csdev is valid. Thus, we need to make sure that the csdev_access is valid for both the invocations. Switch to using the csdev_access directly instead of relying on availability of drvdata->csdev. Cc: Mathieu Poirier Cc: Mike Leach Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-tpiu.c | 30 +++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-tpiu.c b/drivers/hwtracing/coresight/coresight-tpiu.c index 7ef7649f48ad..84ff4bf5d3b8 100644 --- a/drivers/hwtracing/coresight/coresight-tpiu.c +++ b/drivers/hwtracing/coresight/coresight-tpiu.c @@ -60,49 +60,45 @@ struct tpiu_drvdata { struct coresight_device *csdev; }; -static void tpiu_enable_hw(struct tpiu_drvdata *drvdata) +static void tpiu_enable_hw(struct csdev_access *csa) { - CS_UNLOCK(drvdata->base); + CS_UNLOCK(csa->base); /* TODO: fill this up */ - CS_LOCK(drvdata->base); + CS_LOCK(csa->base); } static int tpiu_enable(struct coresight_device *csdev, u32 mode, void *__unused) { - struct tpiu_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); - - tpiu_enable_hw(drvdata); + tpiu_enable_hw(&csdev->access); atomic_inc(csdev->refcnt); dev_dbg(&csdev->dev, "TPIU enabled\n"); return 0; } -static void tpiu_disable_hw(struct tpiu_drvdata *drvdata) +static void tpiu_disable_hw(struct csdev_access *csa) { - CS_UNLOCK(drvdata->base); + CS_UNLOCK(csa->base); /* Clear formatter and stop on flush */ - writel_relaxed(FFCR_STOP_FI, drvdata->base + TPIU_FFCR); + csdev_access_relaxed_write32(csa, FFCR_STOP_FI, TPIU_FFCR); /* Generate manual flush */ - writel_relaxed(FFCR_STOP_FI | FFCR_FON_MAN, drvdata->base + TPIU_FFCR); + csdev_access_relaxed_write32(csa, FFCR_STOP_FI | FFCR_FON_MAN, TPIU_FFCR); /* Wait for flush to complete */ - coresight_timeout(drvdata->base, TPIU_FFCR, FFCR_FON_MAN_BIT, 0); + coresight_timeout(csa->base, TPIU_FFCR, FFCR_FON_MAN_BIT, 0); /* Wait for formatter to stop */ - coresight_timeout(drvdata->base, TPIU_FFSR, FFSR_FT_STOPPED_BIT, 1); + coresight_timeout(csa->base, TPIU_FFSR, FFSR_FT_STOPPED_BIT, 1); - CS_LOCK(drvdata->base); + CS_LOCK(csa->base); } static int tpiu_disable(struct coresight_device *csdev) { - struct tpiu_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); - if (atomic_dec_return(csdev->refcnt)) return -EBUSY; - tpiu_disable_hw(drvdata); + tpiu_disable_hw(&csdev->access); dev_dbg(&csdev->dev, "TPIU disabled\n"); return 0; @@ -152,7 +148,7 @@ static int tpiu_probe(struct amba_device *adev, const struct amba_id *id) desc.access.base = base; /* Disable tpiu to support older devices */ - tpiu_disable_hw(drvdata); + tpiu_disable_hw(&desc.access); pdata = coresight_get_platform_data(dev); if (IS_ERR(pdata)) -- 2.24.1