From: Dave Jiang <dave.jiang@intel.com>
To: Robert Richter <rrichter@amd.com>
Cc: <linux-cxl@vger.kernel.org>, <dan.j.williams@intel.com>,
<ira.weiny@intel.com>, <vishal.l.verma@intel.com>,
<alison.schofield@intel.com>, <Jonathan.Cameron@huawei.com>,
<dave@stgolabs.net>
Subject: Re: [PATCH] cxl: Clarify root_port cleanup routine for cxl_qos_class_verify()
Date: Thu, 4 Jan 2024 11:26:56 -0700 [thread overview]
Message-ID: <21b78581-ab11-41bb-8cdf-455378c19e62@intel.com> (raw)
In-Reply-To: <ZZb3bjsxYT2Rik9e@rric.localdomain>
On 1/4/24 11:22, Robert Richter wrote:
> On 04.01.24 09:08:05, Dave Jiang wrote:
>> The current __free() call for root_port in cxl_qos_class_verify() depends
>> on 'struct device' to be the first member of 'struct cxl_port' and calls
>> put_device() directly with the root_port pointer passed in. Add a helper
>> function put_cxl_port() to handle the put_device() properly and avoid
>> future issues if the 'struct device' member moves.
>>
>> Suggested-by: Robert Richter <rrichter@amd.com>
>> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
>> ---
>> drivers/cxl/core/cdat.c | 12 +++++++++++-
>> 1 file changed, 11 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/cxl/core/cdat.c b/drivers/cxl/core/cdat.c
>> index cd84d87f597a..d6e64570032f 100644
>> --- a/drivers/cxl/core/cdat.c
>> +++ b/drivers/cxl/core/cdat.c
>> @@ -345,11 +345,21 @@ static void discard_dpa_perf(struct list_head *list)
>> }
>> DEFINE_FREE(dpa_perf, struct list_head *, if (!list_empty(_T)) discard_dpa_perf(_T))
>>
>> +static void put_cxl_port(struct cxl_port *port)
>> +{
>> + if (!port)
>> + return;
>> +
>> + put_device(&port->dev);
>> +}
>> +
>> +DEFINE_FREE(cxl_port, struct cxl_port *, put_cxl_port(_T))
>
> Let's put this in parallel with find_cxl_root() to make it part of the
> api for users of find_cxl_root() to cleanup.
Sure that makes sense. Will do that.
>
> Nit: remove the additional newline to have the same style for all uses
> of DEFINE_FREE() in this file.
I was contemplating that because checkpatch complained. But I guess if we are moving the function to where find_cxl_root() is then it won't matter.
>
> -Robert
>
>> +
>> static int cxl_qos_class_verify(struct cxl_memdev *cxlmd)
>> {
>> struct cxl_dev_state *cxlds = cxlmd->cxlds;
>> struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlds);
>> - struct cxl_port *root_port __free(put_device) = NULL;
>> + struct cxl_port *root_port __free(cxl_port) = NULL;
>> LIST_HEAD(__discard);
>> struct list_head *discard __free(dpa_perf) = &__discard;
>> int rc;
>>
>>
next prev parent reply other threads:[~2024-01-04 18:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-04 16:08 [PATCH] cxl: Clarify root_port cleanup routine for cxl_qos_class_verify() Dave Jiang
2024-01-04 17:05 ` Alison Schofield
2024-01-04 18:22 ` Robert Richter
2024-01-04 18:26 ` Dave Jiang [this message]
2024-01-04 19:52 ` Dan Williams
2024-01-08 11:45 ` Jonathan Cameron
2024-01-08 11:57 ` Robert Richter
2024-01-08 12:49 ` Jonathan Cameron
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=21b78581-ab11-41bb-8cdf-455378c19e62@intel.com \
--to=dave.jiang@intel.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=alison.schofield@intel.com \
--cc=dan.j.williams@intel.com \
--cc=dave@stgolabs.net \
--cc=ira.weiny@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=rrichter@amd.com \
--cc=vishal.l.verma@intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.