* Cornelia Huck <cornelia.h...@de.ibm.com> [2017-05-02 18:04:07 +0200]:

> On Tue, 2 May 2017 10:15:19 +0800
> Dong Jia Shi <bjsdj...@linux.vnet.ibm.com> wrote:
> 
> > * Auger Eric <eric.au...@redhat.com> [2017-05-01 19:28:23 +0200]:
> 
> > > >  static void vfio_ccw_io_notifier_handler(void *opaque)
> > > >  {
> > > >      VFIOCCWDevice *vcdev = opaque;
> > > > +    struct ccw_io_region *region = vcdev->io_region;
> > > > +    S390CCWDevice *cdev = S390_CCW_DEVICE(vcdev);
> > > > +    CcwDevice *ccw_dev = CCW_DEVICE(cdev);
> > > > +    SubchDev *sch = ccw_dev->sch;
> > > > +    SCSW *s = &sch->curr_status.scsw;
> > > > +    IRB irb;
> > > >  
> > > >      if (!event_notifier_test_and_clear(&vcdev->io_notifier)) {
> > > >          return;
> > > >      }
> > > > +
> > > > +    if (pread(vcdev->vdev.fd, region,
> > > > +              vcdev->io_region_size, vcdev->io_region_offset) == -1) {
> > > is it possible to read less bytes than requested?
> > Currently, impossible. The kernel side returns either the full region,
> > or an error.
> > But we surely could make it more friendly for a partial return. I will
> > add a check for that case, and generate a channel program check for it.
> 
> I think a channel-control check would be more appropriate here.

Hi Conny,

After reading PoP 14-43, I think you are right.

Quotation from PoP:
------------------8<-----------------------------------
Channel-control check is caused by any machine
malfunction affecting channel-subsystem controls.
... ...

Channel-control check may also indicate that an
error has been detected in the information trans-
ferred to or from main storage during an I/O opera-
tion.
... ...

Detection of the channel-control-check condition
causes the current operation, if any, to be terminated
immediately. The subchannel is made status pending
with primary and alert status or with primary, second-
ary, and alert status as a function of the type of termi-
nation, the current subchannel state, and the device
status presented, if any. When the channel sub-
system recognizes a channel-control-check condi-
tion, any previously existing intermediate interruption
condition may or may not be recognized by the chan-
nel subsystem.
------------------>8-----------------------------------

So I decide to add this piece of code:
if (size != vcdev->io_region_size) {
    /* Information transfer error, generate channel-control check. */
    s->ctrl &= ~SCSW_ACTL_START_PEND;
    s->cstat = SCSW_CSTAT_CHN_CTRL_CHK;
    s->ctrl &= ~SCSW_CTRL_MASK_STCTL;
    s->ctrl |= SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY |
               SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND;
    goto read_err;
}

-- 
Dong Jia Shi


Reply via email to