From patchwork Thu Sep 17 18:19:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Duc Dang X-Patchwork-Id: 7209721 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 2AB749F380 for ; Thu, 17 Sep 2015 18:23:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5109820747 for ; Thu, 17 Sep 2015 18:23:24 +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 767342072F for ; Thu, 17 Sep 2015 18:23:23 +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 1ZcdoZ-0007Yx-8V; Thu, 17 Sep 2015 18:21:47 +0000 Received: from mail-pa0-x22f.google.com ([2607:f8b0:400e:c03::22f]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZcdoH-00076C-0G for linux-arm-kernel@lists.infradead.org; Thu, 17 Sep 2015 18:21:29 +0000 Received: by pacex6 with SMTP id ex6so26366995pac.0 for ; Thu, 17 Sep 2015 11:21:08 -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 :in-reply-to:references; bh=/frU3Dni5vMUnoNljB7ptVVvlJ+nUUvuwpZsD8N0hNw=; b=MCkueM7Wh/DYtuWb30gakDCDu/usXWsC+kjiuIUTQASsO821qG5gs1LRKRnaZtxeak 4QKRo5JqNKpVVFPasKocfLpOtJG+REoSNS1hAFDqtnbo6FY4CTcjfIuoXaG5/P37T0MZ DjWBPxb+zxZOqTOy2r9/89is0bCGjq3Ophalk= 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:in-reply-to:references; bh=/frU3Dni5vMUnoNljB7ptVVvlJ+nUUvuwpZsD8N0hNw=; b=TzxzAemyPw3T8kCuZGuCwyWuwSHyjOQ6foJb5wAxJSBeR28DhhmkbbOWIu5lmhAH2Q PV8OviB8fMwG0vHrqCOnocXxDR4hhx35IQjp6J5Dm1q7mTlRrvekpqiWgpj7Qql7hb1/ X4fmB3yPcWnYmIRMrAmuvW3J9pU9HnCclHXzcki5jXuwSQJKMv8d93J8lohxFWuknJSF pEbNg3EYMgUA60+7bOC/Lyg8/jM6YY6xaUAmdU0LahL7ABe7U/3f2Tu9yJNUj+D008g+ 6mp4iKEShOZg3PX6GaIECuSxXgrws/Ue6xL36JJ8NuQOStLKxE8bmZS0pq0J9ncb1iD3 hwlA== X-Gm-Message-State: ALoCoQnh+0nW6e73KK2ox831Y6PUUjNpGuIuU2fM1l+qcp3lzADtpuivpjLzHcyY6MqNWOKKTA3M X-Received: by 10.68.181.130 with SMTP id dw2mr1034444pbc.70.1442514068262; Thu, 17 Sep 2015 11:21:08 -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 bs3sm4649923pbd.89.2015.09.17.11.21.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Sep 2015 11:21:07 -0700 (PDT) From: Duc Dang To: Greg KH , Russell King - ARM Linux , Loc Ho , Arnd Bergmann , mathias.nyman@intel.com Subject: [PATCH v8 1/3] usb: make xhci platform driver use 64 bit or 32 bit DMA Date: Thu, 17 Sep 2015 11:19:46 -0700 Message-Id: <41fbbb49c112705a8c14a342e98bd557c15c8f0c.1442513540.git.dhdang@apm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150917_112129_124688_49DD9A54 X-CRM114-Status: GOOD ( 14.83 ) 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 , 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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 v4.3-rc1 and address new comments] Signed-off-by: Mark Langsdorf Tested-by: Mark Salter Signed-off-by: Duc Dang Acked-by: Arnd Bergmann --- drivers/usb/host/xhci-plat.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 890ad9d..34c93e8 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -93,14 +93,20 @@ 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; + /* Try to set 64-bit DMA first */ + if (WARN_ON(!pdev->dev.dma_mask)) + /* Platform did not initialize dma_mask */ + ret = dma_coerce_mask_and_coherent(&pdev->dev, + DMA_BIT_MASK(64)); else - dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); + ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); + + /* If seting 64-bit DMA mask fails, fall back to 32-bit DMA mask */ + if (ret) { + ret = dma_set_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)