From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Xi Pardee <xi.pardee@linux.intel.com>
Cc: rajvi0912@gmail.com, irenic.rajneesh@gmail.com,
david.e.box@linux.intel.com, Hans de Goede <hdegoede@redhat.com>,
platform-driver-x86@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
linux-pm@vger.kernel.org
Subject: Re: [PATCH v3 2/3] platform/x86:intel/pmc: Create generic_core_init() for all platforms
Date: Sun, 29 Dec 2024 17:23:40 +0200 (EET) [thread overview]
Message-ID: <e3628ae8-317b-82e7-7545-38ba51dd4481@linux.intel.com> (raw)
In-Reply-To: <0810bc98-ea48-4d30-bfb1-bd009ee485de@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 5104 bytes --]
On Fri, 20 Dec 2024, Xi Pardee wrote:
> On 12/20/2024 3:52 AM, Ilpo Järvinen wrote:
> > On Thu, 19 Dec 2024, Xi Pardee wrote:
> >
> > > Create a generic_core_init() function for all architecture to reduce
> > > duplicate code in each architecture file. Create an info structure
> > > to catch the variations between each architecture and pass it to the
> > > generic init function.
> > >
> > > Convert all architectures to call the generic core init function.
> > >
> > > Signed-off-by: Xi Pardee <xi.pardee@linux.intel.com>
> > This looks much better!
> >
> > > ---
> > > drivers/platform/x86/intel/pmc/adl.c | 21 ++++--------
> > > drivers/platform/x86/intel/pmc/arl.c | 47 ++++++++-------------------
> > > drivers/platform/x86/intel/pmc/cnp.c | 21 ++++--------
> > > drivers/platform/x86/intel/pmc/core.c | 45 +++++++++++++++++++++++++
> > > drivers/platform/x86/intel/pmc/core.h | 25 ++++++++++++++
> > > drivers/platform/x86/intel/pmc/icl.c | 18 ++++------
> > > drivers/platform/x86/intel/pmc/lnl.c | 24 +++++---------
> > > drivers/platform/x86/intel/pmc/mtl.c | 45 +++++++------------------
> > > drivers/platform/x86/intel/pmc/spt.c | 18 ++++------
> > > drivers/platform/x86/intel/pmc/tgl.c | 31 +++++++++---------
> > > 10 files changed, 145 insertions(+), 150 deletions(-)
> > >
> > > diff --git a/drivers/platform/x86/intel/pmc/adl.c
> > > b/drivers/platform/x86/intel/pmc/adl.c
> > > index e7878558fd909..ac37f4ece9c70 100644
> > > --- a/drivers/platform/x86/intel/pmc/adl.c
> > > +++ b/drivers/platform/x86/intel/pmc/adl.c
> > > diff --git a/drivers/platform/x86/intel/pmc/arl.c
> > > b/drivers/platform/x86/intel/pmc/arl.c
> > > index 05dec4f5019f3..137a1fdfee715 100644
> > > --- a/drivers/platform/x86/intel/pmc/arl.c
> > > +++ b/drivers/platform/x86/intel/pmc/arl.c
> > > @@ -691,40 +691,19 @@ static int arl_resume(struct pmc_dev *pmcdev)
> > > return cnl_resume(pmcdev);
> > > }
> > > +static struct pmc_dev_info arl_pmc_dev = {
> > > + .func = 0,
> > > + .ssram = true,
> > > + .dmu_guid = ARL_PMT_DMU_GUID,
> > > + .regmap_list = arl_pmc_info_list,
> > > + .map = &arl_socs_reg_map,
> > > + .fixup = arl_d3_fixup,
> > I think the fixups should be left to be called from the per architecture
> > init funcs.
>
> Will rename the fixup field to platform_specifc (more explanation at the end).
> > > diff --git a/drivers/platform/x86/intel/pmc/core.h
> > > b/drivers/platform/x86/intel/pmc/core.h
> > > index a1886d8e1ef3e..82be953db9463 100644
> > > --- a/drivers/platform/x86/intel/pmc/core.h
> > > +++ b/drivers/platform/x86/intel/pmc/core.h
> > > @@ -436,6 +436,30 @@ enum pmc_index {
> > > PMC_IDX_MAX
> > > };
> > > +/**
> > > + * struct pmc_dev_info - Structure to keep pmc device info
> > > + * @func: Function number of the primary pmc
> > Capitalize "PMC" in the comments.
> Will change it.
> >
> > > + * @ssram: Bool shows if platform has ssram support
> > > + * @dmu_guid: DMU GUID
> > > + * @regmap_list: Pointer to a list of pmc_info structure that could be
> > > + * available for the platform
> > > + * @map: Pointer to a pmc_reg_map struct that contains platform
> > > + * specific attributes of the primary pmc
> > > + * @fixup: Function to perform platform specific fixup
> > > + * @suspend: Function to perform platform specific suspend
> > > + * @resume: Function to perform platform specific resume
> > > + */
> > > +struct pmc_dev_info {
> > > + u8 func;
> > > + bool ssram;
> > > + u32 dmu_guid;
> > > + struct pmc_info *regmap_list;
> > > + const struct pmc_reg_map *map;
> > > + void (*fixup)(void);
> > > + void (*suspend)(struct pmc_dev *pmcdev);
> > > + int (*resume)(struct pmc_dev *pmcdev);
> > > +};
> > > - return tgl_core_generic_init(pmcdev, PCH_H);
> > > + return tgl_core_generic_init(pmcdev, &tgl_pmc_dev);
> > > }
> > >
> > It might be also worth to consider what is stored into those
> > X86_MATCH_VFM()s so that the simple init functions could be removed
> > entirely but it could be done in another patch on top of this one.
>
> Right now we store the init function pointer for each architecture in
> X86_MATCH_VFM()
> structure. We could change it to be a pointer to the pmc_dev_info structure
> instead. Most
> of the per architecture init function call the generic_init function directly
> except for TGL
> init function. The TGL case can be handled by adding a new callback function
> pointer field named
> platform_specific and this field can also be used to replace the fixup field.
To preserve generality, the function pointer should be a real replacement
of the generic init function (if non-NULL), not some platform specific
hook is called from one point of the generic init function.
If the init function is NULL, just call the generic init function
directly.
If not NULL, that per platform replacement function in can then do the
fixup like it currently does (and whatever extra is needed) and call the
generic init function.
--
i.
next prev parent reply other threads:[~2024-12-29 15:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-19 23:55 [PATCH v3 0/3] Add Arrow Lake U/H support Xi Pardee
2024-12-19 23:55 ` [PATCH v3 1/3] platform/x86:intel/pmc: Make tgl_core_generic_init() static Xi Pardee
2024-12-19 23:55 ` [PATCH v3 2/3] platform/x86:intel/pmc: Create generic_core_init() for all platforms Xi Pardee
2024-12-20 11:52 ` Ilpo Järvinen
2024-12-20 19:55 ` Xi Pardee
2024-12-29 15:23 ` Ilpo Järvinen [this message]
2024-12-19 23:55 ` [PATCH v3 3/3] platform/x86/intel/pmc: Add Arrow Lake U/H support to intel_pmc_core driver Xi Pardee
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=e3628ae8-317b-82e7-7545-38ba51dd4481@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=david.e.box@linux.intel.com \
--cc=hdegoede@redhat.com \
--cc=irenic.rajneesh@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=rajvi0912@gmail.com \
--cc=xi.pardee@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