From patchwork Wed Dec 17 18:02:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Murali Karicheri X-Patchwork-Id: 5508651 Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4C8869F47A for ; Wed, 17 Dec 2014 18:03:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3B625209FD for ; Wed, 17 Dec 2014 18:03:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9E85B20A1B for ; Wed, 17 Dec 2014 18:03:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751193AbaLQSCz (ORCPT ); Wed, 17 Dec 2014 13:02:55 -0500 Received: from arroyo.ext.ti.com ([192.94.94.40]:40273 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750900AbaLQSCy (ORCPT ); Wed, 17 Dec 2014 13:02:54 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id sBHI2OF3013519; Wed, 17 Dec 2014 12:02:24 -0600 Received: from DLEE70.ent.ti.com (dlemailx.itg.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id sBHI2Oxh024173; Wed, 17 Dec 2014 12:02:24 -0600 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.174.1; Wed, 17 Dec 2014 12:02:24 -0600 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id sBHI2Mwt028069; Wed, 17 Dec 2014 12:02:24 -0600 From: Murali Karicheri To: , , , , , , , CC: Murali Karicheri Subject: [RFC PATCH 2/2] PCI: get device dma configuration from parent Date: Wed, 17 Dec 2014 13:02:24 -0500 Message-ID: <1418839344-14393-3-git-send-email-m-karicheri2@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1418839344-14393-1-git-send-email-m-karicheri2@ti.com> References: <1418839344-14393-1-git-send-email-m-karicheri2@ti.com> MIME-Version: 1.0 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch makes use of the helper function dma_get_parent_cfg() to get dma configuration from the parent of the root bus bridge device. One particular comfiguration that is required for Keystone PCI devices to function correctly is the dma_pfn_offset that has to be correctly set in the pci device's device structure in order for getting the dma_mask right for the device. Signed-off-by: Murali Karicheri --- drivers/pci/probe.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index c8ca98c..8f4d55b 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1519,6 +1519,8 @@ static void pci_init_capabilities(struct pci_dev *dev) void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) { + struct pci_bus *temp_bus = bus; + struct device *parent; int ret; pci_configure_device(dev); @@ -1527,9 +1529,21 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) dev->dev.release = pci_release_dev; set_dev_node(&dev->dev, pcibus_to_node(bus)); - dev->dev.dma_mask = &dev->dma_mask; - dev->dev.dma_parms = &dev->dma_parms; - dev->dev.coherent_dma_mask = 0xffffffffull; + /* + * look for host bridge and check if the dma parameters + * can be copied from parent + */ + while (!pci_is_root_bus(temp_bus)) + temp_bus = temp_bus->parent; + + parent = temp_bus->bridge->parent; + + /* override with parent dma configuration if available */ + if (dma_get_parent_cfg(&dev->dev, parent) < 0) { + dev->dev.dma_mask = &dev->dma_mask; + dev->dev.dma_parms = &dev->dma_parms; + dev->dev.coherent_dma_mask = 0xffffffffull; + } pci_set_dma_max_seg_size(dev, 65536); pci_set_dma_seg_boundary(dev, 0xffffffff);