mbox series

[v3,0/5] soc: qcom: Add SoC info driver

Message ID 20190221162419.32384-1-vaishali.thakkar@linaro.org
Headers show
Series soc: qcom: Add SoC info driver | expand

Message

Vaishali Thakkar Feb. 21, 2019, 4:24 p.m. UTC
This patchset adds SoC info driver which can provide information
such as Chip ID, Chip family and serial number about Qualcomm SoCs
to user space via sysfs. Furthermore, it allows userspace to get
information about custom attributes and various image version
information via debugfs.

The patchset cleanly applies on top of v5.0-rc6.

Changes since v1:
        - Align ifdefs to left, remove unnecessary debugfs dir
          creation check and fix function signatures in patch 3
        - Fix comment for teh case when serial number is not
          available in patch 1
Changes since v2:
	- Reorder patches [patch five -> patch two]

Vaishali Thakkar (5):
  base: soc: Add serial_number attribute to soc
  base: soc: Export soc_device_register/unregister APIs
  soc: qcom: Add socinfo driver
  soc: qcom: socinfo: Expose custom attributes
  soc: qcom: socinfo: Expose image information

 Documentation/ABI/testing/sysfs-devices-soc |   7 +
 drivers/base/soc.c                          |   9 +
 drivers/soc/qcom/Kconfig                    |   8 +
 drivers/soc/qcom/Makefile                   |   1 +
 drivers/soc/qcom/smem.c                     |   8 +
 drivers/soc/qcom/socinfo.c                  | 605 ++++++++++++++++++++
 include/linux/sys_soc.h                     |   1 +
 7 files changed, 639 insertions(+)
 create mode 100644 drivers/soc/qcom/socinfo.c

-- 
2.17.1

Comments

Greg KH Feb. 21, 2019, 4:31 p.m. UTC | #1
On Thu, Feb 21, 2019 at 09:54:16PM +0530, Vaishali Thakkar wrote:
> From: Vinod Koul <vkoul@kernel.org>

> 

> Qcom Socinfo driver can be built as a module, so

> export these two APIs.

> 

> Signed-off-by: Vinod Koul <vkoul@kernel.org>

> Signed-off-by: Vaishali Thakkar <vaishali.thakkar@linaro.org>

> ---

> Changes since v2:

> 	- Reordered patches [patch 5->patch 2]

> Changes since v1:

> 	- None


Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Greg KH Feb. 21, 2019, 4:32 p.m. UTC | #2
On Thu, Feb 21, 2019 at 09:54:18PM +0530, Vaishali Thakkar wrote:
> +#else

> +static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo) { return 0; }


I don't think that will actually compile :)
Greg KH Feb. 21, 2019, 4:34 p.m. UTC | #3
On Thu, Feb 21, 2019 at 09:54:19PM +0530, Vaishali Thakkar wrote:
>  static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo)

>  {

> +	struct smem_image_version *smem_image_version;

> +	size_t size;

> +

>  	qcom_socinfo->dbg_root = debugfs_create_dir("qcom_socinfo", NULL);

>  

>  	DEBUGFS_UINT_ADD(raw_version);

> @@ -314,6 +432,98 @@ static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo)

>  	DEBUGFS_ADD(pmic_model);

>  	DEBUGFS_ADD(platform_subtype);

>  	DEBUGFS_ADD(pmic_die_revision);

> +

> +	smem_image_version = qcom_smem_get(QCOM_SMEM_HOST_ANY,

> +					   SMEM_IMAGE_VERSION_TABLE,

> +					   &size);

> +

> +	qcom_socinfo->boot = debugfs_create_dir("boot",

> +						qcom_socinfo->dbg_root);

> +	if (!qcom_socinfo->boot) {

> +		pr_err("Cannot create boot image directory\n");

> +		return;

> +	}


You do not care, do not check please.  Also, even if you wanted to
check, your error checking was wrong :)

