All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Davidlohr Bueso <dave@stgolabs.net>
Cc: <linux-cxl@vger.kernel.org>, <peterz@infradead.org>,
	<mingo@redhat.com>, <acme@kernel.org>, <mark.rutland@arm.com>,
	<will@kernel.org>, <dan.j.williams@intel.com>,
	<bwidawsk@kernel.org>, <ira.weiny@intel.com>,
	<vishal.l.verma@intel.com>, <alison.schofield@intel.com>,
	<linuxarm@huawei.com>, <linux-perf-users@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/4] cxl/pci: Find and register CXL PMU devices
Date: Tue, 21 Mar 2023 14:48:13 +0000	[thread overview]
Message-ID: <20230321144813.00002c19@Huawei.com> (raw)
In-Reply-To: <20230307023656.cyntxctzqgpam5u3@offworld>

On Mon, 6 Mar 2023 18:36:56 -0800
Davidlohr Bueso <dave@stgolabs.net> wrote:

> On Fri, 03 Mar 2023, Jonathan Cameron wrote:
> 
> >+int devm_cxl_cpmu_add(struct device *parent, struct cxl_cpmu_regs *regs, int index)
> >+{
> >+	struct cxl_cpmu *cpmu;
> >+	struct device *dev;
> >+	int rc;
> >+
> >+	cpmu = kzalloc(sizeof(*cpmu), GFP_KERNEL);
> >+	if (!cpmu)
> >+		return -ENOMEM;
> >+
> >+	cpmu->base = regs->cpmu;
> >+	dev = &cpmu->dev;
> >+	device_initialize(dev);
> >+	device_set_pm_not_required(dev);
> >+	dev->parent = parent;
> >+	dev->bus = &cxl_bus_type;
> >+	dev->type = &cxl_cpmu_type;
> >+	rc = ida_alloc(&cpmu_ida, GFP_KERNEL);
> >+	if (rc < 0)
> >+		goto err;  
> 
> Probably better to do the ida_alloc after the cpmu allocation above, before
> arming the dev.

Hi Davidlohr,

There was a bug hiding here I think as the device_put() could cause the ida
to be freed even though the ida_alloc() failed.

Good you pointed out this oddity.

Moving the ida_alloc earlier requires an explicit free of the cpmu
but that's easy enough to locally to that if (rc < 0)

Thanks,

Jonathan

  reply	other threads:[~2023-03-21 14:48 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-03 17:50 [PATCH 0/4] CXL 3.0 Performance Monitoring Unit support Jonathan Cameron
2023-03-03 17:50 ` [PATCH 1/4] cxl: Add function to count regblocks of a given type Jonathan Cameron
2023-03-07  2:28   ` Davidlohr Bueso
2023-03-03 17:50 ` [PATCH 2/4] cxl/pci: Find and register CXL PMU devices Jonathan Cameron
2023-03-03 18:25   ` Dave Jiang
2023-03-04  2:46   ` kernel test robot
2023-03-06 11:12     ` Jonathan Cameron
2023-03-04  8:22   ` kernel test robot
2023-03-04  8:22   ` kernel test robot
2023-03-07  2:36   ` Davidlohr Bueso
2023-03-21 14:48     ` Jonathan Cameron [this message]
2023-03-03 17:50 ` [PATCH 3/4] cxl: CXL Performance Monitoring Unit driver Jonathan Cameron
2023-03-03 21:56   ` Liang, Kan
2023-03-06 14:41     ` Jonathan Cameron
2023-03-06 18:10       ` Liang, Kan
2023-03-07  9:19         ` Jonathan Cameron
2023-03-07 16:21           ` Liang, Kan
2023-03-21 17:46         ` Jonathan Cameron
2023-03-03 17:50 ` [PATCH 4/4] docs: perf: Minimal introduction the the CXL PMU device and driver Jonathan Cameron
2023-03-03 18:34   ` Dave Jiang
2023-03-06 10:27     ` 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=20230321144813.00002c19@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=acme@kernel.org \
    --cc=alison.schofield@intel.com \
    --cc=bwidawsk@kernel.org \
    --cc=dan.j.williams@intel.com \
    --cc=dave@stgolabs.net \
    --cc=ira.weiny@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=vishal.l.verma@intel.com \
    --cc=will@kernel.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 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.