linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Suzuki K Poulose <suzuki.poulose@arm.com>
To: mathieu.poirier@linaro.org
Cc: coresight@lists.linaro.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, mike.leach@linaro.org
Subject: Re: [RFC PATCH 02/14] coresight: Introduce device access abstraction
Date: Thu, 30 Jul 2020 15:58:48 +0100	[thread overview]
Message-ID: <a841f0a4-e371-b5ba-c451-ec49d9f6e10b@arm.com> (raw)
In-Reply-To: <20200729195617.GB3073178@xps15>

On 07/29/2020 08:56 PM, Mathieu Poirier wrote:
> On Wed, Jul 22, 2020 at 06:20:28PM +0100, Suzuki K Poulose wrote:
>> We are about to introduce support for sysreg access to ETMv4.4+
>> component. Since there are generic routines that access the
>> registers (e.g, CS_LOCK/UNLOCK , claim/disclaim operations, timeout)
>> and in order to preserve the logic of these operations at a single place
>> we introduce an abstraction layer for the accesses to a given device.
>> This will also be helpful in consolidating the sysfs.attribute helpers,
>> that we define per driver.
> 
> Please drop the last sentence, it doesn't add to the current patch.
> 

Sure.

>> diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c
>> index e9c90f2de34a..38e9c03ab754 100644
>> --- a/drivers/hwtracing/coresight/coresight.c
>> +++ b/drivers/hwtracing/coresight/coresight.c
>> @@ -1387,6 +1387,54 @@ static int __init coresight_init(void)
>>   }

...

>>    * coresight_release_platform_data: Release references to the devices connected
>>    * to the output port of this device.
>> @@ -1451,6 +1499,7 @@ struct coresight_device *coresight_register(struct coresight_desc *desc)
>>   	csdev->type = desc->type;
>>   	csdev->subtype = desc->subtype;
>>   	csdev->ops = desc->ops;
>> +	csdev->access = desc->access;
>>   	csdev->orphan = false;
>>   
>>   	csdev->dev.type = &coresight_dev_type[desc->type];
>> diff --git a/include/linux/coresight.h b/include/linux/coresight.h
>> index 58fffdecdbfd..81ac708689f8 100644
>> --- a/include/linux/coresight.h
>> +++ b/include/linux/coresight.h
>> @@ -7,6 +7,7 @@
>>   #define _LINUX_CORESIGHT_H
>>   
>>   #include <linux/device.h>
>> +#include <linux/io.h>
>>   #include <linux/perf_event.h>
>>   #include <linux/sched.h>
>>   
>> @@ -114,6 +115,32 @@ struct coresight_platform_data {
>>   	struct coresight_connection *conns;
>>   };
>>   
>> +/**
>> + * struct csdev_access - Abstraction of a CoreSight device access.
>> + *
>> + * @no_iomem	: True if the device doesn't have iomem access.
>> + * @base	: When no_iomem == false, base address of the component
>> + * @read	: Read from the given "offset" of the given instance.
>> + * @write	: Write "val" to the given "offset".
>> + */
>> +struct csdev_access {
>> +	bool no_iomem;
> 
> I find the no_iomen to be difficult to understand, especially when prefixed with
> '!'.  Using "has_iomem" would be a lot more intuitive and would avoid extra
> mental gymnastics.


I agree. That was a bit of laziness in part, to limit the changes to the
existing drivers, where almost everyone, except the ETM would need to
simply use the MMIO approach. So, in order to keep those changes to
minimum, i.e, simply initialize the base, I used the inverted logic.
I will fix it.



>> +u32 coresight_relaxed_read32(struct coresight_device *csdev, u32 offset);
>> +u32 coresight_read32(struct coresight_device *csdev, u32 offset);
>> +void coresight_write32(struct coresight_device *csdev, u32 val, u32 offset);
>> +void coresight_relaxed_write32(struct coresight_device *csdev,
>> +			       u32 val,
>> +			       u32 offset);
>> +
> 
> Why are the 64 bit version outside of the #ifdef and the 32 bit within?

Mistake ;-). I will address all of the comments above in my next version.

...