> +	DEBUGFS_IMAGE_NAME(name, boot, SMEM_IMAGE_TABLE_BOOT_INDEX);

> +	DEBUGFS_IMAGE_VARIANT(variant, boot, SMEM_IMAGE_TABLE_BOOT_INDEX);

> +	DEBUGFS_IMAGE_OEM(oem, boot, SMEM_IMAGE_TABLE_BOOT_INDEX);

> +

> +	qcom_socinfo->tz = debugfs_create_dir("tz",

> +					      qcom_socinfo->dbg_root);

> +	if (!qcom_socinfo->tz) {

> +		pr_err("Cannot create tz image directory\n");

> +		return;

> +	}


Same here, no error checking please.

> +	DEBUGFS_IMAGE_NAME(name, tz, SMEM_IMAGE_TABLE_TZ_INDEX);

> +	DEBUGFS_IMAGE_VARIANT(variant, tz, SMEM_IMAGE_TABLE_TZ_INDEX);

> +	DEBUGFS_IMAGE_OEM(oem, tz, SMEM_IMAGE_TABLE_TZ_INDEX);

> +

> +	qcom_socinfo->rpm = debugfs_create_dir("rpm",

> +					       qcom_socinfo->dbg_root);

> +	if (!qcom_socinfo->rpm) {

> +		pr_err("Cannot create rpm image directory\n");

> +		return;

> +	}


And here.

> +	DEBUGFS_IMAGE_NAME(name, rpm, SMEM_IMAGE_TABLE_RPM_INDEX);

> +	DEBUGFS_IMAGE_VARIANT(variant, rpm, SMEM_IMAGE_TABLE_RPM_INDEX);

> +	DEBUGFS_IMAGE_OEM(oem, rpm, SMEM_IMAGE_TABLE_RPM_INDEX);

> +

> +	qcom_socinfo->apps = debugfs_create_dir("apps",

> +						qcom_socinfo->dbg_root);

> +	if (!qcom_socinfo->apps) {

> +		pr_err("Cannot create apps image directory\n");

> +		return;

> +	}


And here.

> +	DEBUGFS_IMAGE_NAME(name, apps, SMEM_IMAGE_TABLE_APPS_INDEX);

> +	DEBUGFS_IMAGE_VARIANT(variant, apps, SMEM_IMAGE_TABLE_APPS_INDEX);

> +	DEBUGFS_IMAGE_OEM(oem, apps, SMEM_IMAGE_TABLE_APPS_INDEX);

> +

> +	qcom_socinfo->mpss = debugfs_create_dir("mpss",

> +						qcom_socinfo->dbg_root);

> +	if (!qcom_socinfo->mpss) {

> +		pr_err("Cannot create mpss image directory\n");

> +		return;

> +	}


Yet again...

> +

> +	DEBUGFS_IMAGE_NAME(name, mpss, SMEM_IMAGE_TABLE_MPSS_INDEX);

> +	DEBUGFS_IMAGE_VARIANT(variant, mpss, SMEM_IMAGE_TABLE_MPSS_INDEX);

> +	DEBUGFS_IMAGE_OEM(oem, mpss, SMEM_IMAGE_TABLE_MPSS_INDEX);

> +

> +	qcom_socinfo->adsp = debugfs_create_dir("adsp",

> +						qcom_socinfo->dbg_root);

> +	if (!qcom_socinfo->adsp) {

> +		pr_err("Cannot create adsp image directory\n");

> +		return;

> +	}


And again...

> +

> +	DEBUGFS_IMAGE_NAME(name, adsp, SMEM_IMAGE_TABLE_ADSP_INDEX);

> +	DEBUGFS_IMAGE_VARIANT(variant, adsp, SMEM_IMAGE_TABLE_ADSP_INDEX);

> +	DEBUGFS_IMAGE_OEM(oem, adsp, SMEM_IMAGE_TABLE_ADSP_INDEX);

> +

