Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp61357ybj; Thu, 19 Sep 2019 10:40:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqxC3UwF1Y2xwWP1MlQJ8ndvjh8sv5JG1wo25WNEdEKzMfK+dTy6U/MWYNss1dvJBAOVrPbb X-Received: by 2002:a50:ac0d:: with SMTP id v13mr17143527edc.189.1568914853276; Thu, 19 Sep 2019 10:40:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568914853; cv=none; d=google.com; s=arc-20160816; b=I9Yle4FAKFI3sz9NAVtkxEhYgHZVtuOWF4ydPdTJ0V59/avcFVhkYKyaMDQJ69DtsV ukCXkkkcS7XyWWjoEeIDUGNrhKhZtYYV4kH4foK16F7L4l3zFYmle8mJa4vUS13iyo7j yySDp6Bd/xujtZ68mmT46X4gt/t1so0ImcVWnjh8RF7uPArAk5ZL8llmw2trD5/qr2tO BM8UKGgq8N7n0iBMcmeJnliWORm5wgEtBPQh47rAhGfWPbFo09Vwa5kbQ5Vuo7kXcBfA XiT1aI17BLhLgGtNVbiizlWDgminZgdwVtSsTfLoUCI2cMHv+sJiYsKb0i20q/C6mRxk jCqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=AtJmx7YzvmNMJX7vvcIKkFLqCflOxxyrvK1PoirDPTw=; b=ZxNEJVcIj8JASBfCgBdDiluWaqLPjLrBvxLiSthnMcc2BQ1jQSB1EZWl8hQ7+LD6kR i/N1PMHBTzOOZAWm8jG5qyV49wReb2UaUiTUOEeOPrZHZqhj0+/1nuKGO1DnDobaATLi c/H3DGu7y38pnXDEjYp4D4Z1mlh6pdFdJBPYWfFYWMukuCGujheVbUWqrW6rcWVCIHzm 4lHJT8x8jruMEENpM8rdhXk7mUvBmg4uWyOGXNW9II4ol/J3uFiVuH8UqoDXl1/ecyg5 9OC5iPuZtC0/PQb8nlK/AA+TxprcmXAk9jZDvFDDniL9EFf1nL0IQSZnzd4NIQZuBySn zByA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oP8A5i+9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e10si3078644ejr.222.2019.09.19.10.40.29; Thu, 19 Sep 2019 10:40:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oP8A5i+9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404001AbfISPKI (ORCPT + 99 others); Thu, 19 Sep 2019 11:10:08 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:38267 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403990AbfISPKH (ORCPT ); Thu, 19 Sep 2019 11:10:07 -0400 Received: by mail-ed1-f65.google.com with SMTP id a23so3537293edv.5 for ; Thu, 19 Sep 2019 08:10:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=AtJmx7YzvmNMJX7vvcIKkFLqCflOxxyrvK1PoirDPTw=; b=oP8A5i+95DshExg2j5Uy8V9cUWkT0LstsMnL2HErbO3Vbig4wntTV4m9mYDptkb17n DAQHzC8LQ2HHXAIlqY5oIicOzr1wdnGP8KPctTWRc8JkI8n/5S2+1EkzYZyn93b7xA1L NRMSQHt8iAoE7YAYXWfur0TQYTo8GWxJZe5JgQytR/3NugB/OyojB6PhG45vS5P5rCgU vIx+13MlRVX+3pbxQFpNkjMlKkilkbYM3IuJysA6VOviuAKnocL55IrKfuuCVLzkrQjJ X3ULAwILuiC2s4Vo0QyTdo9hMV7Jp7SwibWqDyGQH8nHWaysISxxH80tBDisIJEEM9WM HTiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=AtJmx7YzvmNMJX7vvcIKkFLqCflOxxyrvK1PoirDPTw=; b=a7tA22dNvJGw3/T4tu4gqfXvBPisTFUG4tMLdoS45a3LcWEqPkOj+lMbNeRytUcOd4 0QMG9qHDWSw5NONW58hhTsRsafIZdlP2+wrSdBZU4dIwnbrID1Cjzpywi/86Gsv1e43r fadsv/swLyBjXIGkb6uUVV01zRHL2MpthC9WPZg3xeS5PmoP6Xg5U/vgdsroEhPPhT27 89nLxZmjbPx82pCKi1HugrekCxEaSLcK46E7S+Sg7s1pOuppxS54em7g5dh2hr5RmN3U zWWknwz+cRjMbFiN52WVq+dlm3UmIKnrNdEp7WA1mV9ekdlNpCOd6pa3FML14+hc5slF wouQ== X-Gm-Message-State: APjAAAUQNz8fHll7OEk4gwMbFzMp1M6UnF3nfz/bXzfSukIivC0LY/xZ aqHggoJMhlNP/Exj91mhtOsP9A== X-Received: by 2002:a17:906:244c:: with SMTP id a12mr14473110ejb.288.1568905805521; Thu, 19 Sep 2019 08:10:05 -0700 (PDT) Received: from lophozonia ([85.195.192.192]) by smtp.gmail.com with ESMTPSA id j10sm1683364ede.59.2019.09.19.08.10.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2019 08:10:04 -0700 (PDT) Date: Thu, 19 Sep 2019 17:10:02 +0200 From: Jean-Philippe Brucker To: Auger Eric Cc: Jean-Philippe Brucker , will.deacon@arm.com, mark.rutland@arm.com, devicetree@vger.kernel.org, jacob.jun.pan@linux.intel.com, joro@8bytes.org, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, robh+dt@kernel.org, robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 8/8] iommu/arm-smmu-v3: Add support for PCI PASID Message-ID: <20190919151002.GF1013538@lophozonia> References: <20190610184714.6786-1-jean-philippe.brucker@arm.com> <20190610184714.6786-9-jean-philippe.brucker@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 08, 2019 at 09:58:16AM +0200, Auger Eric wrote: > > + ret = pci_enable_pasid(pdev, features); > > + if (!ret) > > + master->ssid_bits = min_t(u8, ilog2(num_pasids), > > + master->smmu->ssid_bits); > I don't really get why this setting is conditional to the success of > pci_enabled_pasid and not num_pasids > 0. num_pasids only contains the value of the PCIe PASID capability. If pci_enable_pasid() fails then we want to leave master->ssid_bits to 0 so that we report to users that SVA and AUXD aren't supported. > If it fails the ssid_bits is set to min(smmu->ssid_bits, > fwspec->num_pasid_bits) anyway. > > > + return ret; > > +} > > + > > +static void arm_smmu_disable_pasid(struct arm_smmu_master *master) > > +{ > > + struct pci_dev *pdev; > > + > > + if (!dev_is_pci(master->dev)) > > + return; > > + > > + pdev = to_pci_dev(master->dev); > > + > > + if (!pdev->pasid_enabled) > > + return; > > + > > + pci_disable_pasid(pdev); > > + master->ssid_bits = 0; > in case of a platform device you leave the ssid_bits to a value != 0. Is > that what you want? Yes, this is only for PCI devices, there is no standard way of disabling PASID in platform devices. We just take whatever the firmware gives us. > > +} > > + > > static void arm_smmu_detach_dev(struct arm_smmu_master *master) > > { > > unsigned long flags; > > @@ -2413,6 +2456,9 @@ static int arm_smmu_add_device(struct device *dev) > > > > master->ssid_bits = min(smmu->ssid_bits, fwspec->num_pasid_bits); > > > > + /* Note that PASID must be enabled before, and disabled after ATS */ > > + arm_smmu_enable_pasid(master); > In case the call fails, don't you want to handle the error and reset the > ssid_bits? This function fails if the device doesn't support PASID, and we leave ssid_bits to 0. That said, I think it would be nicer to move the above line (that deals with fwspec) into arm_smmu_enable_pasid() Thanks, Jean