Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3764782pxv; Mon, 19 Jul 2021 08:13:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxR9/WHffEe+/nUZ5CNIQWnuWt7SIp4wf9imO0uV/LaeudMdnoVybBLrl/s5/QcAM5EiXLj X-Received: by 2002:aa7:cc92:: with SMTP id p18mr19610814edt.365.1626707616910; Mon, 19 Jul 2021 08:13:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626707616; cv=none; d=google.com; s=arc-20160816; b=qXavSJfyCvPhiAEvFKFfSFsKSkRC1snmGICr9TKCCL59okEXcGMinIonPJh/6LV4MM 4KKzjQmh/kpLwMWSv/QGMJjllSd4ScWhWs0lWDsRiHyMzUZRLLc+08dbX3kRNC4tozl5 cNDkps1v5k/ux2SqGE/FuIzp087tH/HN0rUbdpZHiip+z7x8+dFrBtqDTSsv20jmomMR l/e30Q7cbuyKBNMAqq8mtS7zsqsRMkmuumZfaf9K+W5QpaUvvVnVKhwuJKSabtoFI/5b pnDmhScptejdkQNOKNgrVueWWp/720u+OhiNdKGHaH2q/Qzh3tHyh1FOGnWm6p8DPquY EI0Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ODtQWCdF0nnpZvTkeqOVP4ik1YTB2CW0DnxGNJRMWwM=; b=gjFpI0lVzQOG3vu+xpOYsWjMAFd5Z6hcuezJVCD3nM1klmqoz+4FYZFPN/LHeQKwB9 8qEgNMacD7S+Ti93+gqawdEsjlFZYbSaSCkQACySJk41Bg93oIOeyJBosMQvvfkGvGp5 in+jZ75z8onRU5/BzGra0aKZTNtn2EVSJNgXqTSnHg8F3SaankyJF7ONZ07bz7bxRQEx 90CUPUyZEj/4T525b+zKPuJi4m20jmTZjaAZX0NC5GTWZyWHuXzLU/yCHiecECxJ4VXz IJ6LFmsdG3//9i6wb6LKV6V7ldTPGGTt28WGGijUcgKa4pIPucxRag6GunhxzLS8sXgt 0ikA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GtSGS+di; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f12si24193022edx.468.2021.07.19.08.13.14; Mon, 19 Jul 2021 08:13:36 -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=@linuxfoundation.org header.s=korg header.b=GtSGS+di; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243065AbhGSO2l (ORCPT + 99 others); Mon, 19 Jul 2021 10:28:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:56038 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239522AbhGSOXz (ORCPT ); Mon, 19 Jul 2021 10:23:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 91BDC6128E; Mon, 19 Jul 2021 15:03:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626707011; bh=x58gpLQeByz1VzpEf4ha9kXrLaM2EdD7QyXJTnbA8HE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GtSGS+diySGZznNe6R9KKjKwYqZ2Xs/yttvUtrC9FD///X0TEI6OO+BBS0IRS72PG kEbkMUTX9+Hwr4cgs2qg+bt8GGDIFC0b/26wjryJKIdCeMGhIvzotl95wZXnNv8FBm zbY5DkYAweNQPfO3devvlrkcSm6C0r9ffVdzM7qU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Geoff Levand , Michael Ellerman , Sasha Levin Subject: [PATCH 4.4 152/188] powerpc/ps3: Add dma_mask to ps3_dma_region Date: Mon, 19 Jul 2021 16:52:16 +0200 Message-Id: <20210719144941.462409970@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144913.076563739@linuxfoundation.org> References: <20210719144913.076563739@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 a1bc7e758422..2d729b53a556 100644 --- a/arch/powerpc/include/asm/ps3.h +++ b/arch/powerpc/include/asm/ps3.h @@ -83,6 +83,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 @@ -97,6 +98,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 19bae78b1f25..76cbf1be9962 100644 --- a/arch/powerpc/platforms/ps3/mm.c +++ b/arch/powerpc/platforms/ps3/mm.c @@ -18,6 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include #include #include #include @@ -1132,6 +1133,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; @@ -1143,6 +1145,16 @@ int ps3_dma_region_init(struct ps3_system_bus_device *dev, r->offset -= map.r1.offset; 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) { case PS3_DEVICE_TYPE_SB: r->region_ops = (USE_DYNAMIC_DMA) -- 2.30.2