linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Subject: [PATCH] pci/msi: remove redundant calculation in msi_setup_msi_desc
@ 2023-08-18  7:26 黄少波
  2023-08-18  8:30 ` Ilpo Järvinen
  2023-08-23 14:15 ` Thomas Gleixner
  0 siblings, 2 replies; 6+ messages in thread
From: 黄少波 @ 2023-08-18  7:26 UTC (permalink / raw)
  To: Bjorn Helgaas, Thomas Gleixner, Ahmed S. Darwish, Jason Gunthorpe,
	Kevin Tian, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org
  Cc: 李高鹏, 梁伟鹏,
	翁金飞, 熊亮

Whether to support 64-bit address status has been calculated before,
and the calculation result can be used directly afterwards, so use
msi_attrib.is_64 to avoid double calculation.

Suggested-by: weipengliang <weipengliang@xiaomi.com>
Signed-off-by: sparkhuang <huangshaobo3@xiaomi.com>
---
 drivers/pci/msi/msi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c
index ef1d885..304e889 100644
--- a/drivers/pci/msi/msi.c
+++ b/drivers/pci/msi/msi.c
@@ -303,7 +303,7 @@ static int msi_setup_msi_desc(struct pci_dev *dev, int nvec,
        desc.pci.msi_attrib.multiple    = ilog2(__roundup_pow_of_two(nvec));
        desc.affinity                   = masks;

-       if (control & PCI_MSI_FLAGS_64BIT)
+       if (desc.pci.msi_attrib.is_64)
                desc.pci.mask_pos = dev->msi_cap + PCI_MSI_MASK_64;
        else
                desc.pci.mask_pos = dev->msi_cap + PCI_MSI_MASK_32;
--
2.7.4

#/******本邮件及其附件含有小米公司的保密信息,仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制、或散发)本邮件中的信息。如果您错收了本邮件,请您立即电话或邮件通知发件人并删除本邮件! This e-mail and its attachments contain confidential information from XIAOMI, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!******/#

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: Subject: [PATCH] pci/msi: remove redundant calculation in msi_setup_msi_desc
  2023-08-18  7:26 Subject: [PATCH] pci/msi: remove redundant calculation in msi_setup_msi_desc 黄少波
@ 2023-08-18  8:30 ` Ilpo Järvinen
  2023-08-23 14:15 ` Thomas Gleixner
  1 sibling, 0 replies; 6+ messages in thread
From: Ilpo Järvinen @ 2023-08-18  8:30 UTC (permalink / raw)
  To: 黄少波
  Cc: Bjorn Helgaas, Thomas Gleixner, Ahmed S. Darwish, Jason Gunthorpe,
	Kevin Tian, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org, 李高鹏,
	梁伟鹏, 翁金飞,
	熊亮

[-- Attachment #1: Type: text/plain, Size: 1202 bytes --]

On Fri, 18 Aug 2023, 黄少波 wrote:

You should add () to the function name in the subject and use capital 
PCI/MSI.

> Whether to support 64-bit address status has been calculated before,
> and the calculation result can be used directly afterwards, so use
> msi_attrib.is_64 to avoid double calculation.
> 
> Suggested-by: weipengliang <weipengliang@xiaomi.com>
> Signed-off-by: sparkhuang <huangshaobo3@xiaomi.com>
> ---
>  drivers/pci/msi/msi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c
> index ef1d885..304e889 100644
> --- a/drivers/pci/msi/msi.c
> +++ b/drivers/pci/msi/msi.c
> @@ -303,7 +303,7 @@ static int msi_setup_msi_desc(struct pci_dev *dev, int nvec,
>         desc.pci.msi_attrib.multiple    = ilog2(__roundup_pow_of_two(nvec));
>         desc.affinity                   = masks;
> 
> -       if (control & PCI_MSI_FLAGS_64BIT)
> +       if (desc.pci.msi_attrib.is_64)
>                 desc.pci.mask_pos = dev->msi_cap + PCI_MSI_MASK_64;
>         else
>                 desc.pci.mask_pos = dev->msi_cap + PCI_MSI_MASK_32;
> --
> 2.7.4

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

-- 
 i.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Subject: [PATCH] pci/msi: remove redundant calculation in msi_setup_msi_desc
  2023-08-18  7:26 Subject: [PATCH] pci/msi: remove redundant calculation in msi_setup_msi_desc 黄少波
  2023-08-18  8:30 ` Ilpo Järvinen
@ 2023-08-23 14:15 ` Thomas Gleixner
  2023-08-24  7:27   ` huangshaobo3
  1 sibling, 1 reply; 6+ messages in thread
From: Thomas Gleixner @ 2023-08-23 14:15 UTC (permalink / raw)
  To: 黄少波, Bjorn Helgaas, Ahmed S. Darwish,
	Jason Gunthorpe, Kevin Tian, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org
  Cc: 李高鹏, 梁伟鹏,
	翁金飞, 熊亮

On Fri, Aug 18 2023 at 07:26, 黄少波 wrote:

Your patch is corrupt:

 Applying: Subject: [PATCH] pci/msi: remove redundant calculation in msi_setup_msi_desc
 error: corrupt patch at line 12

It's DOS mangled and whitespace damaged.

> Whether to support 64-bit address status has been calculated before,
> and the calculation result can be used directly afterwards, so use
> msi_attrib.is_64 to avoid double calculation.

I'm not seeing what this solves:

> -       if (control & PCI_MSI_FLAGS_64BIT)
> +       if (desc.pci.msi_attrib.is_64)

Both variants resolve to a test of a bit and a conditional instruction
on the result. It's exactly zero difference in terms of "calculation".

So all this does is change the memory location to test. Not more not
less. It does not generate better code and does not save anything.

Thanks,

        tglx


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Subject: [PATCH] pci/msi: remove redundant calculation in msi_setup_msi_desc
  2023-08-23 14:15 ` Thomas Gleixner
@ 2023-08-24  7:27   ` huangshaobo3
  2023-08-24  9:04     ` Thomas Gleixner
  0 siblings, 1 reply; 6+ messages in thread
From: huangshaobo3 @ 2023-08-24  7:27 UTC (permalink / raw)
  To: tglx
  Cc: bhelgaas, chenwei29, darwi, huangshaobo3, jgg, kevin.tian,
	linux-kernel, linux-pci, weipengliang, wengjinfei

On Wed, 23 Aug 2023 16:15:27 +0200, Thomas Gleixner wrote:
> On Fri, Aug 18 2023 at 07:26, 黄少波 wrote:

> Your patch is corrupt:

>  Applying: Subject: [PATCH] pci/msi: remove redundant calculation in msi_setup_msi_desc
>  error: corrupt patch at line 12

> It's DOS mangled and whitespace damaged.

Very sorry, may have accidentally broken the patch format,
and will make sure to use plain text next time.

> > Whether to support 64-bit address status has been calculated before,
> > and the calculation result can be used directly afterwards, so use
> > msi_attrib.is_64 to avoid double calculation.

> I'm not seeing what this solves:

> > -       if (control & PCI_MSI_FLAGS_64BIT)
> > +       if (desc.pci.msi_attrib.is_64)

> Both variants resolve to a test of a bit and a conditional instruction
> on the result. It's exactly zero difference in terms of "calculation".

> So all this does is change the memory location to test. Not more not
> less. It does not generate better code and does not save anything.

It may not be appropriate to write to eliminate duplicate calculations,
can it be proposed again with clean code?

> Thanks,

>         tglx

thanks,
sparkhuang
#/******本邮件及其附件含有小米公司的保密信息,仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制、或散发)本邮件中的信息。如果您错收了本邮件,请您立即电话或邮件通知发件人并删除本邮件! This e-mail and its attachments contain confidential information from XIAOMI, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!******/#

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Subject: [PATCH] pci/msi: remove redundant calculation in msi_setup_msi_desc
  2023-08-24  7:27   ` huangshaobo3
@ 2023-08-24  9:04     ` Thomas Gleixner
  2023-08-24 10:52       ` sparkhuang
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Gleixner @ 2023-08-24  9:04 UTC (permalink / raw)
  To: huangshaobo3
  Cc: bhelgaas, chenwei29, darwi, huangshaobo3, jgg, kevin.tian,
	linux-kernel, linux-pci, weipengliang, wengjinfei

On Thu, Aug 24 2023 at 00:27, huangshaobo3@xiaomi.com wrote:
> On Wed, 23 Aug 2023 16:15:27 +0200, Thomas Gleixner wrote:
>> I'm not seeing what this solves:
>
>> > -       if (control & PCI_MSI_FLAGS_64BIT)
>> > +       if (desc.pci.msi_attrib.is_64)
>
>> Both variants resolve to a test of a bit and a conditional instruction
>> on the result. It's exactly zero difference in terms of "calculation".
>
>> So all this does is change the memory location to test. Not more not
>> less. It does not generate better code and does not save anything.
>
> It may not be appropriate to write to eliminate duplicate calculations,
> can it be proposed again with clean code?

What's wrong with the existing code?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Subject: [PATCH] pci/msi: remove redundant calculation in msi_setup_msi_desc
  2023-08-24  9:04     ` Thomas Gleixner
@ 2023-08-24 10:52       ` sparkhuang
  0 siblings, 0 replies; 6+ messages in thread
From: sparkhuang @ 2023-08-24 10:52 UTC (permalink / raw)
  To: tglx
  Cc: bhelgaas, chenwei29, darwi, huangshaobo3, jgg, kevin.tian,
	linux-kernel, linux-pci, weipengliang, wengjinfei

On Thu, 24 Aug 2023 11:04:16 +0200, Thomas Gleixner wrote:
> On Thu, Aug 24 2023 at 00:27, huangshaobo3@xiaomi.com wrote:
> > On Wed, 23 Aug 2023 16:15:27 +0200, Thomas Gleixner wrote:
> >> I'm not seeing what this solves:
> >
> >> > -       if (control & PCI_MSI_FLAGS_64BIT)
> >> > +       if (desc.pci.msi_attrib.is_64)
> >
> >> Both variants resolve to a test of a bit and a conditional instruction
> >> on the result. It's exactly zero difference in terms of "calculation".
> >
> >> So all this does is change the memory location to test. Not more not
> >> less. It does not generate better code and does not save anything.
> >
> > It may not be appropriate to write to eliminate duplicate calculations,
> > can it be proposed again with clean code?
>
> What's wrong with the existing code?

There is nothing wrong with the current code,
using desc.pci.msi_attrib.is_64 does not solve any problems,
thank you very much for reviewing comments.

Thanks,
sparkhuang
#/******±¾Óʼþ¼°Æä¸½¼þº¬ÓÐСÃ×¹«Ë¾µÄ±£ÃÜÐÅÏ¢£¬½öÏÞÓÚ·¢Ë͸øÉÏÃæµØÖ·ÖÐÁгöµÄ¸öÈË»òȺ×é¡£½ûÖ¹ÈÎºÎÆäËûÈËÒÔÈκÎÐÎʽʹÓ㨰üÀ¨µ«²»ÏÞÓÚÈ«²¿»ò²¿·ÖµØÐ¹Â¶¡¢¸´ÖÆ¡¢»òÉ¢·¢£©±¾ÓʼþÖеÄÐÅÏ¢¡£Èç¹ûÄú´íÊÕÁ˱¾Óʼþ£¬ÇëÄúÁ¢¼´µç»°»òÓʼþ֪ͨ·¢¼þÈ˲¢É¾³ý±¾Óʼþ£¡ This e-mail and its attachments contain confidential information from XIAOMI, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!******/#

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-08-24 10:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-18  7:26 Subject: [PATCH] pci/msi: remove redundant calculation in msi_setup_msi_desc 黄少波
2023-08-18  8:30 ` Ilpo Järvinen
2023-08-23 14:15 ` Thomas Gleixner
2023-08-24  7:27   ` huangshaobo3
2023-08-24  9:04     ` Thomas Gleixner
2023-08-24 10:52       ` sparkhuang

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).