lkml.org 
[lkml]   [2018]   [Dec]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 5/5] switchtec: MRPC DMA mode implementation
On Wed, Dec 12, 2018 at 03:58:22PM -0700, Logan Gunthorpe wrote:
> On 2018-12-12 3:52 p.m., Bjorn Helgaas wrote:
> > On Mon, Dec 10, 2018 at 05:12:24PM +0800, Wesley Sheng wrote:
> >> MRPC normal mode requires the host to read the MRPC command status and
> >> output data from BAR. This results in high latency responses from the
> >> Memory Read TLP and potential Completion Timeout (CTO).
> >>
> >> MRPC DMA mode implementation includes:
> >> Macro definitions for registers and data structures corresponding to
> >> MRPC DMA mode.
> >>
> >> Add module parameter use_dma_mrpc to select between MRPC DMA mode and
> >> MRPC normal mode.
> >>
> >> Add MRPC mode functionality to:
> >> * Retrieve MRPC DMA mode version
> >> * Allocate DMA buffer, ISR registration, and enable DMA function during
> >> initialization
> >> * Check MRPC execution status and collect execution results from DMA buffer
> >> * Release DMA buffer and disable DMA function when unloading module
> >>
> >> MRPC DMA mode is a new feature of firmware and the driver will fall back
> >> to MRPC normal mode if there is no support in the legacy firmware.
> >>
> >> Include <linux/io-64-nonatomic-lo-hi.h> so that readq/writeq is replaced
> >> by two readl/writel on systems that do not support it.
> >>
> >> Signed-off-by: Wesley Sheng <wesley.sheng@microchip.com>
> >> Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
> >> ---
> >> drivers/pci/switch/switchtec.c | 108 +++++++++++++++++++++++++++++++++++++----
> >> include/linux/switchtec.h | 16 ++++++
> >> 2 files changed, 114 insertions(+), 10 deletions(-)
> >>
> >> diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c
> >> index 0b8862b..6b726cb 100644
> >> --- a/drivers/pci/switch/switchtec.c
> >> +++ b/drivers/pci/switch/switchtec.c
> >> @@ -13,7 +13,7 @@
> >> #include <linux/uaccess.h>
> >> #include <linux/poll.h>
> >> #include <linux/wait.h>
> >> -
> >> +#include <linux/io-64-nonatomic-lo-hi.h>
> >> #include <linux/nospec.h>
> >>
> >> MODULE_DESCRIPTION("Microsemi Switchtec(tm) PCIe Management Driver");
> >> @@ -25,6 +25,11 @@ static int max_devices = 16;
> >> module_param(max_devices, int, 0644);
> >> MODULE_PARM_DESC(max_devices, "max number of switchtec device instances");
> >>
> >> +static bool use_dma_mrpc = 1;
> >> +module_param(use_dma_mrpc, bool, 0644);
> >> +MODULE_PARM_DESC(use_dma_mrpc,
> >> + "Enable the use of the DMA MRPC feature");
> >
> > What's the purpose of the module parameter? Can't you automatically
> > figure out whether the firmware supports DMA mode?
> >
> > Module parameters make life difficult for users and lead to code
> > that's rarely used and poorly tested, so I think we should avoid them
> > whenever we can.
> >
> > If you *can't* automatically figure out when to use DMA, please make
> > it clear in the changelog that the "use_dma_mrpc" parameter is
> > required with legacy firmware. And in that case, it seems like it
> > should be named "disable_dma" or similar, since it defaults to being
> > enabled.
>
> The code should already automatically determine whether the firmware
> supports DMA or not. This parameter is just to aid debugging/testing so
> we can run the module without DMA even if the firmware indicates it has
> support.
>
> It's not that critical so I'm sure we can remove it at this point if you
> don't think that's a good enough justification.

You and Kurt are the maintainers of this, so it's up to you. I
personally probably would not add a parameter that's only for
debugging, but at the end of the day I only want to double-check
that this is all as you intend.

I reworked the changelog as follows.


commit a5fa833d8008b9f8e211e2fbc7bc1f45f6457133
Author: Wesley Sheng <wesley.sheng@microchip.com>
Date: Mon Dec 10 17:12:24 2018 +0800

switchtec: Add MRPC DMA mode support

MRPC normal mode requires the host to read the MRPC command status and
output data from BAR. This results in high latency responses from the
Memory Read TLP and potential Completion Timeout (CTO).

Add support for MRPC DMA mode, including related macro definitions and data
structures and code to:

* Retrieve MRPC DMA mode version from adapter firmware
* Allocate DMA buffer, register ISR, and enable DMA during init
* Check MRPC execution status and collect execution results from DMA buffer
* Release DMA buffer and disable DMA function when unloading module

MRPC DMA mode is a new feature of firmware, and the driver will fall back
to MRPC normal mode if there is no support in the legacy firmware.

Add a module parameter, "use_dma_mrpc", to select between MRPC DMA mode and
MRPC normal mode. Since the driver automatically detects DMA support in
the firmware, this parameter is just for debugging and testing.

Include <linux/io-64-nonatomic-lo-hi.h> so that readq/writeq is replaced by
two readl/writel on systems that do not support it.

Signed-off-by: Wesley Sheng <wesley.sheng@microchip.com>
[bhelgaas: changelog]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>

\
 
 \ /
  Last update: 2018-12-13 16:16    [W:1.179 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site