Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp55480pxx; Wed, 28 Oct 2020 18:00:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzMbx0GmI86s+lmZeFAq6hyXSc688+PkKghpv651NKGO6LetEaIaL7QE+rYOmz5WvyMCiU X-Received: by 2002:a17:906:a891:: with SMTP id ha17mr1723047ejb.524.1603933254742; Wed, 28 Oct 2020 18:00:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603933254; cv=none; d=google.com; s=arc-20160816; b=RGs91XLWs89znzFUVm9EalpPCjy8Pnp0kf9iM/IDZihpExo3q2WCcjLT+czeAAdREp 7zEAVJzGywmhQiVYewxI2rXMa9q3xTyx+YHCq/Yu/MFC9hBxpdwk3gpFkihr2/Ixw5cN pXSIa05jpTSCjazPRNS16iifuKZJpKkCJOCjr/kXuo6xZxepwZJYILuycT658ia2kdDD rJDvEWKCg2sN6+xcuy/4eUZwAQ3+qylItAASlNLWFPBhAFFa0PFQ6OjPfvTwFCHBf5Vv lG/AMVOybWAkyW5yxSK3ba708HKJVaiunrfXaB2KsOJ3nyx6VU7jHfNuZ7rVK3M1gj2+ fIDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=/shLaSx89EmUCpSlajm7L1qrtkVV0vvuH5zfkR+kAUM=; b=nhldx/WaEVJcay93/fTj+lSk8BP7SpI9QmqHBY4FbC/CwS92D12O0MdUBGZKYWazYk NCK/AoV5HcuyeYlo/xyZXZ+cy1L7VUV6Kfurg63QEnwobyUGem/T29aMex9qqNFYGrG4 2KyplZ9VnobHFhCF4iKEPcYjJX9VaEbHkfkRAP3rT///ARnU00p7VmCpNccAFpd/YzvD MHni6RIU2vOHx6y2kr5H7ZM4BrclHFy58mAykADXVZar4z5VIgLXTFgB822ZytvbKOFp qH2jubnKG66TdhaILImoWHNcZpPD9xtF6l4XpwwkKmZtwyGP4kRp4A4mIaIJs9Rx/PpQ kjpg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id op13si696354ejb.645.2020.10.28.18.00.32; Wed, 28 Oct 2020 18:00:54 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730485AbgJ1WKR (ORCPT + 99 others); Wed, 28 Oct 2020 18:10:17 -0400 Received: from foss.arm.com ([217.140.110.172]:39094 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730462AbgJ1WKK (ORCPT ); Wed, 28 Oct 2020 18:10:10 -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 E5FA51763; Wed, 28 Oct 2020 15:10:09 -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 049BA3F68F; Wed, 28 Oct 2020 15:10:08 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: mathieu.poirier@linaro.org, mike.leach@linaro.org, coresight@lists.linaro.org, linux-kernel@vger.kernel.org, Suzuki K Poulose Subject: [PATCH v3 08/26] coresight: tpiu: Prepare for using coresight device access abstraction Date: Wed, 28 Oct 2020 22:09:27 +0000 Message-Id: <20201028220945.3826358-10-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20201028220945.3826358-1-suzuki.poulose@arm.com> References: <20201028220945.3826358-1-suzuki.poulose@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Prepare the TPIU driver to make use of the CoreSight device access abstraction layer. The driver touches the device even before the coresight device is registered. Thus we could be accessing the devices without a csdev. As we are about to use the abstraction layer for accessing the device, pass in the access directly to avoid having to deal with the un-initialised 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 dfa3b91d0281..98c4a029854c 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 = CSDEV_ACCESS_IOMEM(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