All of lore.kernel.org
 help / color / mirror / Atom feed
From: Barry Song <21cnbao@gmail.com>
To: gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, linuxarm@huawei.com,
	rafael@kernel.org, robin.murphy@arm.com,
	song.bao.hua@hisilicon.com, wangzhou1@hisilicon.com,
	will@kernel.org
Subject: Re: [PATCH] platform-msi: Add ABI to show msi_irqs of platform devices
Date: Thu, 12 Aug 2021 16:19:30 +1200	[thread overview]
Message-ID: <20210812041930.28931-1-21cnbao@gmail.com> (raw)
In-Reply-To: <YRO5R0/N9KITjyY9@kroah.com>

>
> > +static ssize_t platform_msi_show(struct device *dev, struct device_attribute *attr,
> > +     char *buf)
> > +{
> > + struct msi_desc *entry;
> > + unsigned long irq;
> > + int retval;
> > +
> > + retval = kstrtoul(attr->attr.name, 10, &irq);
> > + if (retval)
> > + return retval;
> > +
> > + entry = irq_get_msi_desc(irq);
> > + if (entry)
> > + return sprintf(buf, "msi\n");
>
> sysfs_emit()?

yep.

>
> But why isn't this all handled by the MSI core code?  Why would each bus
> need to have this logic in it?

i think i can extract some common code for sysfs populate/destroy to msi core from pci and platform.
but we still need some pci/platform specific code in pci-msi and platform-msi cores. for example,
pci-msi has specific data which will be accessed in its show() entry.

struct msi_desc {
        ...
        union {
                /* PCI MSI/X specific data */
                struct {
                        u32 masked;
                        struct {
                                u8      is_msix         : 1;
                                u8      multiple        : 3;
                                u8      multi_cap       : 3;
                                u8      maskbit         : 1;
                                u8      is_64           : 1;
                                u8      is_virtual      : 1;
                                u16     entry_nr;
                                unsigned default_irq;
                        } msi_attrib;
                        union {
                                u8      mask_pos;
                                void __iomem *mask_base;
                        };
                };

                ...
                struct platform_msi_desc platform;
                ...
        };
};

in addition, they are quite different in initialization/release and also need different places to save sysfs groups.
so probably i can let msi cores provide msi_populate_sysfs() and msi_destroy_sysfs() APIs. And ask pci and platform
to call msi_populate_sysfs() in their init code and save the groups in their specific pointers,  and then they can
free sysfs in their release paths by calling msi_destroy_sysfs()

>
> thanks,
>
> greg k-h

Thanks
Barry

  reply	other threads:[~2021-08-12  4:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-11 10:50 [PATCH] platform-msi: Add ABI to show msi_irqs of platform devices Barry Song
2021-08-11 11:49 ` Greg KH
2021-08-12  4:19   ` Barry Song [this message]
2021-08-12  7:24     ` Greg KH
2021-08-12  9:13       ` Barry Song

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=20210812041930.28931-1-21cnbao@gmail.com \
    --to=21cnbao@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=rafael@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=song.bao.hua@hisilicon.com \
    --cc=wangzhou1@hisilicon.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.