Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1728048 > unrolled thread

[PATCH 2/2] scsi: Align queue to ARCH_DMA_MINALIGN in non-coherent DMA mode

Started byHuacai Chen <chenhc@lemote.com>
First post2017-09-07 11:00 +0200
Last post2017-09-11 10:50 +0200
Articles 4 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 2/2] scsi: Align queue to ARCH_DMA_MINALIGN in non-coherent DMA mode Huacai Chen <chenhc@lemote.com> - 2017-09-07 11:00 +0200
    Re: [PATCH 2/2] scsi: Align queue to ARCH_DMA_MINALIGN in  non-coherent DMA mode kbuild test robot <lkp@intel.com> - 2017-09-09 19:10 +0200
    Re: [PATCH 2/2] scsi: Align queue to ARCH_DMA_MINALIGN in  non-coherent DMA mode Christoph Hellwig <hch@infradead.org> - 2017-09-11 09:40 +0200
      Re: [PATCH 2/2] scsi: Align queue to ARCH_DMA_MINALIGN innon-coherent DMA mode "陈华才" <chenhc@lemote.com> - 2017-09-11 10:50 +0200

#1728048 — [PATCH 2/2] scsi: Align queue to ARCH_DMA_MINALIGN in non-coherent DMA mode

FromHuacai Chen <chenhc@lemote.com>
Date2017-09-07 11:00 +0200
Subject[PATCH 2/2] scsi: Align queue to ARCH_DMA_MINALIGN in non-coherent DMA mode
Message-ID<un0Pg-61N-17@gated-at.bofh.it>
In non-coherent DMA mode, kernel uses cache flushing operations to
maintain I/O coherency, so scsi's block queue should be aligned to
ARCH_DMA_MINALIGN.

Cc: stable@vger.kernel.org
Signed-off-by: Huacai Chen <chenhc@lemote.com>
---
 drivers/scsi/scsi_lib.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index f6097b8..800bf2a 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2096,11 +2096,14 @@ void __scsi_init_queue(struct Scsi_Host *shost, struct request_queue *q)
 		q->limits.cluster = 0;
 
 	/*
-	 * set a reasonable default alignment on word boundaries: the
-	 * host and device may alter it using
+	 * set a reasonable default alignment on word/cacheline boundaries:
+	 * the host and device may alter it using
 	 * blk_queue_update_dma_alignment() later.
 	 */
-	blk_queue_dma_alignment(q, 0x03);
+	if (plat_device_is_coherent(dev))
+		blk_queue_dma_alignment(q, 0x04 - 1);
+	else
+		blk_queue_dma_alignment(q, dma_get_cache_alignment() - 1);
 }
 EXPORT_SYMBOL_GPL(__scsi_init_queue);
 
-- 
2.7.0



}I	

[toc] | [next] | [standalone]


#1729493 — Re: [PATCH 2/2] scsi: Align queue to ARCH_DMA_MINALIGN in non-coherent DMA mode

Fromkbuild test robot <lkp@intel.com>
Date2017-09-09 19:10 +0200
SubjectRe: [PATCH 2/2] scsi: Align queue to ARCH_DMA_MINALIGN in non-coherent DMA mode
Message-ID<unRqx-8u8-13@gated-at.bofh.it>
In reply to#1728048

[Multipart message — attachments visible in raw view] — view raw

Hi Huacai,

[auto build test ERROR on mmotm/master]
[also build test ERROR on v4.13 next-20170908]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Huacai-Chen/mm-dmapool-Align-to-ARCH_DMA_MINALIGN-in-non-coherent-DMA-mode/20170909-230504
base:   git://git.cmpxchg.org/linux-mmotm.git master
config: m68k-sun3_defconfig (attached as .config)
compiler: m68k-linux-gcc (GCC) 4.9.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=m68k 

All errors (new ones prefixed by >>):

   drivers/scsi/scsi_lib.c: In function '__scsi_init_queue':
   drivers/scsi/scsi_lib.c:2139:2: error: implicit declaration of function 'plat_device_is_coherent' [-Werror=implicit-function-declaration]
     if (plat_device_is_coherent(dev))
     ^
>> drivers/scsi/scsi_lib.c:2142:3: error: implicit declaration of function 'dma_get_cache_alignment' [-Werror=implicit-function-declaration]
      blk_queue_dma_alignment(q, dma_get_cache_alignment() - 1);
      ^
   cc1: some warnings being treated as errors

