[PATCH v2] nvme-pci: Check for null on pci_alloc_p2pmem()

2019-07-08 Thread Alan Mikhak
From: Alan Mikhak Modify nvme_alloc_sq_cmds() to call pci_free_p2pmem() to free the memory it allocated using pci_alloc_p2pmem() in case pci_p2pmem_virt_to_bus() returns null. Makes sure not to call pci_free_p2pmem() if pci_alloc_p2pmem() returned null which can happen if CONFIG_PCI_P2PDMA

[PATCH] nvme-pci: No IRQ map for read if no read queue allocated

2019-07-08 Thread Alan Mikhak
From: Alan Mikhak nvme_dev_add() assumes a read queue is always allocated. That may not be the case on single-interrupt systems for which pci_assign_irq() would report runtime IRQ mapping not provided by arch. This patch makes sure nvme_dev_add() only requests an IRQ mapping for read queues

Re: [PATCH] PCI: endpoint: Add DMA to Linux PCI EP Framework

2019-05-30 Thread Alan Mikhak
ffer on the endpoint side for the DMA transfer and pass its pointer down the stack using the 'buffer' field to lower layers. This would allow different PCIe controller drivers to implement DMA or not according to their needs. Each implementer can decide to use DMAengine client API, which would be preferable, or directly read or write to DMA hardware registers to suit their needs. I would appreciate feedback and comment on such choices as part of this review. Regards, Alan Mikhak

Re: [PATCH v2] PCI: endpoint: Skip odd BAR when skipping 64bit BAR

2019-05-31 Thread Alan Mikhak
On Thu, May 30, 2019 at 9:37 PM Kishon Vijay Abraham I wrote: > > Hi Alan, > > On 25/05/19 12:20 AM, Alan Mikhak wrote: > > Hi Kishon, > > > > Yes. This change is still applicable even when the platform specifies > > that it only supports 64-bit BARs by se

Re: [PATCH] PCI: endpoint: Add DMA to Linux PCI EP Framework

2019-05-31 Thread Alan Mikhak
> http://git.ti.com/cgit/cgit.cgi/ti-linux-kernel/ti-linux-kernel.git/tree/drivers/pci/endpoint/pci-epf-core.c?h=ti-linux-4.19.y > > > > I would appreciate feedback and comment on such choices as part of this > > review. Thanks for all your comments and providing the link to your implementation of pci_epf_tx() in [1] above. It clarifies a lot and provides a very useful reference. Regards, Alan Mikhak

Re: PCI: dwc: Warn only for non-prefetchable memory resource size >4GB

2020-05-19 Thread Alan Mikhak
Hi Lorenzo, I came across this issue when implementing a Linux NVMe endpoint function driver under the Linux PCI Endpoint Framework: https://lwn.net/Articles/804369/ I needed to map up to 128GB of host memory using a single ATU window from the endpoint side because NVMe PRPs can be scattered all

[PATCH 0/2] tools: PCI: Fix broken pcitest compilation

2019-05-23 Thread Alan Mikhak
From: Alan Mikhak This patchset fixes a compiler error and two warnings that resulted in a broken compilation of pcitest. tools/pci/pcitest.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.7.4

[PATCH 1/2] tools: PCI: Fix broken pcitest compilation

2019-05-23 Thread Alan Mikhak
From: Alan Mikhak Fixes: fef31ecaaf2c ("tools: PCI: Fix compilation warnings") pcitest is currently broken due to the following compiler error and related warning. Fix by changing the run_test() function signature to return an integer result. pcitest.c: In function run_test: pcite

[PATCH 2/2] tools: PCI: Fix compiler warning in pcitest

2019-05-23 Thread Alan Mikhak
From: Alan Mikhak Fixes: fbca0b284bd0 ("tools: PCI: Add 'h' in optstring of getopt()") Fix the following compiler warning in pcitest: pcitest.c: In function main: pcitest.c:214:4: warning: too many arguments for format [-Wformat-extra-args] "usage: %s [options]\n"

[PATCH v2 2/2] tools: PCI: Fix compiler warning in pcitest

