Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp943086rwb; Fri, 28 Jul 2023 02:10:23 -0700 (PDT) X-Google-Smtp-Source: APBJJlHtr2sERDGKIolUOuxrAT6eYUhzRXdq+yR026jAfXvrEydk3TiV67+pqAwbgq220zUwlX49 X-Received: by 2002:a17:907:75ed:b0:993:dd0d:10a5 with SMTP id jz13-20020a17090775ed00b00993dd0d10a5mr1572410ejc.22.1690535422673; Fri, 28 Jul 2023 02:10:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690535422; cv=none; d=google.com; s=arc-20160816; b=AdbfTlPZ2r6thFdNSp5jaYZCR327qFwSGRu/1nzslyr0O4xydcWBu7dO2JWV87BEdp 8AeioiFCp1kRpOhOTwMCEMZ8JgacEfGbi2xST0abNhCQYmo4++CRERMkNIUG/caB3dkU wJG1tijCvTA+XL37rAKnQLyYZAQHfuJc4avT8ZVaBYCWEdO0bHUJGs12Xmtg+lzGazsd SazI2h/nJykxVPrE1KTDHieP9DLlhocpomONgNz8zVD6ZFVDP9g4Q3pBRiJy/0d+1Lss /mfZrJPDIHTqpiOmUzGwWlOs94Gnw012JOYQLNEF9JIWYEgrso/XOiWshmQ1NU7Mqmdz VkAA== 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=csmJdueaYe4TxgWwO4Wd3yP+V9n21yRw5VpjM04yUXk=; fh=riyKrOB71QeaYkNgYFXKbZofm92XDtbw7DHqYdEKRCg=; b=HlWA0Aw2fhGJi3+s8fIZKn0XWWmBOz4GR1heexh6SHdNBf/pcMg7/UjSosS8OIqsL9 Utbz+UVm67YZUe/8B/8lBFVEUy49xVLItAc0wufMKYAbZmEQxVCMphBkQQvLxTG7gXdb Vxg8p9AxYeX3acwH/CnrGWVzD+dry26qB6Yp9hnNVx0DML6PuFnNFLEEwQthtC069dkI vr6jlyIgETBWEKlKAB+Bwrb9hSI7Nys2bzuajdy1UewjpMDs8ab0Cvkuy3lyp4Dqwo/P c1bRzr8B4olaWuIDvEnHNZQaOrJ2QNi5/XIROkU1xFdQHkR9i8cDjywO9sVIUw9usVmV H8gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=BM2vivVt; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lc23-20020a170906f91700b00992ad2f72fesi2268983ejb.537.2023.07.28.02.09.58; Fri, 28 Jul 2023 02:10:22 -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=@sifive.com header.s=google header.b=BM2vivVt; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235211AbjG1Iu1 (ORCPT + 99 others); Fri, 28 Jul 2023 04:50:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235179AbjG1IuC (ORCPT ); Fri, 28 Jul 2023 04:50:02 -0400 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51ECF4C21 for ; Fri, 28 Jul 2023 01:49:02 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-7906614bc90so56968039f.3 for ; Fri, 28 Jul 2023 01:49:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1690534124; x=1691138924; 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=csmJdueaYe4TxgWwO4Wd3yP+V9n21yRw5VpjM04yUXk=; b=BM2vivVtM0Vi8txgqqrMMVb/gEDggT3Tp7zPzwqBmVjYZjyemJMBl2CnhFcmwoK3VQ 5stAE9+DdzguzRWN33KZEG+VBG8c7XDe5pfdv5xrw5IJYGmPCGgQ3i5oF9DJDcCmzGwK 6495KdKqI1WSIrcw87ndvyo3xlljoPnBbM/rPT14u/Z6dR8XWFQNUvHqbIu/pfbppDqW +GAyql6/CUacfDF7OnqUqwVrJxdk9Tjl6iSbHXyhbkDoczvCZaoniefnBZ6H5Vh6Akc4 VhPCu8cG8U2KsJmvs8g94sbhlmpRjxKqR8K17VLffXR/eTxQ2zxDnpHXrf4GgzKOqyBq MRgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690534124; x=1691138924; 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=csmJdueaYe4TxgWwO4Wd3yP+V9n21yRw5VpjM04yUXk=; b=Gp0UUcXvnCoFI/Z7lVt7qavMZ8UXYJTg6/IRvU/ljsx5Ov6r7ajNiecKuZFtUDGgHc +79SJwnWrol0qbBJ9BZD9fVeLFnh0J3r/Zb8Qv7/xGVkb74Oi65hINROa+5uoz9MuUY+ 4crNsaRr6gk0MhN7yTqpKq3vbLloMaKp26uYVnLEmbsrs1fbaICXNU1upk3UcHDKdjz9 7yR3oLznORiiUWwFZohTQB2aYTSmsuGn3LUJqzp9C8QxJzdQ9ig9EKvc1LbpLH+w++iH 5Ukp2/h7TysH+hXESB7IyxpeTAf98HyIsDrQNL6w6/P1iS1Rx8W8sP7wuR9PVLN0BeOf 1C0w== X-Gm-Message-State: ABy/qLYP+YrEqkWQMxvqoMgkwTS7QAvkseg06zOYQiQQd95ml2lyb8Q0 hXpdlErWkBWJmbmzB9sNdXFqF1rjOQdNDjo4DuXYIw== X-Received: by 2002:a5e:990d:0:b0:785:ff35:f340 with SMTP id t13-20020a5e990d000000b00785ff35f340mr2426775ioj.14.1690534124749; Fri, 28 Jul 2023 01:48:44 -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: Zong Li Date: Fri, 28 Jul 2023 16:48:32 +0800 Message-ID: Subject: Re: [PATCH 06/11] RISC-V: drivers/iommu/riscv: Add command, fault, page-req queues To: Tomasz Jeznach 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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 Fri, Jul 28, 2023 at 1:19=E2=80=AFPM Tomasz Jeznach wrote: > > On Mon, Jul 24, 2023 at 11:47=E2=80=AFAM Zong Li wro= te: > > > > 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 = devices. > > > > > > > > > > > > > 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", i= ommu->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 = away, > > > > 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 *dat= a); > > > > > +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 t= he > > > > patch that adds ATS/PRI support IMHO. This comment also applies to = its > > > > interrupt handlers below. > > > > > > > > > > ack. will do. > > > > > > > > > > > > +static inline void riscv_iommu_cmd_inval_set_addr(struct riscv_i= ommu_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 iofe= nce > > > > 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 comman= ds' > is that it is a 4k page aligned address packed at dword1[61:10], so > effectively shifted by 2 bits. Thanks for your clarifying. Just an opinion, perhaps you can use 'FIELD_PREP()' on it as well, it might be clearer. > > regards, > - Tomasz > > > > > Regards, > > > > Nick > > > > > > > > > > regards, > > > - Tomasz > > > > > > _______________________________________________ > > > linux-riscv mailing list > > > linux-riscv@lists.infradead.org > > > http://lists.infradead.org/mailman/listinfo/linux-riscv