Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1681894pxk; Tue, 1 Sep 2020 05:18:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweusxwYuXWfMLCT2rYrgdY06Ln/d7rFx90v9BROvXup9UipuPIWxsWu9uf7FKsmUywDivy X-Received: by 2002:a05:6402:d07:: with SMTP id eb7mr1575256edb.160.1598962717683; Tue, 01 Sep 2020 05:18:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598962717; cv=none; d=google.com; s=arc-20160816; b=fML8hambSb6taRUN3ZvulRuKcnSx6mHmOYwZ7n3IieLtUjh6tH+GIrp0V9VBcFl/Iz ZmdkdLw4aKdLrAJGTjgK8HTK1yvAS8lgjVyD7E/VipZXAVjZuXttF+JO7e9JDUbOIJV7 pJIsGcut+MsIy41J/wrU3NgQX6z7cuH5zdHf4GSB1IISVedVMwijgpuEb2aCNNiX4Gcm veJZfmZWUp5rIa+809oTA3vWb3i4m71yn9NTFM1VXUCOOct+BsE0psnI02QyLXnrmuWu l39/L/bjFc4l8YCkSJwHZ3hhL1l7/IGG2VnnOKQacKZWYBMLkAZjsnBfXar/gIHf1cL+ 4ttw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=XklrsUDfyjjcCTWoTmWtKva3UnB9b/9Rp4bPAA+ecZs=; b=sJ+2Eln0Be88paDjzSZdZpT3Cv63vnJ1Rm58GH/0b6mHUTcq5EQpRJ/pPCI0BlYWVr V+4+0zV3vKXPBEgUHZmNBVnjM53FFUidzHipp40YpuU39Ha6RI4RQMT8dCKdiU1kbdZU I/M0ffSy5xSXNjAkzN5Hh6DUDv15ZcM0HvfkhZSGJjrVUj8xVHz5wYHQj5V57RxmfwNr F13UUt9s3A41BFW2JYngJ9dDbP0NeHV/kLIYkqW8mPANxef5rBYo4zTISvls8aflAODl x2KHoSz4d7NQazM0iJ0wn10I/3xETf4CwqWz8TpCBUZDYQioC+amsHcQ4DUuoSsDEy/J sFhQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id nr20si536540ejb.483.2020.09.01.05.18.13; Tue, 01 Sep 2020 05:18:37 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726107AbgIAMLw (ORCPT + 99 others); Tue, 1 Sep 2020 08:11:52 -0400 Received: from foss.arm.com ([217.140.110.172]:40882 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728060AbgIAMAx (ORCPT ); Tue, 1 Sep 2020 08:00:53 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 463E01FB; Tue, 1 Sep 2020 05:00:30 -0700 (PDT) Received: from [10.57.40.122] (unknown [10.57.40.122]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 937E73F68F; Tue, 1 Sep 2020 05:00:28 -0700 (PDT) Subject: Re: [PATCH 2/2] usb: dwc3: Add driver for Xilinx platforms To: Manish Narani , "gregkh@linuxfoundation.org" , "robh+dt@kernel.org" , Michal Simek , "balbi@kernel.org" , "p.zabel@pengutronix.de" Cc: "devicetree@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , git , "linux-arm-kernel@lists.infradead.org" References: <1598467441-124203-1-git-send-email-manish.narani@xilinx.com> <1598467441-124203-3-git-send-email-manish.narani@xilinx.com> <0927fb9f-1044-38b3-d6f3-76edffefd99c@arm.com> From: Robin Murphy Message-ID: <98c17481-e9c5-ce03-ad30-3653ec2305d4@arm.com> Date: Tue, 1 Sep 2020 13:00:27 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-08-28 18:53, Manish Narani wrote: > Hi Robin, > > Thanks for the review. Please find my comment below inline. > >> -----Original Message----- >> From: Robin Murphy >> Sent: Friday, August 28, 2020 12:17 AM >> To: Manish Narani ; gregkh@linuxfoundation.org; >> robh+dt@kernel.org; Michal Simek ; balbi@kernel.org; >> p.zabel@pengutronix.de >> Cc: devicetree@vger.kernel.org; linux-usb@vger.kernel.org; linux- >> kernel@vger.kernel.org; git ; linux-arm- >> kernel@lists.infradead.org >> Subject: Re: [PATCH 2/2] usb: dwc3: Add driver for Xilinx platforms >> >> On 2020-08-26 19:44, Manish Narani wrote: >> [...] >>> + /* >>> + * This routes the usb dma traffic to go through CCI path instead >>> + * of reaching DDR directly. This traffic routing is needed to >>> + * make SMMU and CCI work with USB dma. >>> + */ >>> + if (of_dma_is_coherent(dev->of_node) || dev->iommu_group) { >>> + reg = readl(priv_data->regs + XLNX_USB_COHERENCY); >>> + reg |= XLNX_USB_COHERENCY_ENABLE; >>> + writel(reg, priv_data->regs + XLNX_USB_COHERENCY); >>> + } >> >> This looks rather suspect - coherency should be based on coherency, not >> on whether an IOMMU group is present. If the device isn't described as >> coherent in the DT, then any SMMU mappings will end up using attributes >> that will downgrade traffic to be non-snooping anyway. And if the SMMU >> is enabled but not translating (e.g. "iommu.passthrough=1") then >> enabling hardware coherency when the DMA layer hasn't been told about it >> can potentially lead to nasty subtle problems and data loss. > > May be the description needs to be updated in this. This is not the actual coherency enabling bit, but this is needed when coherency is enabled. > This is a register inside Xilinx USB controller which handles USB (which is in LPD) traffic route switching from LPD (Low Power Domain) to FPD (Full Power Domain) path in the Xilinx SoC in either of the below scenarios: > 1. Device is described coherent in DT. > 2. SMMU is enabled. > > I will update the same in v2. Ah, OK, so it's just that the control bit itself has a terrible name :) From the available information I had assumed that this controlled the output attributes, and that the interconnect might then steer traffic based on those. Explaining a bit more clearly in the comment probably would be a good idea. In that case, I'd concur that the current logic is in fact appropriate, but please use the device_iommu_mapped() helper for cleanliness. Cheers, Robin.