2019-05-23 Thread Alan Mikhak
Fix the following compiler warning in pcitest: pcitest.c: In function main: pcitest.c:214:4: warning: too many arguments for format [-Wformat-extra-args] "usage: %s [options]\n" Signed-off-by: Alan Mikhak Fixes: fbca0b284bd0 ("tools: PCI: Add 'h' in optstring of getopt()"

[PATCH v2 0/2] tools: PCI: Fix broken pcitest compilation

2019-05-23 Thread Alan Mikhak
This patchset fixes a compiler error and two warnings that resulted in a broken compilation of pcitest. tools/pci/pcitest.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.7.4

[PATCH v2 1/2] tools: PCI: Fix broken pcitest compilation

2019-05-23 Thread Alan Mikhak
ret : 1 - ret; /* return 0 if test succeeded */ pcitest.c: In function main: pcitest.c:232:9: error: void value not ignored as it ought to be return run_test(test); Signed-off-by: Alan Mikhak Fixes: fef31ecaaf2c ("tools: PCI: Fix compilation warnings") Reviewed-by: Paul Walmsley -

[PATCH v2] PCI: endpoint: Set endpoint controller pointer to null

2019-05-23 Thread Alan Mikhak
Set endpoint controller pointer to null in pci_epc_remove_epf() to avoid -EBUSY on subsequent call to pci_epc_add_epf(). Requires checking for null endpoint function pointer. Signed-off-by: Alan Mikhak --- drivers/pci/endpoint/pci-epc-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion

[PATCH v2] PCI: endpoint: Allocate enough space for fixed size BAR

2019-05-23 Thread Alan Mikhak
-off-by: Alan Mikhak --- drivers/pci/endpoint/functions/pci-epf-test.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c index 27806987e93b..7d41e6684b87 100644 --- a/drivers/pci

[PATCH v2] PCI: endpoint: Skip odd BAR when skipping 64bit BAR

2019-05-23 Thread Alan Mikhak
for odd loop index when BAR is 64bit but leaks on subsequent unbind by not calling pci_epf_free_space(). Signed-off-by: Alan Mikhak Reviewed-by: Paul Walmsley --- drivers/pci/endpoint/functions/pci-epf-test.c | 25 - 1 file changed, 12 insertions(+), 13 deletions(-) diff

[PATCH v2] PCI: endpoint: Clear BAR before freeing its space

2019-05-23 Thread Alan Mikhak
Associated pci_epf_bar structure is needed in pci_epc_clear_bar() but would be cleared in pci_epf_free_space(), if called first, and BAR would not get cleared. Signed-off-by: Alan Mikhak --- drivers/pci/endpoint/functions/pci-epf-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion

[PATCH] PCI: endpoint: Add DMA to Linux PCI EP Framework

2019-05-23 Thread Alan Mikhak
. Signed-off-by: Alan Mikhak --- drivers/misc/pci_endpoint_test.c| 72 +++- drivers/pci/controller/dwc/pcie-designware-ep.c | 22 +++ drivers/pci/controller/dwc/pcie-designware.h| 13 ++ drivers/pci/endpoint/functions/pci-epf-test.c | 211 +++- drivers/pci

Re: [PATCH v2] PCI: endpoint: Clear BAR before freeing its space

2019-05-23 Thread Alan Mikhak
+Bjorn Helgaas, +Gustavo Pimentel, +Wen Yang, +Kangjie Lu On Thu, May 23, 2019 at 2:57 PM Alan Mikhak wrote: > > Associated pci_epf_bar structure is needed in pci_epc_clear_bar() but > would be cleared in pci_epf_free_space(), if called first, and BAR > would not get cleared. &g

Re: [PATCH v2] PCI: endpoint: Skip odd BAR when skipping 64bit BAR

2019-05-23 Thread Alan Mikhak
+Bjorn Helgaas, +Gustavo Pimentel, +Wen Yang, +Kangjie Lu On Thu, May 23, 2019 at 2:55 PM Alan Mikhak wrote: > > Always skip odd bar when skipping 64bit BARs in pci_epf_test_set_bar() > and pci_epf_test_alloc_space(). > > Otherwise, pci_epf_test_set_bar() will call pci_epc_set_ba

Re: [PATCH v2] PCI: endpoint: Allocate enough space for fixed size BAR

2019-05-23 Thread Alan Mikhak
+Bjorn Helgaas, +Gustavo Pimentel, +Wen Yang, +Kangjie Lu On Thu, May 23, 2019 at 2:48 PM Alan Mikhak wrote: > > PCI endpoint test function code should honor the .bar_fixed_size parameter > from underlying endpoint controller drivers or results may be unexpected. > > In pci_epf_t

Re: [PATCH v2] PCI: endpoint: Set endpoint controller pointer to null

2019-05-23 Thread Alan Mikhak
+Bjorn Helgaas On Thu, May 23, 2019 at 2:46 PM Alan Mikhak wrote: > > Set endpoint controller pointer to null in pci_epc_remove_epf() > to avoid -EBUSY on subsequent call to pci_epc_add_epf(). > > Requires checking for null endpoint function pointer. > > Signe

[PATCH] nvme-pci: Avoid leak if pci_p2pmem_virt_to_bus() returns null

2019-06-24 Thread Alan Mikhak
. Signed-off-by: Alan Mikhak --- drivers/nvme/host/pci.c | 14 +- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 524d6bd6d095..5dfa067f6506 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -1456,11

Re: [PATCH] nvme-pci: Avoid leak if pci_p2pmem_virt_to_bus() returns null

2019-06-25 Thread Alan Mikhak
On Tue, Jun 25, 2019 at 12:09 AM Christoph Hellwig wrote: > > On Mon, Jun 24, 2019 at 04:57:22PM -0700, Alan Mikhak wrote: > > Modify nvme_alloc_sq_cmds() to call pci_free_p2pmem() > > to free the memory it allocated using pci_alloc_p2pmem() > > in case pci_p2pmem_vi

Re: [PATCH] nvme-pci: Avoid leak if pci_p2pmem_virt_to_bus() returns null

2019-06-25 Thread Alan Mikhak
On Tue, Jun 25, 2019 at 10:10 AM Heitke, Kenneth wrote: > > > > On 6/24/2019 5:57 PM, Alan Mikhak wrote: > > Modify nvme_alloc_sq_cmds() to call pci_free_p2pmem() > > to free the memory it allocated using pci_alloc_p2pmem() > > in case pci_p2pmem_virt_to_bus() r

Re: [PATCH] PCI: endpoint: Add DMA to Linux PCI EP Framework

2019-05-29 Thread Alan Mikhak
On Mon, May 27, 2019 at 2:09 AM Gustavo Pimentel wrote: > > On Fri, May 24, 2019 at 20:42:43, Alan Mikhak > wrote: > > Hi Alan, > > > On Fri, May 24, 2019 at 1:59 AM Gustavo Pimentel > > wrote: > > > > > > Hi Alan, > > > > >

[PATCH] scatterlist: Validate page before calling PageSlab()

2019-09-30 Thread Alan Mikhak
From: Alan Mikhak Modify sg_miter_stop() to validate the page pointer before calling PageSlab(). This check prevents a crash that will occur if PageSlab() gets called with a page pointer that is not backed by page struct. A virtual address obtained from ioremap() for a physical address in PCI

Re: [PATCH] PCI: endpoint: Add DMA to Linux PCI EP Framework

2019-09-13 Thread Alan Mikhak
On Fri, Sep 13, 2019 at 5:11 AM Kishon Vijay Abraham I wrote: > > + Haotian Wang > > On 03/06/19 11:12 PM, Alan Mikhak wrote: > > On Sun, Jun 2, 2019 at 9:43 PM Kishon Vijay Abraham I wrote: > >> Hi Alan, > >> On 31/05/19 11:46 PM, Alan Mikhak wrote: > >

Re: [PATCH] scatterlist: Validate page before calling PageSlab()

2019-10-01 Thread Alan Mikhak
On Tue, Oct 1, 2019 at 5:16 AM Jason Gunthorpe wrote: > > On Mon, Sep 30, 2019 at 04:22:35PM -0700, Alan Mikhak wrote: > > From: Alan Mikhak > > > > Modify sg_miter_stop() to validate the page pointer > > before calling PageSlab(). This check prevents a crash &

Re: [PATCH] scatterlist: Validate page before calling PageSlab()

2019-10-01 Thread Alan Mikhak
On Tue, Oct 1, 2019 at 10:12 AM Jason Gunthorpe wrote: > > On Tue, Oct 01, 2019 at 10:09:48AM -0700, Alan Mikhak wrote: > > On Tue, Oct 1, 2019 at 5:16 AM Jason Gunthorpe wrote: > > > > > > On Mon, Sep 30, 2019 at 04:22:35PM -0700, Alan Mikhak wr

Re: [PATCH] scatterlist: Validate page before calling PageSlab()

2019-10-01 Thread Alan Mikhak
On Tue, Oct 1, 2019 at 10:44 AM Jason Gunthorpe wrote: > > On Tue, Oct 01, 2019 at 10:26:38AM -0700, Alan Mikhak wrote: > > > > > Cost of adding page structs to a large PCI I/O address range can be > > > > quite substantial. Allowing PCI I/O pages without page

[PATCH] scatterlist: Comment on pages for sg_set_page()

2019-10-01 Thread Alan Mikhak
From: Alan Mikhak Update the description of sg_set_page() to communicate current requirements for the page pointer parameter. Signed-off-by: Alan Mikhak --- include/linux/scatterlist.h | 6 ++ 1 file changed, 6 insertions(+) diff --git a/include/linux/scatterlist.h b/include/linux

Re: [PATCH] scatterlist: Comment on pages for sg_set_page()

2019-10-02 Thread Alan Mikhak
On Wed, Oct 2, 2019 at 7:27 AM Jason Gunthorpe wrote: > > On Tue, Oct 01, 2019 at 11:32:50AM -0700, Alan Mikhak wrote: > > From: Alan Mikhak > > > > Update the description of sg_set_page() to communicate current > > requirements for the page pointer parameter. >

[PATCH] PCI: endpoint: cast the page number to phys_addr_t

2019-10-04 Thread Alan Mikhak
From: Alan Mikhak Modify pci_epc_mem_alloc_addr() to cast the variable 'pageno' from type 'int' to 'phys_addr_t' before shifting left. This cast is needed to avoid treating bit 31 of 'pageno' as the sign bit which would otherwise get sign-extended to produce a negative value. When added

Re: [PATCH] scatterlist: Validate page before calling PageSlab()

2019-10-07 Thread Alan Mikhak
On Sun, Oct 6, 2019 at 11:13 PM Christoph Hellwig wrote: > > On Mon, Sep 30, 2019 at 04:22:35PM -0700, Alan Mikhak wrote: > > From: Alan Mikhak > > > > Modify sg_miter_stop() to validate the page pointer > > before calling PageSlab(). This check prevents a crash &

Re: [PATCH] PCI: endpoint: cast the page number to phys_addr_t

2019-10-07 Thread Alan Mikhak
On Fri, Oct 4, 2019 at 6:49 PM Alan Mikhak wrote: > > From: Alan Mikhak > > Modify pci_epc_mem_alloc_addr() to cast the variable 'pageno' > from type 'int' to 'phys_addr_t' before shifting left. This > cast is needed to avoid treating bit 31 of 'pageno' as the > sign bit

Re: [PATCH] PCI: endpoint: cast the page number to phys_addr_t

2019-10-07 Thread Alan Mikhak
> PCI memory size 128M 0x20 Correction: PCI memory size 128G 0x20

Re: [PATCH] scatterlist: Validate page before calling PageSlab()

2019-10-07 Thread Alan Mikhak
On Mon, Oct 7, 2019 at 9:44 AM Alan Mikhak wrote: > > On Sun, Oct 6, 2019 at 11:13 PM Christoph Hellwig wrote: > > > > On Mon, Sep 30, 2019 at 04:22:35PM -0700, Alan Mikhak wrote: > > > From: Alan Mikhak > > > > > > Modify sg_miter_stop() to v

[PATCH v2] PCI: endpoint: Cast the page number to phys_addr_t

2019-10-09 Thread Alan Mikhak
From: Alan Mikhak Modify pci_epc_mem_alloc_addr() to cast the variable 'pageno' from type 'int' to 'phys_addr_t' before shifting left. This cast is needed to avoid treating bit 31 of 'pageno' as the sign bit which would otherwise get sign-extended to produce a negative value. When added

[PATCH] PCI: endpoint: functions/pci-epf-test: Enable picking DMA channel by name

2020-05-01 Thread Alan Mikhak
From: Alan Mikhak Modify pci_epf_test_init_dma_chan() to call dma_request_channel() with a filter function to pick DMA channel by name, if desired. Add a new filter function pci_epf_test_pick_dma_chan() which takes a name string as an optional parameter. If desired name is specified, the filter

[PATCH] PCI: endpoint: functions/pci-epf-test: Support slave DMA transfer

2020-05-01 Thread Alan Mikhak
From: Alan Mikhak Modify pci_epf_test_data_transfer() to also support slave DMA transfers. Adds a direction parameter so caller can specify one of the supported DMA transfer directions: DMA_MEM_TO_MEM, DMA_MEM_TO_DEV, and DMA_DEV_TO_MEM. For DMA_MEM_TO_MEM, the function calls

[PATCH][next] dmaengine: dw-edma: support local dma device transfer semantics

2020-04-28 Thread Alan Mikhak
From: Alan Mikhak Modify dw_edma_device_transfer() to also support the semantics of dma device transfer for additional use cases involving pcitest utility as a local initiator. For its original use case, dw-edma supported the semantics of dma device transfer from the perspective of a remote

[PATCH] irqchip: Skip contexts other supervisor in plic_init()

2019-10-23 Thread Alan Mikhak
From: Alan Mikhak Modify plic_init() to skip .dts interrupt contexts other than supervisor external interrupt. Signed-off-by: Alan Mikhak --- drivers/irqchip/irq-sifive-plic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers

Re: [PATCH] scatterlist: Validate page before calling PageSlab()

2019-10-15 Thread Alan Mikhak
On Tue, Oct 15, 2019 at 2:55 AM Christoph Hellwig wrote: > > On Mon, Oct 07, 2019 at 02:13:51PM -0700, Alan Mikhak wrote: > > > My goal is to not modify the Linux NVMe target code at all. The NVMe > > > endpoint function driver currently does the work that is required.

Re: [PATCH] scatterlist: Validate page before calling PageSlab()

2019-10-15 Thread Alan Mikhak
On Tue, Oct 15, 2019 at 10:45 AM Logan Gunthorpe wrote: > > > > On 2019-10-15 11:40 a.m., Alan Mikhak wrote: > > On Tue, Oct 15, 2019 at 2:55 AM Christoph Hellwig > > wrote: > >> > >> On Mon, Oct 07, 2019 at 02:13:51PM -0700, Alan Mikhak wrote: >

Re: [PATCH] scatterlist: Validate page before calling PageSlab()

2019-10-15 Thread Alan Mikhak
On Tue, Oct 15, 2019 at 9:12 AM Logan Gunthorpe wrote: > > > > On 2019-10-15 3:55 a.m., Christoph Hellwig wrote: > > On Mon, Oct 07, 2019 at 02:13:51PM -0700, Alan Mikhak wrote: > >>> My goal is to not modify the Linux NVMe target code at all. The NVMe > >&

Re: [PATCH v2] PCI: endpoint: Skip odd BAR when skipping 64bit BAR

2019-05-24 Thread Alan Mikhak
ing of PCI_BASE_ADDRESS_MEM_TYPE_64 in epf_bar->flags to before the 'continue' statement to advance the 'bar' loop index accordingly. The comment you see about 'pci_epc_set_bar()' preceding the moved code is the original comment and was also moved along with the code. Regards, Alan Mikhak On Fri,

Re: [PATCH] PCI: endpoint: Add DMA to Linux PCI EP Framework

2019-05-24 Thread Alan Mikhak
( 102400 bytes): OKAY $ pcitest -w WRITE ( 102400 bytes): OKAY Regards, Alan Mikhak > > -Original Message- > From: Alan Mikhak > > Sent: 23 de maio de 2019 23:24 > To: linux-...@vger.kernel.org; > linux-kernel@vger.kernel.org; kis...@ti.com; lorenzo.pieral...@arm.com;

Re: [PATCH] PCI: endpoint: Add DMA to Linux PCI EP Framework

2019-06-03 Thread Alan Mikhak
On Sun, Jun 2, 2019 at 9:43 PM Kishon Vijay Abraham I wrote: > Hi Alan, > On 31/05/19 11:46 PM, Alan Mikhak wrote: > > On Thu, May 30, 2019 at 10:08 PM Kishon Vijay Abraham I > > wrote: > >> Hi Alan, > >>> Hi Kishon, > >> > >> I still hav

Re: [PATCH] PCI: endpoint: functions/pci-epf-test: Enable picking DMA channel by name

2020-05-11 Thread Alan Mikhak
On Thu, May 7, 2020 at 2:42 PM Rob Herring wrote: > > On Fri, May 01, 2020 at 09:20:08AM -0700, Alan Mikhak wrote: > > From: Alan Mikhak > > > > Modify pci_epf_test_init_dma_chan() to call dma_request_channel() with a > > filter function to pick DMA channel by name,

Re: [PATCH] PCI: endpoint: functions/pci-epf-test: Support slave DMA transfer

2020-05-11 Thread Alan Mikhak
On Thu, May 7, 2020 at 2:44 PM Rob Herring wrote: > > On Fri, May 01, 2020 at 05:29:12PM -0700, Alan Mikhak wrote: > > From: Alan Mikhak > > > > Modify pci_epf_test_data_transfer() to also support slave DMA transfers. > > Adds a direction parameter so caller can sp