linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Shrikanth Hegde <sshegde@linux.ibm.com>
To: ajd@linux.ibm.com
Cc: npiggin@gmail.com, christophe.leroy@csgroup.eu,
	mpe@ellerman.id.au, peterz@infradead.org, fbarrat@linux.ibm.com,
	mahesh@linux.ibm.com, oohall@gmail.com, hbathini@linux.ibm.com,
	dhowells@redhat.com, haren@linux.ibm.com,
	linux-kernel@vger.kernel.org, maddy@linux.ibm.com,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 5/6] powerpc: powenv: oxcl: use lock guard for mutex
Date: Fri, 14 Mar 2025 16:03:21 +0530	[thread overview]
Message-ID: <cb0c10be-2c86-4b14-9f2b-5e00e4d8ae4d@linux.ibm.com> (raw)
In-Reply-To: <d6999d74-45f6-413a-8881-90473b322dfa@linux.ibm.com>



On 3/14/25 15:00, Shrikanth Hegde wrote:
> 
> 
> On 3/14/25 11:15, Shrikanth Hegde wrote:
>> use guard(mutex) for scope based resource management of mutex.
>> This would make the code simpler and easier to maintain.
>>
>> More details on lock guards can be found at
>> https://lore.kernel.org/all/20230612093537.614161713@infradead.org/T/#u
>>
>> Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
>> ---
>>   arch/powerpc/platforms/powernv/ocxl.c | 12 +++---------
>>   1 file changed, 3 insertions(+), 9 deletions(-)
>>
>> diff --git a/arch/powerpc/platforms/powernv/ocxl.c b/arch/powerpc/ 
>> platforms/powernv/ocxl.c
>> index 64a9c7125c29..f8139948348e 100644
>> --- a/arch/powerpc/platforms/powernv/ocxl.c
>> +++ b/arch/powerpc/platforms/powernv/ocxl.c
>> @@ -172,12 +172,11 @@ static void pnv_ocxl_fixup_actag(struct pci_dev 
>> *dev)
>>       if (phb->type != PNV_PHB_NPU_OCAPI)
>>           return;
>> -    mutex_lock(&links_list_lock);
>> +    guard(mutex)(&links_list_lock);
>>       link = find_link(dev);
>>       if (!link) {
>>           dev_warn(&dev->dev, "couldn't update actag information\n");
>> -        mutex_unlock(&links_list_lock);
>>           return;
>>       }
>> @@ -206,7 +205,6 @@ static void pnv_ocxl_fixup_actag(struct pci_dev *dev)
>>       dev_dbg(&dev->dev, "total actags for function: %d\n",
>>           link->fn_desired_actags[PCI_FUNC(dev->devfn)]);
>> -    mutex_unlock(&links_list_lock);
>>   }
>>   DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pnv_ocxl_fixup_actag);
>> @@ -253,12 +251,11 @@ int pnv_ocxl_get_actag(struct pci_dev *dev, u16 
>> *base, u16 *enabled,
>>   {
>>       struct npu_link *link;
>> -    mutex_lock(&links_list_lock);
>> +    guard(mutex)(&links_list_lock);
>>       link = find_link(dev);
>>       if (!link) {
>>           dev_err(&dev->dev, "actag information not found\n");
>> -        mutex_unlock(&links_list_lock);
>>           return -ENODEV;
>>       }
>>       /*
>> @@ -274,7 +271,6 @@ int pnv_ocxl_get_actag(struct pci_dev *dev, u16 
>> *base, u16 *enabled,
>>       *enabled   = link->fn_actags[PCI_FUNC(dev->devfn)].count;
>>       *supported = link->fn_desired_actags[PCI_FUNC(dev->devfn)];
>> -    mutex_unlock(&links_list_lock);
>>       return 0;
>>   }
>>   EXPORT_SYMBOL_GPL(pnv_ocxl_get_actag);
>> @@ -293,12 +289,11 @@ int pnv_ocxl_get_pasid_count(struct pci_dev 
>> *dev, int *count)
>>        *
>>        * We only support one AFU-carrying function for now.
>>        */
>> -    mutex_lock(&links_list_lock);
>> +    guard(mutex)(&links_list_lock);
>>       link = find_link(dev);
>>       if (!link) {
>>           dev_err(&dev->dev, "actag information not found\n");
>> -        mutex_unlock(&links_list_lock);
>>           return -ENODEV;
>>       }
>> @@ -309,7 +304,6 @@ int pnv_ocxl_get_pasid_count(struct pci_dev *dev, 
>> int *count)
>>               break;
>>           }
>> -    mutex_unlock(&links_list_lock);
> 
> Hi. Andrew,
> 
> After this change below dev_dbg will be called with mutex held still. Is 
> that a concern? I don't see the mutex being used in that path.
> 
> Since using scoped_guard cause more code churn here, I would prefer not 
> use it.

I see current code in pnv_ocxl_fixup_actag calls dev_dbg with mutex 
held. So likely not a concern of using just guard in 
pnv_ocxl_get_pasid_count as well.

Assuming that, let me send out v2 with corrected commit subject. :w

> 
>>       dev_dbg(&dev->dev, "%d PASIDs available for function\n",
>>           rc ? 0 : *count);
>>       return rc;
> 



  reply	other threads:[~2025-03-14 10:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-14  5:45 [PATCH 0/6] powerpc: use lock guards for mutex Set 1 Shrikanth Hegde
2025-03-14  5:45 ` [PATCH 1/6] powerpc: eeh: use lock guard for mutex Shrikanth Hegde
2025-03-14  5:45 ` [PATCH 2/6] powerpc: rtas: " Shrikanth Hegde
2025-03-14  5:45 ` [PATCH 3/6] powerpc: fadump: " Shrikanth Hegde
2025-03-14  8:22   ` Peter Zijlstra
2025-03-14  9:08     ` Shrikanth Hegde
2025-03-14  5:45 ` [PATCH 4/6] powerpc: book3s: vas: " Shrikanth Hegde
2025-03-14  8:25   ` Peter Zijlstra
2025-03-14  9:27     ` Shrikanth Hegde
2025-03-14  5:45 ` [PATCH 5/6] powerpc: powenv: oxcl: " Shrikanth Hegde
2025-03-14  6:06   ` Andrew Donnellan
2025-03-14  6:57     ` Shrikanth Hegde
2025-03-14  9:30   ` Shrikanth Hegde
2025-03-14 10:33     ` Shrikanth Hegde [this message]
2025-03-19  3:59     ` Andrew Donnellan
2025-03-14  5:45 ` [PATCH 6/6] powerpc: sysdev: " Shrikanth Hegde

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=cb0c10be-2c86-4b14-9f2b-5e00e4d8ae4d@linux.ibm.com \
    --to=sshegde@linux.ibm.com \
    --cc=ajd@linux.ibm.com \
    --cc=christophe.leroy@csgroup.eu \
    --cc=dhowells@redhat.com \
    --cc=fbarrat@linux.ibm.com \
    --cc=haren@linux.ibm.com \
    --cc=hbathini@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mahesh@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=oohall@gmail.com \
    --cc=peterz@infradead.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).