From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D08C6C433E1 for ; Mon, 27 Jul 2020 14:59:29 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9E747206E7 for ; Mon, 27 Jul 2020 14:59:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="gQdkvkyF"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="Kc8IkCAx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9E747206E7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=HmEboK5TqEfM7ELicTKT3EW9R7GFbC14BBbynvln8+k=; b=gQdkvkyFtlegMyDjS5Dx9hN3L s7l05qPNJCVbwMmUITJHisGOrAToJAuf/nOtx9Nl83CkbUD/raDO813G3L58Nqft06QfJG/b3gFaQ 2IfZ+apLm8vqcZI9qg46bHtlpw0IclDl/g0Sc4uGyaLI3FGzCRzqpZWN8weyJ575hb/JkOUbQzodW VVlSxg+LFNCjfw3GF3x/SN0hCUWrZiaAPiOx4DxKnKSdG28XF8qPJUvnl1SsAwqw4f1bS4WsFef4g nHtsvbeUURPTUfz9t0MdGEuktLqCALdcnI/RRPLOeu/HnX1Y7wx/wDUwWifZijbrcQsVR97EN6jkm tLqW6z6ZQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k04Zx-000501-9d; Mon, 27 Jul 2020 14:58:13 +0000 Received: from m43-7.mailgun.net ([69.72.43.7]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k04Zs-0004zU-Ds for linux-arm-kernel@lists.infradead.org; Mon, 27 Jul 2020 14:58:12 +0000 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1595861891; h=In-Reply-To: Content-Type: MIME-Version: References: Message-ID: Subject: Cc: To: From: Date: Sender; bh=7443zfi2pZMKrWNjK4v1Ad32a0BS0R3bKBhFoOV5yxQ=; b=Kc8IkCAxP9hnzdh6XM4TFW3I3YFs34cUoKMCYBnG5tJXoXQ/yMy3KOkIiuRo2fzyZD2xbB74 9ArUR6Z1pZx25qD0d8DjZJX2mXBXhz6K7Xcj5bnNKQ4rqx0kc36fS/aDju+pdDByQg9/Imdo M/ReY/08j43VEfSuVc+iTiikiF0= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyJiYzAxZiIsICJsaW51eC1hcm0ta2VybmVsQGxpc3RzLmluZnJhZGVhZC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n03.prod.us-east-1.postgun.com with SMTP id 5f1eeb6a7ab15087eb97f567 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 27 Jul 2020 14:57:46 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id A890FC43395; Mon, 27 Jul 2020 14:57:45 +0000 (UTC) Received: from jcrouse1-lnx.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: jcrouse) by smtp.codeaurora.org (Postfix) with ESMTPSA id 2C638C433C9; Mon, 27 Jul 2020 14:57:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 2C638C433C9 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=jcrouse@codeaurora.org Date: Mon, 27 Jul 2020 08:57:41 -0600 From: Jordan Crouse To: Bjorn Andersson Subject: Re: [PATCH v10 04/13] iommu/arm-smmu-qcom: Add implementation for the adreno GPU SMMU Message-ID: <20200727145740.GA32521@jcrouse1-lnx.qualcomm.com> Mail-Followup-To: Bjorn Andersson , linux-arm-msm@vger.kernel.org, Robin Murphy , Will Deacon , freedreno@lists.freedesktop.org, iommu@lists.linux-foundation.org, Sai Prakash Ranjan , Joerg Roedel , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20200720154047.3611092-1-jcrouse@codeaurora.org> <20200720154047.3611092-5-jcrouse@codeaurora.org> <20200727062703.GB3521288@ripper> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200727062703.GB3521288@ripper> User-Agent: Mutt/1.5.24 (2015-08-30) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200727_105811_488240_FAC2857D X-CRM114-Status: GOOD ( 23.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sai Prakash Ranjan , Will Deacon , linux-arm-msm@vger.kernel.org, Joerg Roedel , Robin Murphy , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, freedreno@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sun, Jul 26, 2020 at 11:27:03PM -0700, Bjorn Andersson wrote: > On Mon 20 Jul 08:40 PDT 2020, Jordan Crouse wrote: > > diff --git a/drivers/iommu/arm-smmu-qcom.c b/drivers/iommu/arm-smmu-qcom.c > [..] > > +static int qcom_adreno_smmu_alloc_context_bank(struct arm_smmu_domain *smmu_domain, > > + struct device *dev, int start, int count) > > +{ > > + struct arm_smmu_device *smmu = smmu_domain->smmu; > > + > > + /* > > + * Assign context bank 0 to the GPU device so the GPU hardware can > > + * switch pagetables > > + */ > > + if (qcom_adreno_smmu_is_gpu_device(dev)) { > > + if (start > 0 || test_bit(0, smmu->context_map)) > > + return -ENOSPC; > > + > > + set_bit(0, smmu->context_map); > > + return 0; > > + } > > + > > + return __arm_smmu_alloc_bitmap(smmu->context_map, start, count); > > If we end up here before the GPU device shows up this is going to > steal the first context bank, causing the subsequent allocation for the > GPU to always fail. > > As such I think it would be appropriate for you to adjust "start" to > never be 0 here. And I think it would be appropriate to write this > function as: > > if (gpu) { > start = 0; > count = 1; > } else { > if (start == 0) > start = 1; > } > > return __arm_smmu_alloc_bitmap(smmu->context_map, start, count); Excellent suggestions. Thanks. Jordan > Regards, > Bjorn -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel