提交 b6953cd7 编写于 作者: G Geoff Levand 提交者: Yang Yingliang

powerpc/ps3: Add dma_mask to ps3_dma_region

stable inclusion
from linux-4.19.198
commit c58022e95bd62435cb05a3a61c24905e3aa6280c

--------------------------------

[ Upstream commit 9733862e ]

Commit f959dcd6 (dma-direct: Fix
potential NULL pointer dereference) added a null check on the
dma_mask pointer of the kernel's device structure.

Add a dma_mask variable to the ps3_dma_region structure and set
the device structure's dma_mask pointer to point to this new variable.

Fixes runtime errors like these:
# WARNING: Fixes tag on line 10 doesn't match correct format
# WARNING: Fixes tag on line 10 doesn't match correct format

  ps3_system_bus_match:349: dev=8.0(sb_01), drv=8.0(ps3flash): match
  WARNING: CPU: 0 PID: 1 at kernel/dma/mapping.c:151 .dma_map_page_attrs+0x34/0x1e0
  ps3flash sb_01: ps3stor_setup:193: map DMA region failed
Signed-off-by: NGeoff Levand <geoff@infradead.org>
Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/562d0c9ea0100a30c3b186bcc7adb34b0bbd2cd7.1622746428.git.geoff@infradead.orgSigned-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 35833479
...@@ -83,6 +83,7 @@ struct ps3_dma_region_ops; ...@@ -83,6 +83,7 @@ struct ps3_dma_region_ops;
* @bus_addr: The 'translated' bus address of the region. * @bus_addr: The 'translated' bus address of the region.
* @len: The length in bytes of the region. * @len: The length in bytes of the region.
* @offset: The offset from the start of memory of the region. * @offset: The offset from the start of memory of the region.
* @dma_mask: Device dma_mask.
* @ioid: The IOID of the device who owns this region * @ioid: The IOID of the device who owns this region
* @chunk_list: Opaque variable used by the ioc page manager. * @chunk_list: Opaque variable used by the ioc page manager.
* @region_ops: struct ps3_dma_region_ops - dma region operations * @region_ops: struct ps3_dma_region_ops - dma region operations
...@@ -97,6 +98,7 @@ struct ps3_dma_region { ...@@ -97,6 +98,7 @@ struct ps3_dma_region {
enum ps3_dma_region_type region_type; enum ps3_dma_region_type region_type;
unsigned long len; unsigned long len;
unsigned long offset; unsigned long offset;
u64 dma_mask;
/* driver variables (set by ps3_dma_region_create) */ /* driver variables (set by ps3_dma_region_create) */
unsigned long bus_addr; unsigned long bus_addr;
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include <linux/dma-mapping.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/export.h> #include <linux/export.h>
#include <linux/memblock.h> #include <linux/memblock.h>
...@@ -1130,6 +1131,7 @@ int ps3_dma_region_init(struct ps3_system_bus_device *dev, ...@@ -1130,6 +1131,7 @@ int ps3_dma_region_init(struct ps3_system_bus_device *dev,
enum ps3_dma_region_type region_type, void *addr, unsigned long len) enum ps3_dma_region_type region_type, void *addr, unsigned long len)
{ {
unsigned long lpar_addr; unsigned long lpar_addr;
int result;
lpar_addr = addr ? ps3_mm_phys_to_lpar(__pa(addr)) : 0; lpar_addr = addr ? ps3_mm_phys_to_lpar(__pa(addr)) : 0;
...@@ -1141,6 +1143,16 @@ int ps3_dma_region_init(struct ps3_system_bus_device *dev, ...@@ -1141,6 +1143,16 @@ int ps3_dma_region_init(struct ps3_system_bus_device *dev,
r->offset -= map.r1.offset; r->offset -= map.r1.offset;
r->len = len ? len : _ALIGN_UP(map.total, 1 << r->page_size); r->len = len ? len : _ALIGN_UP(map.total, 1 << r->page_size);
dev->core.dma_mask = &r->dma_mask;
result = dma_set_mask_and_coherent(&dev->core, DMA_BIT_MASK(32));
if (result < 0) {
dev_err(&dev->core, "%s:%d: dma_set_mask_and_coherent failed: %d\n",
__func__, __LINE__, result);
return result;
}
switch (dev->dev_type) { switch (dev->dev_type) {
case PS3_DEVICE_TYPE_SB: case PS3_DEVICE_TYPE_SB:
r->region_ops = (USE_DYNAMIC_DMA) r->region_ops = (USE_DYNAMIC_DMA)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册