linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Sandeep Singh <Sandeep.Singh@amd.com>
Cc: Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-input <linux-input@vger.kernel.org>,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
	Jonathan Cameron <jic23@kernel.org>,
	linux-iio <linux-iio@vger.kernel.org>,
	Hans de Goede <hdegoede@redhat.com>,
	"Shah, Nehal-bakulchandra" <Nehal-bakulchandra.Shah@amd.com>,
	Richard Neumann <mail@richard-neumann.de>,
	Shyam-sundar.S-k@amd.com
Subject: Re: [PATCH v5 2/4] SFH: PCI driver to add support of AMD sensor fusion Hub using HID framework
Date: Fri, 29 May 2020 17:03:39 +0300	[thread overview]
Message-ID: <CAHp75VcLUwXPaEUE+vrkYKdqhe2hTDz5Q7mxqoYWJu3fX0G+JA@mail.gmail.com> (raw)
In-Reply-To: <1590759730-32494-3-git-send-email-Sandeep.Singh@amd.com>

On Fri, May 29, 2020 at 4:42 PM Sandeep Singh <Sandeep.Singh@amd.com> wrote:
>
> From: Sandeep Singh <sandeep.singh@amd.com>
>
> AMD SFH uses HID over PCIe bus.SFH fw is part of MP2
> processor (MP2 which is an ARM® Cortex-M4 core based
> co-processor to x86) and it runs on MP2 where in driver resides
> on X86. This part of module will communicate with MP2 FW and
> provide that data into DRAM
>
> Signed-off-by: Sandeep Singh <sandeep.singh@amd.com>

> Signed-off-by: Nehal Shah <Nehal-bakulchandra.Shah@amd.com>

Why you are submitting code if Nehal's SoB last in the list?

...

> Reported-by: kbuild test robot <lkp@intel.com>

I guess it's not applicable here, since it's a new code. Rather you
may mentioned this in changelog in cover letter.

...

> +       write64(0x0, privdata->mmio + AMD_C2P_MSG2);

Hmm... What's write64()? Isn't it writeq()?

...

> +       if (ACEL_EN  & activestatus) {
> +               sensor_id[num_of_sensors] = ACCEL_IDX;
> +               num_of_sensors++;
> +       }

You can drop a lot of LOCs by doing

    if (ACEL_EN  & activestatus)
        sensor_id[num_of_sensors++] = ACCEL_IDX;

...

> +       rc = pcim_iomap_regions(pdev, BIT(2), DRIVER_NAME);
> +       if (rc)

> +               goto err_pci_enable;

Due to use of PCI managed functions error path is not needed at all.
Return directly.

...

> +       rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
> +       if (rc) {
> +               rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
> +               if (rc)
> +                       goto err_dma_mask;
> +       }

rc = ...;
if (rc)
  rc = ...;
if (rc)
  return rc;

...

> +err_dma_mask:
> +       pci_clear_master(pdev);

PCI managed handling does it for you.

> +err_pci_enable:
> +       pci_set_drvdata(pdev, NULL);

Driver code does this for you.

> +       return rc;

...

> +       dev_info(&pdev->dev, "MP2 device found [%04x:%04x] (rev %x)\n",
> +                pdev->vendor, pdev->device, pdev->revision);

How is it useful? PCI core prints a lot of information which you may
find in dmesg.

...

> +       privdata = devm_kzalloc(&pdev->dev, sizeof(*privdata), GFP_KERNEL);
> +       if (!privdata)

> +               rc = -ENOMEM;

How this has been tested?

> +       privdata->pdev = pdev;

> +       rc = amd_mp2_pci_init(privdata, pdev);
> +       if (rc)
> +               return rc;
> +       return 0;

return amd_mp2_pci_init(...);

...

> +static void amd_mp2_pci_remove(struct pci_dev *pdev)
> +{
> +       struct amd_mp2_dev *privdata = pci_get_drvdata(pdev);
> +
> +       amd_stop_all_sensors(privdata->pdev);

> +       pci_clear_master(pdev);
> +       pci_set_drvdata(pdev, NULL);

Same comments as per error path in the ->probe()

> +}

