Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp793950rwb; Thu, 27 Jul 2023 23:06:35 -0700 (PDT) X-Google-Smtp-Source: APBJJlHmxyeL8B+JKq9bEP8f5JAeevhV2EJRYLSeSbV7gAq1bzSSR32GAeM7NMZfDjg57gI9O7Fb X-Received: by 2002:a17:907:7893:b0:98e:370c:be69 with SMTP id ku19-20020a170907789300b0098e370cbe69mr1871054ejc.6.1690524395188; Thu, 27 Jul 2023 23:06:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690524395; cv=none; d=google.com; s=arc-20160816; b=qIO4Z9dHPKuy8N+8F24S8XTtqklns3uY2EHDIpyluPv4DPQLZeXUwCc7NuYhnXw5PO gVDjSS6r+WW+PrYYRibyszqkjUIU92sa7mZaoGXi/Rl3FhlkP23uAqbqGaoa0ZZkP26y ml6DThybgU6X0lJugpWAyfoha18lZoqgn/0fLz4hSnvi5/tI32MEuu8FC0LYi4Vy9Hqm Gw4NopOcl/WXxVjRApOJ3fAPCvTFs94+5XU/9zNjUE6iTLpicChlKR3J5WtzBCUgDKdL A5/5w4B3zDSLojHDvWK2uaCDsHZLckugJvhlGP+UkN+D6lrq5wGrzXC83xYzKPWGFouv k6GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=dA4h1wXuO+RqiKn56Fbjhd22WJLs7KDtxnH5lEYDThw=; fh=8sXiYuqB7AYwGZLA/tqyzE9C40Mtf2Zjo4D7qPWj5Kw=; b=RuBQZk8CQ2cwKMzQn1NvPmLMTm/9aa+VrmH5o4gjLhN422xR6idbDBWp32Kpya3mEs 1fhjvdBIF4LfShUVum6neepJ3bShEqKU/eLnJx4VkvAeWhfivIf4BeFzG2uHiamGugnm wKQHkAL2DD4EPJAjIZvUi+lcpvqpwM+cg5FoDaGQbJSuaYnv0/H1pQMaVclQPyu2nQaN Bn0hYXAdUqNLuveKLbItsjQADq+2x0eWDyYl3fQ0OFaSqA1xW+nzn1+FsGU2Zga6Fcs7 YglYHE8hPNBPHdq4SoKCjkcUHzBN9sJlixsB+liL3iPKEnd/m7NNT8SurXSllgFTMoZv 0qSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=rCCGFQOa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t10-20020a17090616ca00b0099bd24d66aasi2209429ejd.383.2023.07.27.23.06.10; Thu, 27 Jul 2023 23:06:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=rCCGFQOa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232339AbjG1FTG (ORCPT + 99 others); Fri, 28 Jul 2023 01:19:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229817AbjG1FTE (ORCPT ); Fri, 28 Jul 2023 01:19:04 -0400 Received: from mail-oo1-xc31.google.com (mail-oo1-xc31.google.com [IPv6:2607:f8b0:4864:20::c31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4694430D4 for ; Thu, 27 Jul 2023 22:19:03 -0700 (PDT) Received: by mail-oo1-xc31.google.com with SMTP id 006d021491bc7-55e1ae72dceso1217800eaf.3 for ; Thu, 27 Jul 2023 22:19:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1690521542; x=1691126342; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=dA4h1wXuO+RqiKn56Fbjhd22WJLs7KDtxnH5lEYDThw=; b=rCCGFQOaheftq0HBV0LLW8L+L/v6ll8/foJApxGYX++40jda1h5c0MWTF5uv35NOCF yaH9NHb3PZpu3nzpkBd3mt1WnPtZ9z3ydmeagEC8cU1Hfk8th+iT9nfxFuTWfKWNMdq8 n8wnb1rM3D6J0b3bhLL4G4KA3L8KDqw1kOgvKizfcveQ1uA1cuV2lFWT2zG67WZr6YEU ng2su2EY9hqNPdMBPtdMPPSk0j8ev6ZR+5zcP8/HacSMRejTg4ZwLEfDbEunGix1l0YX DndlAnMka4ykXJbXYC7WjlDVBN+bD7cZ0CXFDvOTrx37mCops+MAyXcQT3agmOs2Veow PzwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690521542; x=1691126342; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dA4h1wXuO+RqiKn56Fbjhd22WJLs7KDtxnH5lEYDThw=; b=SDSHpzj8nF40Qjl3qw4z+f6ECszcTn0vucnAD+lLMMn+d98RpIPg/SiJqDDSWVv5Aa pJH/YOT16AEnzIC57U2kwhxH2vhP2dNJxtGerdcO6yFaC7sSlX+dKG2CANiARg8irCW6 Uk9tNZwrAuzKV2TWWLEm/bGPr9sAp+nJaSzyShSVFcGYUKuK/zFsmkGAX/nlRxXUUEWv yPBrttZzIGrmujbj8gzbZ55uQCPxZC0AkOy/twb4nEYrYLDsyP0mKnd3V8K0HBFGYQJO UDJhd6taAoIuoZMXplqXCfdWk8kpVpblscVpn27/+IJ37zoCaxtmTUHMZfnq1u/JTauL ij4Q== X-Gm-Message-State: ABy/qLbWcynjHLdXx5x+u98JZqG/mkk/PoMjGKDn+B6cvBJf2AbSpA/B 8Re/lq1FsQTVYazetprQmbelril1Jrw+oFrVrlX6/pQHyZDfrmp4jDo= X-Received: by 2002:a05:6808:f05:b0:3a0:5ee3:ea67 with SMTP id m5-20020a0568080f0500b003a05ee3ea67mr2125638oiw.16.1690521542545; Thu, 27 Jul 2023 22:19:02 -0700 (PDT) MIME-Version: 1.0 References: <1fd79e5c53d9d6ed2264f60dd4261f293cc00472.1689792825.git.tjeznach@rivosinc.com> <5b8fd18e-8dfa-96bf-cdd4-4498b1d15ab9@ics.forth.gr> In-Reply-To: From: Tomasz Jeznach Date: Fri, 28 Jul 2023 07:18:51 +0200 Message-ID: Subject: Re: [PATCH 06/11] RISC-V: drivers/iommu/riscv: Add command, fault, page-req queues To: Zong Li Cc: Nick Kossifidis , Anup Patel , Albert Ou , linux@rivosinc.com, Will Deacon , Joerg Roedel , linux-kernel@vger.kernel.org, Sebastien Boeuf , iommu@lists.linux.dev, Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, Robin Murphy Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 24, 2023 at 11:47=E2=80=AFAM Zong Li wrote= : > > On Fri, Jul 21, 2023 at 2:00=E2=80=AFAM Tomasz Jeznach wrote: > > > > On Wed, Jul 19, 2023 at 8:12=E2=80=AFPM Nick Kossifidis wrote: > > > > > > Hello Tomasz, > > > > > > On 7/19/23 22:33, Tomasz Jeznach wrote: > > > > Enables message or wire signal interrupts for PCIe and platforms de= vices. > > > > > > > > > > The description doesn't match the subject nor the patch content (we > > > don't jus enable interrupts, we also init the queues). > > > > > > > + /* Parse Queue lengts */ > > > > + ret =3D of_property_read_u32(pdev->dev.of_node, "cmdq_len", &= iommu->cmdq_len); > > > > + if (!ret) > > > > + dev_info(dev, "command queue length set to %i\n", iom= mu->cmdq_len); > > > > + > > > > + ret =3D of_property_read_u32(pdev->dev.of_node, "fltq_len", &= iommu->fltq_len); > > > > + if (!ret) > > > > + dev_info(dev, "fault/event queue length set to %i\n",= iommu->fltq_len); > > > > + > > > > + ret =3D of_property_read_u32(pdev->dev.of_node, "priq_len", &= iommu->priq_len); > > > > + if (!ret) > > > > + dev_info(dev, "page request queue length set to %i\n"= , iommu->priq_len); > > > > + > > > > dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); > > > > > > > > > > We need to add those to the device tree binding doc (or throw them aw= ay, > > > I thought it would be better to have them as part of the device > > > desciption than a module parameter). > > > > > > > We can add them as an optional fields to DT. > > Alternatively, I've been looking into an option to auto-scale CQ/PQ > > based on number of attached devices, but this gets trickier for > > hot-pluggable systems. I've added module parameters as a bare-minimum, > > but still looking for better solutions. > > > > > > > > > +static irqreturn_t riscv_iommu_priq_irq_check(int irq, void *data)= ; > > > > +static irqreturn_t riscv_iommu_priq_process(int irq, void *data); > > > > + > > > > > > > + case RISCV_IOMMU_PAGE_REQUEST_QUEUE: > > > > + q =3D &iommu->priq; > > > > + q->len =3D sizeof(struct riscv_iommu_pq_record); > > > > + count =3D iommu->priq_len; > > > > + irq =3D iommu->irq_priq; > > > > + irq_check =3D riscv_iommu_priq_irq_check; > > > > + irq_process =3D riscv_iommu_priq_process; > > > > + q->qbr =3D RISCV_IOMMU_REG_PQB; > > > > + q->qcr =3D RISCV_IOMMU_REG_PQCSR; > > > > + name =3D "priq"; > > > > + break; > > > > > > > > > It makes more sense to add the code for the page request queue in the > > > patch that adds ATS/PRI support IMHO. This comment also applies to it= s > > > interrupt handlers below. > > > > > > > ack. will do. > > > > > > > > > +static inline void riscv_iommu_cmd_inval_set_addr(struct riscv_iom= mu_command *cmd, > > > > + u64 addr) > > > > +{ > > > > + cmd->dword0 |=3D RISCV_IOMMU_CMD_IOTINVAL_AV; > > > > + cmd->dword1 =3D addr; > > > > +} > > > > + > > > > > > This needs to be (addr >> 2) to match the spec, same as in the iofenc= e > > > command. > > > > > > > oops. Thanks! > > > > I think it should be (addr >> 12) according to the spec. > My reading of the spec '3.1.1. IOMMU Page-Table cache invalidation commands= ' is that it is a 4k page aligned address packed at dword1[61:10], so effectively shifted by 2 bits. regards, - Tomasz > > > Regards, > > > Nick > > > > > > > regards, > > - Tomasz > > > > _______________________________________________ > > linux-riscv mailing list > > linux-riscv@lists.infradead.org > > http://lists.infradead.org/mailman/listinfo/linux-riscv