From patchwork Thu Aug 20 19:38:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Duc Dang X-Patchwork-Id: 7046761 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0D16D9F372 for ; Thu, 20 Aug 2015 19:42:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 37F472058E for ; Thu, 20 Aug 2015 19:42:07 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6813A20585 for ; Thu, 20 Aug 2015 19:42:06 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZSVh3-0000X8-KD; Thu, 20 Aug 2015 19:40:09 +0000 Received: from mail-pa0-x229.google.com ([2607:f8b0:400e:c03::229]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZSVh0-0007jZ-Br for linux-arm-kernel@lists.infradead.org; Thu, 20 Aug 2015 19:40:07 +0000 Received: by padfo6 with SMTP id fo6so28964795pad.0 for ; Thu, 20 Aug 2015 12:39:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apm.com; s=apm; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TqMMTNUfouf5PYk6sMeVqLgQTUQMnJd2JVHUs3Vfof8=; b=bkgi2QdAE0FjDJunVJg+P3WDtwKBXtrMReKW/3W23oNz0kYGknRK3FrFvGwgXT77pF /GcXxuvV/epuxKSSRhvmU/KJhyX0QgaorfhMN2dgqD+Q5zQ+H2TorRs67ZPEjHSezXgU zePn9TtloEj4dhYsuC6gqLbr+XLztnpkZu5iE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TqMMTNUfouf5PYk6sMeVqLgQTUQMnJd2JVHUs3Vfof8=; b=Ak1T9q3BvO5/A//M6eT/mzUal3kVa5PIlE85cyT9eGC2hL0sFNK8j6GHzjDemZpusL LATZLB4U9cdU+Ed1e7F/U24MGarfpXR1+EEg3jJwAh2ZjiuIIwhZfDPhT0yEYKuTjsLJ EyYuL7FsZbHirZ8PuOd1q6XGlT8za47VJGBkrm9vpbP+7oAEjcrVQm2LzFzRE5zt3zFC G+d52SVhHZAONJBr1htyQqz4sEncCbOJyxe5Ev9RrQKIezeM3T0KSgeJ28PSIdZJkpqc v5e4iA0Dz968VjfO7tRjDr6j5qL7yjyPygMJ1Fme9fLnErjq4xjCfppQmJDpuXgjECT9 g2mg== X-Gm-Message-State: ALoCoQlUdTZ8S6lEezjtjtcToInCQ4ZCrWD0+dQyA/KSLFpfkUlJ2CdhOM8uC7setyfcJDDq8V2/ X-Received: by 10.66.66.196 with SMTP id h4mr9787697pat.120.1440099584883; Thu, 20 Aug 2015 12:39:44 -0700 (PDT) Received: from dhdang-Precision-WorkStation-T3400.amcc.com (70-35-53-82.static.wiline.com. [70.35.53.82]) by smtp.gmail.com with ESMTPSA id fn1sm5265870pab.8.2015.08.20.12.39.43 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Aug 2015 12:39:44 -0700 (PDT) From: Duc Dang To: Greg KH , Russell King - ARM Linux , Loc Ho , Arnd Bergmann Subject: [PATCH v7 1/2] usb: make xhci platform driver use 64 bit or 32 bit DMA Date: Thu, 20 Aug 2015 12:38:53 -0700 Message-Id: <69e6f5bf693d02fba001d02047453bed0519499d.1440098398.git.dhdang@apm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1522889.9kdnRk8vHo@wuerfel> References: <1522889.9kdnRk8vHo@wuerfel> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150820_124006_440803_304DC9FC X-CRM114-Status: GOOD ( 16.30 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Feng Kan , Mark Langsdorf , mathias.nyman@intel.com, Duc Dang , USB list , patches , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,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 The xhci platform driver needs to work on systems that either only support 64-bit DMA or only support 32-bit DMA. Attempt to set a coherent dma mask for 64-bit DMA, and attempt again with 32-bit DMA if that fails. [dhdang: regenerate the patch over 4.2-rc5 and address new comments] Signed-off-by: Mark Langsdorf Tested-by: Mark Salter Signed-off-by: Duc Dang --- Changes from v6: -Add WARN_ON if dma_mask is NULL -Use dma_coerce_mask_and_coherent to assign dma_mask and coherent_dma_mask Changes from v5: -Change comment -Assign dma_mask to coherent_dma_mask if dma_mask is NULL to make sure dma_set_mask_and_coherent does not fail prematurely. Changes from v4: -None Changes from v3: -Re-generate the patch over 4.2-rc5 -No code change. Changes from v2: -None Changes from v1: -Consolidated to use dma_set_mask_and_coherent -Got rid of the check against sizeof(dma_addr_t) drivers/usb/host/xhci-plat.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 890ad9d..e4c7f9d 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -93,14 +93,19 @@ static int xhci_plat_probe(struct platform_device *pdev) if (irq < 0) return -ENODEV; - /* Initialize dma_mask and coherent_dma_mask to 32-bits */ - ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); - if (ret) - return ret; - if (!pdev->dev.dma_mask) - pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; - else - dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); + /* Throw a waring if broken platform code didn't initialize dma_mask */ + WARN_ON(!pdev->dev.dma_mask); + /* + * Try setting dma_mask and coherent_dma_mask to 64 bits, + * then try 32 bits + */ + ret = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); + if (ret) { + ret = dma_coerce_mask_and_coherent(&pdev->dev, + DMA_BIT_MASK(32)); + if (ret) + return ret; + } hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); if (!hcd)