From: Hans de Goede <hdegoede@redhat.com>
To: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
markgross@kernel.org, david.e.box@intel.com
Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] platform/x86/intel/vsec: Use mutex for ida_alloc() and ida_free()
Date: Fri, 10 Feb 2023 17:21:27 +0100 [thread overview]
Message-ID: <916f252b-ef7c-6d22-0c4c-ecd198d49fbf@redhat.com> (raw)
In-Reply-To: <20230207125821.3837799-1-srinivas.pandruvada@linux.intel.com>
Hi,
On 2/7/23 13:58, Srinivas Pandruvada wrote:
> ID alloc and free functions don't have in built protection for parallel
> invocation of ida_alloc() and ida_free(). With the current flow in the
> vsec driver, there is no such scenario. But add mutex protection for
> potential future changes.
>
> Suggested-by: Hans de Goede <hdegoede@redhat.com>
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Thank you for your patch, I've applied this patch to my review-hans
branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans
Note it will show up in my review-hans branch once I've pushed my
local branch there, which might take a while.
Once I've run some tests on this branch the patches there will be
added to the platform-drivers-x86/for-next branch and eventually
will be included in the pdx86 pull-request to Linus for the next
merge-window.
Regards,
Hans
> ---
> drivers/platform/x86/intel/vsec.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/platform/x86/intel/vsec.c b/drivers/platform/x86/intel/vsec.c
> index b936fc5776d7..f1680b7e64f5 100644
> --- a/drivers/platform/x86/intel/vsec.c
> +++ b/drivers/platform/x86/intel/vsec.c
> @@ -129,11 +129,16 @@ static void intel_vsec_remove_aux(void *data)
> auxiliary_device_uninit(data);
> }
>
> +static DEFINE_MUTEX(vsec_ida_lock);
> +
> static void intel_vsec_dev_release(struct device *dev)
> {
> struct intel_vsec_device *intel_vsec_dev = dev_to_ivdev(dev);
>
> + mutex_lock(&vsec_ida_lock);
> ida_free(intel_vsec_dev->ida, intel_vsec_dev->auxdev.id);
> + mutex_unlock(&vsec_ida_lock);
> +
> kfree(intel_vsec_dev->resource);
> kfree(intel_vsec_dev);
> }
> @@ -145,7 +150,9 @@ int intel_vsec_add_aux(struct pci_dev *pdev, struct device *parent,
> struct auxiliary_device *auxdev = &intel_vsec_dev->auxdev;
> int ret, id;
>
> + mutex_lock(&vsec_ida_lock);
> ret = ida_alloc(intel_vsec_dev->ida, GFP_KERNEL);
> + mutex_unlock(&vsec_ida_lock);
> if (ret < 0) {
> kfree(intel_vsec_dev);
> return ret;
> @@ -161,7 +168,9 @@ int intel_vsec_add_aux(struct pci_dev *pdev, struct device *parent,
>
> ret = auxiliary_device_init(auxdev);
> if (ret < 0) {
> + mutex_lock(&vsec_ida_lock);
> ida_free(intel_vsec_dev->ida, auxdev->id);
> + mutex_unlock(&vsec_ida_lock);
> kfree(intel_vsec_dev->resource);
> kfree(intel_vsec_dev);
> return ret;
prev parent reply other threads:[~2023-02-10 16:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-07 12:58 [PATCH] platform/x86/intel/vsec: Use mutex for ida_alloc() and ida_free() Srinivas Pandruvada
2023-02-10 16:21 ` Hans de Goede [this message]
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=916f252b-ef7c-6d22-0c4c-ecd198d49fbf@redhat.com \
--to=hdegoede@redhat.com \
--cc=david.e.box@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=markgross@kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=srinivas.pandruvada@linux.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox