RE: RE: [PATCH v22 3/4] scsi: ufs: Prepare HPB read for cached sub-region

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> > +static int ufshpb_fill_ppn_from_page(struct ufshpb_lu *hpb,
> > +                                    struct ufshpb_map_ctx *mctx, int pos,
> > +                                    int len, u64 *ppn_buf)
> > +{
> > +       struct page *page;
> > +       int index, offset;
> > +       int copied;
> > +
> > +       index = pos / (PAGE_SIZE / HPB_ENTRY_SIZE);
> > +       offset = pos % (PAGE_SIZE / HPB_ENTRY_SIZE);
> Maybe cache hpb->entries_per_page in ufshpb_lu_parameter_init as well?

They are just defined constants and complier will optimize them.

Thanks,
Daejun

> > +
> > +       if ((offset + len) <= (PAGE_SIZE / HPB_ENTRY_SIZE))
> > +               copied = len;
> > +       else
> > +               copied = (PAGE_SIZE / HPB_ENTRY_SIZE) - offset;
> > +
> > +       page = mctx->m_page[index];
> > +       if (unlikely(!page)) {
> > +               dev_err(&hpb->sdev_ufs_lu->sdev_dev,
> > +                       "error. cannot find page in mctx\n");
> > +               return -ENOMEM;
> > +       }
> > +
> > +       memcpy(ppn_buf, page_address(page) + (offset * HPB_ENTRY_SIZE),
> > +              copied * HPB_ENTRY_SIZE);
> > +
> > +       return copied;
> > +}
>  
>  
>   



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux