2022-02-11 09:24:18

by Christophe JAILLET

[permalink] [raw]
Subject: [PATCH 2/3] VMCI: No need to clear memory after a dma_alloc_coherent() call

dma_alloc_coherent() already clear the allocated memory, there is no need
to explicitly call memset().
This saves a few cycles and a few lines of code.

Signed-off-by: Christophe JAILLET <[email protected]>
---
drivers/misc/vmw_vmci/vmci_guest.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/misc/vmw_vmci/vmci_guest.c b/drivers/misc/vmw_vmci/vmci_guest.c
index 1a1858742f75..02d4722d8474 100644
--- a/drivers/misc/vmw_vmci/vmci_guest.c
+++ b/drivers/misc/vmw_vmci/vmci_guest.c
@@ -706,13 +706,11 @@ static int vmci_guest_probe_device(struct pci_dev *pdev,
vmci_dev->notification_bitmap = dma_alloc_coherent(
&pdev->dev, PAGE_SIZE, &vmci_dev->notification_base,
GFP_KERNEL);
- if (!vmci_dev->notification_bitmap) {
+ if (!vmci_dev->notification_bitmap)
dev_warn(&pdev->dev,
"Unable to allocate notification bitmap\n");
- } else {
- memset(vmci_dev->notification_bitmap, 0, PAGE_SIZE);
+ else
caps_in_use |= VMCI_CAPS_NOTIFICATIONS;
- }
}

if (mmio_base != NULL) {
--
2.32.0



2022-02-17 16:37:27

by Vishnu Dasa

[permalink] [raw]
Subject: Re: [PATCH 2/3] VMCI: No need to clear memory after a dma_alloc_coherent() call


> On Feb 10, 2022, at 2:27 PM, Christophe JAILLET <[email protected]> wrote:
>
> dma_alloc_coherent() already clear the allocated memory, there is no need
> to explicitly call memset().
> This saves a few cycles and a few lines of code.
>
> Signed-off-by: Christophe JAILLET <[email protected]>
> ---
> drivers/misc/vmw_vmci/vmci_guest.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/misc/vmw_vmci/vmci_guest.c b/drivers/misc/vmw_vmci/vmci_guest.c
> index 1a1858742f75..02d4722d8474 100644
> --- a/drivers/misc/vmw_vmci/vmci_guest.c
> +++ b/drivers/misc/vmw_vmci/vmci_guest.c
> @@ -706,13 +706,11 @@ static int vmci_guest_probe_device(struct pci_dev *pdev,
> vmci_dev->notification_bitmap = dma_alloc_coherent(
> &pdev->dev, PAGE_SIZE, &vmci_dev->notification_base,
> GFP_KERNEL);
> - if (!vmci_dev->notification_bitmap) {
> + if (!vmci_dev->notification_bitmap)
> dev_warn(&pdev->dev,
> "Unable to allocate notification bitmap\n");
> - } else {
> - memset(vmci_dev->notification_bitmap, 0, PAGE_SIZE);
> + else
> caps_in_use |= VMCI_CAPS_NOTIFICATIONS;
> - }
> }
>
> if (mmio_base != NULL) {
> --
> 2.32.0
>

Thanks!

Acked-by: Vishnu Dasa <[email protected]>