>> +static inline u64 coresight_read64(struct coresight_device *csdev, u32 offset)
>> +{
>> +	WARN_ON_ONCE(1);
> 
> Not sure about the motivation behind using WARN_ON_ONCE(), and only in the read
> functions.  I would simply return 0 here.  After all if CONFIG_CORESIGHT is not
> defined they won't make it very far.
> 

If someone is reading the values, they might do something with the
value, i.e, make a decision when they shouldn't. This is just to prevent
such cases.

>> +	return 0;
>> +}
>> +
>> +static inline void coresight_relaxed_write64(struct coresight_device *csdev,
>> +					     u64 val,
>> +					     u32 offset)
>> +{
>> +}
>> +
>> +static inline void coresight_write64(struct coresight_device *csdev, u64 val, u32 offset)
>> +{
>> +}
>> +
>>   #endif
> 
> I will likely come back to this patch once I have reviewed the rest of the set.
> 

Sure. I am looking for thoughts on the proposed API (not ABI) changes,
as they are quite significant and invasive changes in the code, without
much functionality changes.


Thank you for the review !

Suzuki

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-07-30 14:55 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-22 17:20 [RFC PATCH 00/14] coresight: Support for ETMv4.4 system instructions Suzuki K Poulose
2020-07-22 17:20 ` [RFC PATCH 01/14] coresight: etm4x: Skip save/restore before device registration Suzuki K Poulose
2020-07-29 18:01   ` Mathieu Poirier
2020-07-30 14:45     ` Suzuki K Poulose
2020-07-22 17:20 ` [RFC PATCH 02/14] coresight: Introduce device access abstraction Suzuki K Poulose
2020-07-29 19:56   ` Mathieu Poirier
2020-07-30 14:58     ` Suzuki K Poulose [this message]
2020-07-22 17:20 ` [RFC PATCH 03/14] coresight: tpiu: Use coresight " Suzuki K Poulose
2020-07-29 21:01   ` Mathieu Poirier
2020-07-31 11:36     ` Suzuki K Poulose
2020-07-22 17:20 ` [RFC PATCH 04/14] coresight: etm4x: Free up argument of etm4_init_arch_data Suzuki K Poulose
2020-07-30 17:31   ` Mathieu Poirier
2020-07-31  9:39     ` Suzuki K Poulose
2020-07-22 17:20 ` [RFC PATCH 05/14] coresight: Convert coresight_timeout to use access abstraction Suzuki K Poulose
2020-07-30 18:00   ` Mathieu Poirier
2020-07-22 17:20 ` [RFC PATCH 06/14] coresight: Convert claim and lock operations to use access wrappers Suzuki K Poulose
2020-07-30 19:54   ` Mathieu Poirier
2020-07-31  9:46     ` Suzuki K Poulose
2020-07-22 17:20 ` [RFC PATCH 07/14] coresight: etm4x: Always read the registers on the host CPU Suzuki K Poulose
2020-07-30 19:56   ` Mathieu Poirier
2020-07-22 17:20 ` [RFC PATCH 08/14] coresight: etm4x: Convert all register accesses Suzuki K Poulose
2020-07-30 20:20   ` Mathieu Poirier
2020-07-31  9:49     ` Suzuki K Poulose
2020-07-22 17:20 ` [RFC PATCH 09/14] coresight: etm4x: Add sysreg access helpers Suzuki K Poulose
2020-07-30 21:41   ` Mathieu Poirier
2020-07-31  9:51     ` Suzuki K Poulose
2020-07-22 17:20 ` [RFC PATCH 10/14] coresight: etm4x: Define DEVARCH register fields Suzuki K Poulose
2020-07-22 17:20 ` [RFC PATCH 11/14] coresight: etm4x: Detect system register access support Suzuki K Poulose
2020-07-22 17:20 ` [RFC PATCH 12/14] coresight: etm4x: Refactor probing routine Suzuki K Poulose
2020-07-22 17:20 ` [RFC PATCH 13/14] coresight: etm4x: Add support for sysreg only devices Suzuki K Poulose
2020-07-22 17:20 ` [RFC PATCH 14/14] dts: bindings: coresight: ETMv4.4 system register access only units Suzuki K Poulose
2020-07-23 17:27   ` Rob Herring
2020-07-29 17:20   ` Mathieu Poirier
2020-07-30 16:38     ` Suzuki K Poulose
2020-08-10 20:14       ` Mathieu Poirier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a841f0a4-e371-b5ba-c451-ec49d9f6e10b@arm.com \
    --to=suzuki.poulose@arm.com \
    --cc=coresight@lists.linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=mike.leach@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).