...

> +static const struct pci_device_id amd_mp2_pci_tbl[] = {
> +       {PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_MP2)},

Spaces, please,
 { PCI...() },

> +       {0}

0 is not needed here.

> +};

...

> +#ifndef PCIE_MP2_AMD_H
> +#define PCIE_MP2_AMD_H

+ empty line

> +#include <linux/io-64-nonatomic-lo-hi.h>
> +#include <linux/pci.h>
> +#include <linux/types.h>

> +#define PCI_DEVICE_ID_AMD_MP2  0x15E4

Why not in the C file?

> +/* MP2 C2P Message Registers */
> +#define AMD_C2P_MSG0   0x10500
> +#define AMD_C2P_MSG1   0x10504
> +#define AMD_C2P_MSG2   0x10508
> +#define AMD_C2P_MSG3   0x1050c
> +#define AMD_C2P_MSG4   0x10510
> +#define AMD_C2P_MSG5   0x10514
> +#define AMD_C2P_MSG6   0x10518
> +#define AMD_C2P_MSG7   0x1051c
> +#define AMD_C2P_MSG8   0x10520
> +#define AMD_C2P_MSG9   0x10524
> +
> +/* MP2 P2C Message Registers */
> +#define AMD_P2C_MSG0   0x10680 /*Do not use*/
> +#define AMD_P2C_MSG1   0x10684
> +#define AMD_P2C_MSG2   0x10688
> +#define AMD_P2C_MSG3   0x1068C /*MP2 debug info*/
> +#define AMD_P2C_MSG_INTEN      0x10690 /*MP2 int gen register*/
> +#define AMD_P2C_MSG_INTSTS     0x10694 /*Interrupt sts*/

Do you need all these in the header?

...

> +#define write64 lo_hi_writeq
> +#define read64 lo_hi_readq

Why?! You have writeq() definition or use lo_hi_*() directly.

...

> +int amd_mp2_get_sensor_num(struct pci_dev *dev, u8 *sensor_id);

+ blank line

> +#endif

-- 
With Best Regards,
Andy Shevchenko

  reply	other threads:[~2020-05-29 14:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-29 13:42 [PATCH v5 0/4] SFH: Add Support for AMD Sensor Fusion Hub Sandeep Singh
2020-05-29 13:42 ` [PATCH v5 1/4] SFH: Add maintainers and documentation for AMD SFH based on HID framework Sandeep Singh
2020-05-29 13:42 ` [PATCH v5 2/4] SFH: PCI driver to add support of AMD sensor fusion Hub using " Sandeep Singh
2020-05-29 14:03   ` Andy Shevchenko [this message]
2020-05-29 13:42 ` [PATCH v5 3/4] SFH: Transport Driver to add support of AMD Sensor Fusion Hub (SFH Sandeep Singh
2020-05-29 14:20   ` Andy Shevchenko
2020-05-29 13:42 ` [PATCH v5 4/4] SFH: Create HID report to Enable support of AMD sensor fusion Hub (SFH) Sandeep Singh
2020-05-29 14:21 ` [PATCH v5 0/4] SFH: Add Support for AMD Sensor Fusion Hub Andy Shevchenko
2020-07-28 14:58   ` Marco Felsch
2020-07-28 15:05     ` Richard Neumann
2020-07-28 15:20       ` Marco Felsch

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=CAHp75VcLUwXPaEUE+vrkYKdqhe2hTDz5Q7mxqoYWJu3fX0G+JA@mail.gmail.com \
    --to=andy.shevchenko@gmail.com \
    --cc=Nehal-bakulchandra.Shah@amd.com \
    --cc=Sandeep.Singh@amd.com \
    --cc=Shyam-sundar.S-k@amd.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=hdegoede@redhat.com \
    --cc=jic23@kernel.org \
    --cc=jikos@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mail@richard-neumann.de \
    --cc=srinivas.pandruvada@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;
as well as URLs for NNTP newsgroup(s).