lkml.org 
[lkml]   [2021]   [May]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v2 15/22] dma-direct: Support PCI P2PDMA pages in dma-direct map_sg


On 2021-05-14 7:57 a.m., Christoph Hellwig wrote:
>> + for_each_sg(sgl, sg, nents, i) {
>> + if (sg_is_dma_pci_p2pdma(sg)) {
>> + sg_dma_unmark_pci_p2pdma(sg);
>> + } else {
>
> Double space here. We also don't really need the curly braces to start
> with.
>
>> + struct pci_p2pdma_map_state p2pdma_state = {};
>> + enum pci_p2pdma_map_type map;
>> struct scatterlist *sg;
>> + int i, ret;
>>
>> for_each_sg(sgl, sg, nents, i) {
>> + if (is_pci_p2pdma_page(sg_page(sg))) {
>> + map = pci_p2pdma_map_segment(&p2pdma_state, dev, sg);
>> + switch (map) {
>
> Why not just:
>
> switch (pci_p2pdma_map_segment(&p2pdma_state, dev,
> sg)) {
>
> (even better with a shorter name for p2pdma_state so that it all fits on
> a single line)?
>
>> + case PCI_P2PDMA_MAP_BUS_ADDR:
>> + continue;
>> + case PCI_P2PDMA_MAP_THRU_HOST_BRIDGE:
>> + /*
>> + * Mapping through host bridge should be
>> + * mapped normally, thus we do nothing
>> + * and continue below.
>> + */
>
> I have a bit of a hard time parsing this comment.
>
>> + if (sg->dma_address == DMA_MAPPING_ERROR) {
>> + ret = -EINVAL;
>> goto out_unmap;
>> + }
>> sg_dma_len(sg) = sg->length;
>> }
>>
>> @@ -411,7 +443,7 @@ int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, int nents,
>>
>> out_unmap:
>> dma_direct_unmap_sg(dev, sgl, i, dir, attrs | DMA_ATTR_SKIP_CPU_SYNC);
>> - return -EINVAL;
>> + return ret;
>
> Maybe just initialize ret to -EINVAL at declaration time to simplify this
> a bit?
>

All fair points, will fix in v3.

Logan

\
 
 \ /
  Last update: 2021-05-14 18:18    [W:0.041 / U:1.484 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site