> +	qcom_socinfo->cnss = debugfs_create_dir("cnss",

> +						qcom_socinfo->dbg_root);

> +	if (!qcom_socinfo->cnss) {

> +		pr_err("Cannot create cnss image directory\n");

> +		return;

> +	}


And again...

> +

> +	DEBUGFS_IMAGE_NAME(name, cnss, SMEM_IMAGE_TABLE_CNSS_INDEX);

> +	DEBUGFS_IMAGE_VARIANT(variant, cnss, SMEM_IMAGE_TABLE_CNSS_INDEX);

> +	DEBUGFS_IMAGE_OEM(oem, cnss, SMEM_IMAGE_TABLE_CNSS_INDEX);

> +

> +	qcom_socinfo->video = debugfs_create_dir("video",

> +						 qcom_socinfo->dbg_root);

> +	if (!qcom_socinfo->video) {

> +		pr_err("Cannot create video image directory\n");

> +		return;

> +	}


And one last time.

There, you get to delete a bunch of code, that's always fun :)

thanks,

greg k-h
Vaishali Thakkar Feb. 21, 2019, 5:05 p.m. UTC | #4
On Thu, 21 Feb 2019 at 22:04, Greg KH <gregkh@linuxfoundation.org> wrote:
>

> On Thu, Feb 21, 2019 at 09:54:19PM +0530, Vaishali Thakkar wrote:

> >  static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo)

> >  {

> > +     struct smem_image_version *smem_image_version;

> > +     size_t size;

> > +

> >       qcom_socinfo->dbg_root = debugfs_create_dir("qcom_socinfo", NULL);

> >

> >       DEBUGFS_UINT_ADD(raw_version);

> > @@ -314,6 +432,98 @@ static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo)

> >       DEBUGFS_ADD(pmic_model);

> >       DEBUGFS_ADD(platform_subtype);

> >       DEBUGFS_ADD(pmic_die_revision);

> > +

> > +     smem_image_version = qcom_smem_get(QCOM_SMEM_HOST_ANY,

> > +                                        SMEM_IMAGE_VERSION_TABLE,

> > +                                        &size);

> > +

> > +     qcom_socinfo->boot = debugfs_create_dir("boot",

> > +                                             qcom_socinfo->dbg_root);

> > +     if (!qcom_socinfo->boot) {

> > +             pr_err("Cannot create boot image directory\n");

> > +             return;

> > +     }

>

> You do not care, do not check please.  Also, even if you wanted to

> check, your error checking was wrong :)


I missed to remove all those checks in this patch. Will do. :)

> > +     DEBUGFS_IMAGE_NAME(name, boot, SMEM_IMAGE_TABLE_BOOT_INDEX);

> > +     DEBUGFS_IMAGE_VARIANT(variant, boot, SMEM_IMAGE_TABLE_BOOT_INDEX);

> > +     DEBUGFS_IMAGE_OEM(oem, boot, SMEM_IMAGE_TABLE_BOOT_INDEX);

> > +

> > +     qcom_socinfo->tz = debugfs_create_dir("tz",

> > +                                           qcom_socinfo->dbg_root);

> > +     if (!qcom_socinfo->tz) {

> > +             pr_err("Cannot create tz image directory\n");

> > +             return;

> > +     }

>

> Same here, no error checking please.

>

> > +     DEBUGFS_IMAGE_NAME(name, tz, SMEM_IMAGE_TABLE_TZ_INDEX);

> > +     DEBUGFS_IMAGE_VARIANT(variant, tz, SMEM_IMAGE_TABLE_TZ_INDEX);

> > +     DEBUGFS_IMAGE_OEM(oem, tz, SMEM_IMAGE_TABLE_TZ_INDEX);

> > +

> > +     qcom_socinfo->rpm = debugfs_create_dir("rpm",

> > +                                            qcom_socinfo->dbg_root);

