Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp591284pxb; Thu, 19 Nov 2020 08:50:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJyGf+ptRerce3tB1DwL+19Ec5z341UV8wbj64jLH5WgjFhno0NyXiJiTDJer3sOp970WcKa X-Received: by 2002:a17:906:4dd3:: with SMTP id f19mr27425165ejw.364.1605804656439; Thu, 19 Nov 2020 08:50:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605804656; cv=none; d=google.com; s=arc-20160816; b=Ntp93hqIQo5ZOejizNUJLIHMP8IvQh6021lKSxhdPnR2yC1JBdEr/RS5wUGlZohxU4 TSyRjC9Kf2jeQnqMM5+YLDNFjnB6F89dTRhVwJNtGBV2EXSdF3T2AKz4Aft5BCp1wYtK McBnHCI0Bn3IpnzSWB8hKjZx8jVOk5X9fGjC+uLAU31c8vfAdx3Ba1loQmOu0hxGPqbB KMUC1X4wE2CyMwyGq6LPqqHNgLI3l3jOj28lSYHkBCHi0rLMJVBoUOJ4oFYWI0inV4SO YD7Hqn4qb/v4Hjrz4c2WwmkkUZcbH6rIHl51C0sBRoJjEjsL2Vi0t1yo9gs1dZ2XuY7H XW3A== 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=ws9lC7PpJzgpaWr4n1gbQYNgP8Qo6QfoUGaKktWe3Rs=; b=lD86bi0dIOPnsbyklWCJAEiSMbDBtm/kNigGS7ht7UFc5uIljOnfRmRpfvq16lfe/o a2LnFmJgE4SZQz2dZ7uFX5Rc7fOpjat6ZGlQlKeIMlX5Q40bMoPOhSfz23aCVgSUDPTs kfxo+rohNqy0Kv7L20Ego1FZ5MidOR+N3+e3QitEDm4BhydXlOnrRUJNQMg+F2M0mCwp fR1qE+b2ao4UGb3SU8ys6ruj0Fx5FskNJtVTXNdaFeASsutOS6rgWSxg6ieqQlbnb5Nq tWMXQDMAw4qpheqARSFslousOM8LkyDsvPuDcrsqOJYIRUswth57fOpM8WgvBGbm9RZ5 85Ew== 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 u12si179493edp.98.2020.11.19.08.50.33; Thu, 19 Nov 2020 08:50:56 -0800 (PST) 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 S1729145AbgKSQqK (ORCPT + 99 others); Thu, 19 Nov 2020 11:46:10 -0500 Received: from foss.arm.com ([217.140.110.172]:34456 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728324AbgKSQqH (ORCPT ); Thu, 19 Nov 2020 11:46:07 -0500 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 1932615DB; Thu, 19 Nov 2020 08:46:07 -0800 (PST) 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 F33FD3F719; Thu, 19 Nov 2020 08:46:05 -0800 (PST) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: mathieu.poirier@linaro.org, mike.leach@linaro.org, linux-kernel@vger.kernel.org, anshuman.khandual@arm.com, jonathan.zhouwen@huawei.com, coresight@lists.linaro.org, Suzuki K Poulose Subject: [PATCH v4 04/25] coresight: tpiu: Prepare for using coresight device access abstraction Date: Thu, 19 Nov 2020 16:45:26 +0000 Message-Id: <20201119164547.2982871-5-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20201119164547.2982871-1-suzuki.poulose@arm.com> References: <20201119164547.2982871-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: Mike Leach Reviewed-by: Mathieu Poirier 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