From patchwork Thu May 8 20:49:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 4138821 X-Patchwork-Delegate: lethal@linux-sh.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1A001BFF02 for ; Thu, 8 May 2014 20:49:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 49215202E5 for ; Thu, 8 May 2014 20:49:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 699DE202DD for ; Thu, 8 May 2014 20:49:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755847AbaEHUtJ (ORCPT ); Thu, 8 May 2014 16:49:09 -0400 Received: from mail-ie0-f174.google.com ([209.85.223.174]:44160 "EHLO mail-ie0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755787AbaEHUtE (ORCPT ); Thu, 8 May 2014 16:49:04 -0400 Received: by mail-ie0-f174.google.com with SMTP id ar20so3195312iec.33 for ; Thu, 08 May 2014 13:49:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:from:cc:date:message-id:in-reply-to:references:user-agent :mime-version:content-type:content-transfer-encoding; bh=P/tML/Y9W2kzy9bW/it5NmGoboYlBYJNK/b8hweZL7Q=; b=NwQ41gvEJeXnvEiX3qHnhOekPFYUz7yX1yOTUxvp45DThSUN+dMP4HHB25sM3M36at 3ClxhIIcSOQZkZJPdFzIYc8Wh21lYqup2/Xz+1kpREpyblpd4j1hpab3MHGf5apyP7/o GTrlhsrTL2TUkYq8Ake1rwlBC+zGcGI/PeKb9ueTL7FPb3IiW9XmQ8vFQiyBJog8rGcW +7+R5x3ffTpTFpq22JMAlAH7l+07pRtjhOMleNltOPyg3gxTLEUStfTVcdCexuExtnM+ WRfi03ty/DvhUbOMqRgv6gsme6Wr9znW8YQYvkxxLZXo4GaKbudouvf/lmmNQTxolnW5 Ecvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:from:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-type :content-transfer-encoding; bh=P/tML/Y9W2kzy9bW/it5NmGoboYlBYJNK/b8hweZL7Q=; b=ka979v6a8U+26GhVoR9LVkrtMNxNmNaiTpgmdvb2GweOE/IBBzYt4bzYleZeaVAnV7 wOQjLgpl4U2iZsxnBdHHLuP7TeklHGD4xSvd5eRmsc8gZFebLqwlYt98pJ85dnln0bwZ FYdTUWC/315s2RAfdjT8Rn1xfI00TQI/y/7Pp2QJoRSP9cKIymsnINAoJclkp/b35Wq1 2zhlELjm6v1vS34tAe3uJWHGjAidSFXt8l3kntd/m8/JrciTv4m4nEyrGPDJrHh7peIk jf2rmkz0aaGl5mR9wqU+c1qNVJMrlqM11kyZ7QStN5QC5wOjx2xglANU2BSNJuEufheM v6dA== X-Gm-Message-State: ALoCoQkYC4UAyqi09uWPkmMdHfxBW5/bkNIfCf/J1+rdb6uZxZ1Q42Fye2vqLKJK5lEERfBJ4hQr X-Received: by 10.50.119.132 with SMTP id ku4mr12312578igb.35.1399582144148; Thu, 08 May 2014 13:49:04 -0700 (PDT) Received: from localhost ([172.16.48.245]) by mx.google.com with ESMTPSA id a8sm1363042ign.22.2014.05.08.13.49.03 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 08 May 2014 13:49:03 -0700 (PDT) Subject: [PATCH v3 3/4] sh/PCI: Pass GAPSPCI_DMA_BASE CPU & bus address to dma_declare_coherent_memory() From: Bjorn Helgaas Cc: Arnd Bergmann , linux-doc@vger.kernel.org, linux-sh@vger.kernel.org, Greg Kroah-Hartman , Joerg Roedel , Randy Dunlap , Liviu Dudau , linux-kernel@vger.kernel.org, James Bottomley , Magnus Damm , linux-pci@vger.kernel.org, David Woodhouse Date: Thu, 08 May 2014 14:49:07 -0600 Message-ID: <20140508204907.17877.4848.stgit@bhelgaas-glaptop.roam.corp.google.com> In-Reply-To: <20140508204257.17877.4639.stgit@bhelgaas-glaptop.roam.corp.google.com> References: <20140508204257.17877.4639.stgit@bhelgaas-glaptop.roam.corp.google.com> User-Agent: StGit/0.16 MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 dma_declare_coherent_memory() needs both the CPU physical address and the bus address of the device memory. They are the same on this platform, but in general we should use pcibios_resource_to_bus() to account for any address translation done by the PCI host bridge. This makes no difference on Dreamcast, but is safer if the usage is copied to future drivers. Signed-off-by: Bjorn Helgaas Acked-by: Arnd Bergmann CC: Magnus Damm CC: linux-sh@vger.kernel.org --- arch/sh/drivers/pci/fixups-dreamcast.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/sh/drivers/pci/fixups-dreamcast.c b/arch/sh/drivers/pci/fixups-dreamcast.c index d6cde700e316..f22127f966ce 100644 --- a/arch/sh/drivers/pci/fixups-dreamcast.c +++ b/arch/sh/drivers/pci/fixups-dreamcast.c @@ -31,6 +31,8 @@ static void gapspci_fixup_resources(struct pci_dev *dev) { struct pci_channel *p = dev->sysdata; + struct resource res; + struct pci_bus_region region; printk(KERN_NOTICE "PCI: Fixing up device %s\n", pci_name(dev)); @@ -50,11 +52,21 @@ static void gapspci_fixup_resources(struct pci_dev *dev) /* * Redirect dma memory allocations to special memory window. + * + * If this GAPSPCI region were mapped by a BAR, the CPU + * phys_addr_t would be pci_resource_start(), and the bus + * address would be pci_bus_address(pci_resource_start()). + * But apparently there's no BAR mapping it, so we just + * "know" its CPU address is GAPSPCI_DMA_BASE. */ + res.start = GAPSPCI_DMA_BASE; + res.end = GAPSPCI_DMA_BASE + GAPSPCI_DMA_SIZE - 1; + res.flags = IORESOURCE_MEM; + pcibios_resource_to_bus(dev, ®ion, &resource); BUG_ON(!dma_declare_coherent_memory(&dev->dev, - GAPSPCI_DMA_BASE, - GAPSPCI_DMA_BASE, - GAPSPCI_DMA_SIZE, + res.start, + region.start, + resource_size(&res), DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE)); break;