vim +/dma_get_cache_alignment +2142 drivers/scsi/scsi_lib.c

  2103	
  2104	void __scsi_init_queue(struct Scsi_Host *shost, struct request_queue *q)
  2105	{
  2106		struct device *dev = shost->dma_dev;
  2107	
  2108		queue_flag_set_unlocked(QUEUE_FLAG_SCSI_PASSTHROUGH, q);
  2109	
  2110		/*
  2111		 * this limit is imposed by hardware restrictions
  2112		 */
  2113		blk_queue_max_segments(q, min_t(unsigned short, shost->sg_tablesize,
  2114						SG_MAX_SEGMENTS));
  2115	
  2116		if (scsi_host_prot_dma(shost)) {
  2117			shost->sg_prot_tablesize =
  2118				min_not_zero(shost->sg_prot_tablesize,
  2119					     (unsigned short)SCSI_MAX_PROT_SG_SEGMENTS);
  2120			BUG_ON(shost->sg_prot_tablesize < shost->sg_tablesize);
  2121			blk_queue_max_integrity_segments(q, shost->sg_prot_tablesize);
  2122		}
  2123	
  2124		blk_queue_max_hw_sectors(q, shost->max_sectors);
  2125		blk_queue_bounce_limit(q, scsi_calculate_bounce_limit(shost));
  2126		blk_queue_segment_boundary(q, shost->dma_boundary);
  2127		dma_set_seg_boundary(dev, shost->dma_boundary);
  2128	
  2129		blk_queue_max_segment_size(q, dma_get_max_seg_size(dev));
  2130	
  2131		if (!shost->use_clustering)
  2132			q->limits.cluster = 0;
  2133	
  2134		/*
  2135		 * set a reasonable default alignment on word/cacheline boundaries:
  2136		 * the host and device may alter it using
  2137		 * blk_queue_update_dma_alignment() later.
  2138		 */
> 2139		if (plat_device_is_coherent(dev))
  2140			blk_queue_dma_alignment(q, 0x04 - 1);
  2141		else
> 2142			blk_queue_dma_alignment(q, dma_get_cache_alignment() - 1);
  2143	}
  2144	EXPORT_SYMBOL_GPL(__scsi_init_queue);
  2145	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[toc] | [prev] | [next] | [standalone]


#1730190 — Re: [PATCH 2/2] scsi: Align queue to ARCH_DMA_MINALIGN in non-coherent DMA mode

FromChristoph Hellwig <hch@infradead.org>
Date2017-09-11 09:40 +0200
SubjectRe: [PATCH 2/2] scsi: Align queue to ARCH_DMA_MINALIGN in non-coherent DMA mode
Message-ID<uoru2-8bR-13@gated-at.bofh.it>
In reply to#1728048
> +	if (plat_device_is_coherent(dev))

We can't just call platform device code.  We'll need a proper
DMA API call for this.

> +		blk_queue_dma_alignment(q, 0x04 - 1);
> +	else
> +		blk_queue_dma_alignment(q, dma_get_cache_alignment() - 1);

Which we already have with dma_get_cache_alignment, except that it
doesn't take a struct device pointer and doesn't call into dma_map
ops.  So please add a struct device argument to dma_get_cache_alignment,
and let it call into dma_map_ops where needed.

With that you can replace the above with:

	blk_queue_dma_alignment(q,
			max(0x04U, dma_get_cache_alignment(dev)) - 1);

[toc] | [prev] | [next] | [standalone]


#1730207 — Re: [PATCH 2/2] scsi: Align queue to ARCH_DMA_MINALIGN innon-coherent DMA mode

From"陈华才" <chenhc@lemote.com>
Date2017-09-11 10:50 +0200
SubjectRe: [PATCH 2/2] scsi: Align queue to ARCH_DMA_MINALIGN innon-coherent DMA mode
Message-ID<uoszL-v4-1@gated-at.bofh.it>
In reply to#1730190
Hi, Christoph

I think we cannot modify dma_get_cache_alignment(), because existing callers may want to unconditionally return ARCH_DMA_MINALIGN.

Huacai
 
 
------------------ Original ------------------
From:  "Christoph Hellwig"<hch@infradead.org>;
Date:  Mon, Sep 11, 2017 03:39 PM
To:  "Huacai Chen"<chenhc@lemote.com>; 
Cc:  "James E . J . Bottomley"<jejb@linux.vnet.ibm.com>; "Martin K . Petersen"<martin.petersen@oracle.com>; "Fuxin Zhang"<zhangfx@lemote.com>; "linux-scsi"<linux-scsi@vger.kernel.org>; "linux-kernel"<linux-kernel@vger.kernel.org>; "stable"<stable@vger.kernel.org>; 
Subject:  Re: [PATCH 2/2] scsi: Align queue to ARCH_DMA_MINALIGN innon-coherent DMA mode

 
> +	if (plat_device_is_coherent(dev))

We can't just call platform device code.  We'll need a proper
DMA API call for this.

> +		blk_queue_dma_alignment(q, 0x04 - 1);
> +	else
> +		blk_queue_dma_alignment(q, dma_get_cache_alignment() - 1);

Which we already have with dma_get_cache_alignment, except that it
doesn't take a struct device pointer and doesn't call into dma_map
ops.  So please add a struct device argument to dma_get_cache_alignment,
and let it call into dma_map_ops where needed.

With that you can replace the above with:

	blk_queue_dma_alignment(q,
			max(0x04U, dma_get_cache_alignment(dev)) - 1);

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web