Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1147619pxv; Fri, 9 Jul 2021 19:31:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsRSRc7nnj5mJvQW/xiS6d3RxyjYd5JIRJ/2lvxvyig3nv7HRUFfn/rSs5y7iTW5ewEASW X-Received: by 2002:a17:907:75d2:: with SMTP id jl18mr16794166ejc.238.1625884310484; Fri, 09 Jul 2021 19:31:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625884310; cv=none; d=google.com; s=arc-20160816; b=lRRpCSo5DDW5jW32prdf14DlxNgLB2XrF+8P8nnjJVQ77q2Poga3i+dPMr9CNnNcb+ RwPsT6BACa2X9vEEyV4Vn5ne2KpaOYvYmlSx+t2frQ3s8I9+q9MTiBMWTHM4S4B+N32S ArMLIGk8v1NBwjl6FpUvSGNnufWezeWPPk5Arl64DF7M88IvI5yxz9xJ3p8pJ7l5it3z qxipW4ZIQCRKdPSVl0GXz1471nuP4TMHFoWqYu9/LIIupYefft1bmsjl3QXwvHvk8yE3 7L5I58DOHDCq9jTI9lN2AK0R9RHTtGp/lwymwbzQC0fBca9EfZGZM8JuCtAydg9RIi4T ACaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=avB0JcdcQAvgn0Mwfr5DPNVx5m2pJ8xfzOAOOYNN6zs=; b=nI+p5M+EMyWimZ1VYAzvooo8yc4tryzqNg2Bc2ltp068DGfuy2lirbbkAJYEKJGL7D 7kFgsVE6w0BtHgsnbbogBMn1nXPlK3itRqI87/XyIeAb9hAgOucXS3Da8/QAtIDWh7NB x1aFush/zViXZgmSbsO2AjJ/+06Gq64tPtfwMlkxFPRsALPEQOhXuvMWYIW4pgrTku6d Cv6QIh1TsXiOhw03T5SxBLpg1Sc5WTpHO5J6yX4JzgPNB/Jk2xx/DtHbVVbuIhicATP5 CBFwJq74ww0hGLRWLdp1BMpeW1o+LJ/Cf4qYkKXKv2VkeJGWRPTNZuKrC3M1/7ApobZo fwVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=A9u2btOq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t15si1935728ejd.275.2021.07.09.19.31.27; Fri, 09 Jul 2021 19:31:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=A9u2btOq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234425AbhGJCdU (ORCPT + 99 others); Fri, 9 Jul 2021 22:33:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:42704 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234234AbhGJC3R (ORCPT ); Fri, 9 Jul 2021 22:29:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 54411613F0; Sat, 10 Jul 2021 02:25:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625883941; bh=7OMGQHovSHqEfqr3GzUmZ7OZb7ckknSuqjlhS9W7XGw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A9u2btOq2FEim1ShNSTgt+oowXcMb8+NooAznDMaQy43g3mXazCICbMOXbsnlKLGI Tm2a0mIj54lTCxc0bhq7Es2MX44dv2H3EJQpp/05IMKWslG4b8Aaumxlm0IJV8v+WT DyNjdOVlf1Xh9h36024cfALGT4Qj90tLd6f9g32eYCIi89rk08NQX5kYNZWcwigMGK vLm0ApO9b75LUbcLA0XL5Zhc4b2w7+ZiSLK6N3iTGkwcuE315HvR2W/8Et/FjR9rzs cOSkGngZpvHohjARga4tbajljiuhuI3Jy8Z0+bYVGx//0X2pFsJjmW/G3RDfBpIDSZ EsibFhdJKtlZQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Geoff Levand , Michael Ellerman , Sasha Levin , linuxppc-dev@lists.ozlabs.org Subject: [PATCH AUTOSEL 5.10 55/93] powerpc/ps3: Add dma_mask to ps3_dma_region Date: Fri, 9 Jul 2021 22:23:49 -0400 Message-Id: <20210710022428.3169839-55-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710022428.3169839-1-sashal@kernel.org> References: <20210710022428.3169839-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Geoff Levand [ Upstream commit 9733862e50fdba55e7f1554e4286fcc5302ff28e ] Commit f959dcd6ddfd29235030e8026471ac1b022ad2b0 (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: Geoff Levand Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/562d0c9ea0100a30c3b186bcc7adb34b0bbd2cd7.1622746428.git.geoff@infradead.org Signed-off-by: Sasha Levin --- arch/powerpc/include/asm/ps3.h | 2 ++ arch/powerpc/platforms/ps3/mm.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/arch/powerpc/include/asm/ps3.h b/arch/powerpc/include/asm/ps3.h index cb89e4bf55ce..964063765662 100644 --- a/arch/powerpc/include/asm/ps3.h +++ b/arch/powerpc/include/asm/ps3.h @@ -71,6 +71,7 @@ struct ps3_dma_region_ops; * @bus_addr: The 'translated' bus address of the region. * @len: The length in bytes 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 * @chunk_list: Opaque variable used by the ioc page manager. * @region_ops: struct ps3_dma_region_ops - dma region operations @@ -85,6 +86,7 @@ struct ps3_dma_region { enum ps3_dma_region_type region_type; unsigned long len; unsigned long offset; + u64 dma_mask; /* driver variables (set by ps3_dma_region_create) */ unsigned long bus_addr; diff --git a/arch/powerpc/platforms/ps3/mm.c b/arch/powerpc/platforms/ps3/mm.c index d094321964fb..a81eac35d900 100644 --- a/arch/powerpc/platforms/ps3/mm.c +++ b/arch/powerpc/platforms/ps3/mm.c @@ -6,6 +6,7 @@ * Copyright 2006 Sony Corp. */ +#include #include #include #include @@ -1118,6 +1119,7 @@ int ps3_dma_region_init(struct ps3_system_bus_device *dev, enum ps3_dma_region_type region_type, void *addr, unsigned long len) { unsigned long lpar_addr; + int result; lpar_addr = addr ? ps3_mm_phys_to_lpar(__pa(addr)) : 0; @@ -1129,6 +1131,16 @@ int ps3_dma_region_init(struct ps3_system_bus_device *dev, r->offset -= map.r1.offset; r->len = len ? len : ALIGN(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) { case PS3_DEVICE_TYPE_SB: r->region_ops = (USE_DYNAMIC_DMA) -- 2.30.2