> > +     if (!qcom_socinfo->rpm) {

> > +             pr_err("Cannot create rpm image directory\n");

> > +             return;

> > +     }

>

> And here.

>

> > +     DEBUGFS_IMAGE_NAME(name, rpm, SMEM_IMAGE_TABLE_RPM_INDEX);

> > +     DEBUGFS_IMAGE_VARIANT(variant, rpm, SMEM_IMAGE_TABLE_RPM_INDEX);

> > +     DEBUGFS_IMAGE_OEM(oem, rpm, SMEM_IMAGE_TABLE_RPM_INDEX);

> > +

> > +     qcom_socinfo->apps = debugfs_create_dir("apps",

> > +                                             qcom_socinfo->dbg_root);

> > +     if (!qcom_socinfo->apps) {

> > +             pr_err("Cannot create apps image directory\n");

> > +             return;

> > +     }

>

> And here.

>

> > +     DEBUGFS_IMAGE_NAME(name, apps, SMEM_IMAGE_TABLE_APPS_INDEX);

> > +     DEBUGFS_IMAGE_VARIANT(variant, apps, SMEM_IMAGE_TABLE_APPS_INDEX);

> > +     DEBUGFS_IMAGE_OEM(oem, apps, SMEM_IMAGE_TABLE_APPS_INDEX);

> > +

> > +     qcom_socinfo->mpss = debugfs_create_dir("mpss",

> > +                                             qcom_socinfo->dbg_root);

> > +     if (!qcom_socinfo->mpss) {

> > +             pr_err("Cannot create mpss image directory\n");

> > +             return;

> > +     }

>

> Yet again...

>

> > +

> > +     DEBUGFS_IMAGE_NAME(name, mpss, SMEM_IMAGE_TABLE_MPSS_INDEX);

> > +     DEBUGFS_IMAGE_VARIANT(variant, mpss, SMEM_IMAGE_TABLE_MPSS_INDEX);

> > +     DEBUGFS_IMAGE_OEM(oem, mpss, SMEM_IMAGE_TABLE_MPSS_INDEX);

> > +

> > +     qcom_socinfo->adsp = debugfs_create_dir("adsp",

> > +                                             qcom_socinfo->dbg_root);

> > +     if (!qcom_socinfo->adsp) {

> > +             pr_err("Cannot create adsp image directory\n");

> > +             return;

> > +     }

>

> And again...

>

> > +

> > +     DEBUGFS_IMAGE_NAME(name, adsp, SMEM_IMAGE_TABLE_ADSP_INDEX);

> > +     DEBUGFS_IMAGE_VARIANT(variant, adsp, SMEM_IMAGE_TABLE_ADSP_INDEX);

> > +     DEBUGFS_IMAGE_OEM(oem, adsp, SMEM_IMAGE_TABLE_ADSP_INDEX);

> > +

> > +     qcom_socinfo->cnss = debugfs_create_dir("cnss",

> > +                                             qcom_socinfo->dbg_root);

> > +     if (!qcom_socinfo->cnss) {

> > +             pr_err("Cannot create cnss image directory\n");

> > +             return;

> > +     }

>

> And again...

>

> > +

> > +     DEBUGFS_IMAGE_NAME(name, cnss, SMEM_IMAGE_TABLE_CNSS_INDEX);

> > +     DEBUGFS_IMAGE_VARIANT(variant, cnss, SMEM_IMAGE_TABLE_CNSS_INDEX);

> > +     DEBUGFS_IMAGE_OEM(oem, cnss, SMEM_IMAGE_TABLE_CNSS_INDEX);

> > +

> > +     qcom_socinfo->video = debugfs_create_dir("video",

> > +                                              qcom_socinfo->dbg_root);

> > +     if (!qcom_socinfo->video) {

> > +             pr_err("Cannot create video image directory\n");

> > +             return;

> > +     }

>

> And one last time.

>

> There, you get to delete a bunch of code, that's always fun :)

>

> thanks,

>

> greg k-h